JS8Call-Improved master
Loading...
Searching...
No Matches
SoundOutput.h
Go to the documentation of this file.
1
5
6#ifndef SOUNDOUT_H__
7#define SOUNDOUT_H__
8
9#include <QAudioDevice>
10#include <QAudioFormat>
11#include <QAudioSink>
12#include <QObject>
13#include <QString>
14
24class SoundOutput : public QObject {
25 Q_OBJECT;
26
27 public:
31 SoundOutput() = default;
32
37 qreal attenuation() const;
38
43 QAudioFormat format() const;
44
45 public Q_SLOTS:
52 void setFormat(QAudioDevice const &device, unsigned channels,
53 unsigned msBuffered = 0u);
54
61 void setDeviceFormat(QAudioDevice const &device, QAudioFormat const &format,
62 unsigned msBuffered = 0u);
63
68 void restart(QIODevice *source);
69
73 void suspend();
74
78 void resume();
79
83 void reset();
84
88 void stop();
89
94 void setAttenuation(qreal value);
95
99 void resetAttenuation();
100
101 Q_SIGNALS:
106 void error(QString message) const;
107
112 void status(QString message) const;
113
114 private:
119 bool checkStream() const;
120
121 private Q_SLOTS:
126 void handleStateChanged(QAudio::State state) const;
127
128 private:
129 QAudioDevice m_device;
130 QScopedPointer<QAudioSink> m_stream;
131 QAudioFormat m_format;
132 unsigned m_msBuffered = 0u;
133 qreal m_volume = 1.0;
134 bool m_error = false;
135};
136
137#endif
void setDeviceFormat(QAudioDevice const &device, QAudioFormat const &format, unsigned msBuffered=0u)
Set device and explicit format to use for playback.
Definition SoundOutput.cpp:74
void suspend()
Temporarily suspend output streaming.
Definition SoundOutput.cpp:134
QAudioFormat format() const
Active audio format used by the output.
Definition SoundOutput.cpp:185
void reset()
Reset internal state and stop any active stream.
Definition SoundOutput.cpp:154
void restart(QIODevice *source)
Restart output streaming from the given QIODevice source.
Definition SoundOutput.cpp:96
void setAttenuation(qreal value)
Set attenuation (volume multiplier) for playback.
Definition SoundOutput.cpp:191
qreal attenuation() const
Current attenuation (volume multiplier).
Definition SoundOutput.cpp:177
void resume()
Resume output after a suspend.
Definition SoundOutput.cpp:144
void error(QString message) const
Emitted when an error occurs related to audio output.
void stop()
Stop playback immediately.
Definition SoundOutput.cpp:164
void resetAttenuation()
Reset attenuation to default (unity) value.
Definition SoundOutput.cpp:202
SoundOutput()=default
Default-construct a SoundOutput helper.
void status(QString message) const
Emitted to report informational status updates.
void setFormat(QAudioDevice const &device, unsigned channels, unsigned msBuffered=0u)
Configure format based on device and channel count.
Definition SoundOutput.cpp:54