37 , mAudioOutputDevice(this)
39 , pAudioGenerator(&defaultGenerator)
40 , mAudioDeviceGuard(this)
41 , mDefaultBufferSize(4096)
89 LOGMESSAGE <<
"Starting audio device with previous settings";
96 parameters.
muted =
false;
199 LOGMESSAGE <<
"First disconnect audio device";
207 LOGMESSAGE <<
"Audio device successfully connected";
218 LOGWARNING <<
"AudioOutputDevice could not be connected, aborting.";
241 QList<QAudioDeviceInfo> infoAboutDevices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
242 QStringList currentDeviceNames;
243 for (
const QAudioDeviceInfo &dev : infoAboutDevices)
245 QString deviceName = dev.deviceName();
247 if (not deviceName.contains(
":CARD="))
249 currentDeviceNames.append(deviceName);
256 LOGMESSAGE <<
"Recognized a change in the list of audio devices";
257 LOGSTATUS <<
"The current device names are:" << currentDeviceNames;
259 QStringList newDevices,removedDevices;
260 for (
const QString &entry : currentDeviceNames)
263 if (currentDeviceNames.indexOf(entry)<0) removedDevices.append(entry);
266 if (newDevices.size()>0 and mAudioDeviceNames.size()>=0)
268 if (removedDevices.size()>0)
271 mAudioDeviceNames = currentDeviceNames;
void disconnect()
Stop the audio output device.
virtual void finallyCalledWorker() override final
Virtual worker function called when the thread stops.
AudioOutput()
Constructor.
void updateListOfDevices() override final
Update the list of devices.
virtual bool init() override
Init audio device.
virtual void initiallyCalledWorker() override final
Initially called worker function.
bool active
True of device is active.
int getVerbosity()
Get verbosity level.
void setVerbosity(int verbosity)
Set verbosity level of messages.
QString deviceName
Name of the audio device.
void onConnectionSuccessfullyEstablished(bool success)
Signal indicating that successful of failed connection.
void onAudioDevicesRemoved(const QStringList &devices)
Signal indicating that an audio device has been removed.
bool connect(const AudioDeviceParameters ¶meters)
AudioOutputDevice mAudioOutputDevice
Instance of the device.
Virtual base class for audio-generating modules.
Structure holding the parameters and status of an audio device.
virtual bool stop() override
Stop audio device.
virtual bool init()
Virtual initialization function (no functionality here)
void setVolume(double volume)
Set the global volume of the audio device.
void setVerbosity(int verbosity)
Set the verbosity level of the class-specific messages.
int sampleRate
Actual sample rate.
void setAudioGenerator(AudioGenerator &generator)
Select an AudioGenerator for output.
void setParameters(const AudioParameters ¶meters)
Set audio device parameters.
const AudioParameters getActualDeviceParameters() const
Get the actual audio device parameters.
void onChangeOfAvailableAudioDevices(const QStringList &devices)
Signal indicating that the list of available devices has been changed.
void onAudioDevicesAdded(const QStringList &devices)
Signal indicating that a new audio device was plugged in (e.g. a USB headphone)
virtual bool exit() override
Exit audio device.
int bufferSize
Buffer size of the device if applicable.
QStringList mAudioDeviceNames
Current list of devices.
virtual bool exit()
Virtual exit function (no functionality here)
AudioGenerator * pAudioGenerator
Pointer to synthesizer.
void setVolume(double volume)
Set the global volume.
virtual bool start()
Start the thread.
void setActualParameters(const AudioParameters &p)
Set audio device parameters (thread safe)
void connectDevice(const bool active) override final
Connect the audio output to a device (e.g. soundcard) with a given set of device parameters.
int channelCount
Number of channels (mono=1, stereo=2)
void onCurrentDeviceParametersChanged()
Signal indicating that the actually used audio device has changed.
void setThreadName(const QString name)
Set thread name (Linux only)
virtual bool stop()
Stop the thread.
QSettings mSettings
Settings object.
void setWantedParameters(const AudioParameters ¶meters)
Set the wanted audio device parameters.
bool startMonitoring(int seconds=20)
Start the AudioDeviceGuard.
int mDefaultBufferSize
Default audio buffer size.
virtual bool start() override
Start audio device.
void setActualParameters(const AudioParameters ¶meters)
Set the actual audio device parameters.
const AudioParameters getWantedDeviceParameters() const
Get the intended audio device parameters.
Abstract base class for audio input and output.
AudioDeviceGuard mAudioDeviceGuard
Audio device guard.
bool muted
True if device is muted.