40 : pAudioOutput(audiooutput)
41 , pQtAudioOutputStream(nullptr)
72 ", Sample rate =" << realizedParameters.
sampleRate <<
73 ", Sample size =" << realizedParameters.
sampleSize <<
74 ", Channel count =" << realizedParameters.
channelCount <<
75 ", Buffer size =" << realizedParameters.
bufferSize;
77 QAudioDeviceInfo info;
81 info = QAudioDeviceInfo::defaultOutputDevice();
82 realizedParameters.
deviceName = info.deviceName();
95 QStringList deviceList;
96 QList<QAudioDeviceInfo> availableDevices(QAudioDeviceInfo::availableDevices(QAudio::AudioOutput));
97 for (
const QAudioDeviceInfo &deviceinfo : availableDevices)
99 if (deviceinfo.deviceName() == realizedParameters.
deviceName)
103 deviceList << deviceinfo.deviceName();
110 <<
"in the list" << deviceList;
111 LOGWARNING <<
"Now Trying to connect to default device";
112 LOGSTATUS <<
"Recursive call of connect()";
114 return connect(realizedParameters);
123 <<
"samplesize =" << realizedParameters.
sampleSize 125 <<
"buffersize =" << realizedParameters.
bufferSize;
129 format.setSampleRate(realizedParameters.
sampleRate);
130 format.setChannelCount(realizedParameters.
channelCount);
131 format.setCodec(
"audio/pcm");
132 format.setSampleSize(16);
133 format.setByteOrder(QAudioFormat::LittleEndian);
134 format.setSampleType(QAudioFormat::SignedInt);
137 if (not info.isFormatSupported(format))
139 LOGWARNING <<
"Audio format is not supported by backend," 140 <<
"falling back to nearest format";
141 format = info.nearestFormat(format);
142 if (not info.isFormatSupported(format))
144 LOGWARNING <<
"Fallback failed. Probably there is" 145 <<
"no audio output device available.";
150 LOGMESSAGE <<
"Format sample size, type and rate =" << format.sampleSize()
151 << format.sampleType() << format.sampleRate();
152 if ((format.sampleSize()!=16 and format.sampleSize()!=24)
153 or format.sampleType() != QAudioFormat::SignedInt)
155 LOGWARNING <<
"Sample type and/or size are not supported by the application.";
160 if (format.sampleRate() != realizedParameters.
sampleRate)
162 LOGMESSAGE <<
"Resetting sample rate to " << format.sampleRate();
163 realizedParameters.
sampleRate = format.sampleRate();
167 if (format.channelCount() != realizedParameters.
channelCount)
169 LOGMESSAGE <<
"Resetting channel count to " << format.channelCount();
170 realizedParameters.
channelCount = format.channelCount();
198 if (not open(QIODevice::ReadOnly))
200 LOGWARNING <<
"QAudioOutput could not be opened, aborting.";
213 if (realizedParameters.
deviceName != info.deviceName())
215 LOGERROR <<
"Severe consistency error";
222 realizedParameters.
active =
true;
223 pAudioOutput->setActualParameters(realizedParameters);
274 return static_cast<qint64
>(
292 { (void)data; (void)maxSize;
return 0; }
void disconnect()
Stop the audio output device.
AudioOutputDevice(AudioOutput *audioplayerthread)
Constructor, resetting the member variables.
void setModuleName(const QString &name)
Specify the name of the class-specific module.
int sampleSize
Sample size (16 or 24)
qint64 writeData(const char *data, qint64 maxSize) override final
Empty implementation for writing without functionality.
bool active
True of device is active.
QAudioOutput * pQtAudioOutputStream
Pointer to System-Qt audio driver.
QString deviceName
Name of the audio device.
bool connect(const AudioDeviceParameters ¶meters)
Structure holding the parameters and status of an audio device.
virtual size_t generateSound(char *data, size_t maxSize)
Virtual function for sound generation. This function generates an A440 on the right and an A220 on th...
int sampleRate
Actual sample rate.
qint64 readData(char *data, qint64 maxSize) override final
Read PCM data.
int mSampleSize
Sample size in bits (16/24)
int bufferSize
Buffer size of the device if applicable.
void setVolume(double volume)
Set the global volume.
AudioGenerator * getAudioGenerator() const
QList< int > supportedSampleRates
List of supported sample rates.
int channelCount
Number of channels (mono=1, stereo=2)
AudioOutput * pAudioOutput
Pointer back to AudioOutputThread.