SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
AudioDeviceManager Class Reference

#include <audiodevicemanager.h>

Classes

class  InputDeviceInfo
 
class  OutputDeviceInfo
 

Public Member Functions

 AudioDeviceManager ()
 
 ~AudioDeviceManager ()
 
const QList< QAudioDeviceInfo > & getInputDevices () const
 
const QList< QAudioDeviceInfo > & getOutputDevices () const
 
bool getOutputDeviceName (int outputDeviceIndex, QString &deviceName) const
 
bool getInputDeviceName (int inputDeviceIndex, QString &deviceName) const
 
int getOutputDeviceIndex (const QString &deviceName) const
 
int getInputDeviceIndex (const QString &deviceName) const
 
void addAudioSink (AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
 Add the audio sink. More...
 
void removeAudioSink (AudioFifo *audioFifo)
 Remove the audio sink. More...
 
void addAudioSource (AudioFifo *audioFifo, MessageQueue *sampleSourceMessageQueue, int inputDeviceIndex=-1)
 Add an audio source. More...
 
void removeAudioSource (AudioFifo *audioFifo)
 Remove an audio source. More...
 
bool getInputDeviceInfo (const QString &deviceName, InputDeviceInfo &deviceInfo) const
 
bool getOutputDeviceInfo (const QString &deviceName, OutputDeviceInfo &deviceInfo) const
 
int getInputSampleRate (int inputDeviceIndex=-1)
 
int getOutputSampleRate (int outputDeviceIndex=-1)
 
void setInputDeviceInfo (int inputDeviceIndex, const InputDeviceInfo &deviceInfo)
 
void setOutputDeviceInfo (int outputDeviceIndex, const OutputDeviceInfo &deviceInfo)
 
void unsetInputDeviceInfo (int inputDeviceIndex)
 
void unsetOutputDeviceInfo (int outputDeviceIndex)
 
void inputInfosCleanup ()
 Remove input info from map for input devices not present. More...
 
void outputInfosCleanup ()
 Remove output info from map for output devices not present. More...
 

Static Public Attributes

static const unsigned int m_defaultAudioSampleRate = 48000
 
static const float m_defaultAudioInputVolume = 1.0f
 
static const QString m_defaultUDPAddress = "127.0.0.1"
 
static const quint16 m_defaultUDPPort = 9998
 
static const QString m_defaultDeviceName = "System default device"
 

Private Member Functions

void resetToDefaults ()
 
QByteArray serialize () const
 
bool deserialize (const QByteArray &data)
 
void startAudioOutput (int outputDeviceIndex)
 
void stopAudioOutput (int outputDeviceIndex)
 
void startAudioInput (int inputDeviceIndex)
 
void stopAudioInput (int inputDeviceIndex)
 
void serializeInputMap (QByteArray &data) const
 
void deserializeInputMap (QByteArray &data)
 
void debugAudioInputInfos () const
 
void serializeOutputMap (QByteArray &data) const
 
void deserializeOutputMap (QByteArray &data)
 
void debugAudioOutputInfos () const
 

Private Attributes

QList< QAudioDeviceInfo > m_inputDevicesInfo
 
QList< QAudioDeviceInfo > m_outputDevicesInfo
 
QMap< AudioFifo *, int > m_audioSinkFifos
 
QMap< AudioFifo *, MessageQueue * > m_audioFifoToSinkMessageQueues
 audio sink FIFO to attached sink message queue More...
 
QMap< int, QList< MessageQueue * > > m_outputDeviceSinkMessageQueues
 sink message queues attached to device More...
 
QMap< int, AudioOutput * > m_audioOutputs
 audio device index to audio output map (index -1 is default device) More...
 
QMap< QString, OutputDeviceInfom_audioOutputInfos
 audio device name to audio output info More...
 
QMap< AudioFifo *, int > m_audioSourceFifos
 
QMap< AudioFifo *, MessageQueue * > m_audioFifoToSourceMessageQueues
 audio source FIFO to attached source message queue More...
 
QMap< int, QList< MessageQueue * > > m_inputDeviceSourceMessageQueues
 sink message queues attached to device More...
 
QMap< int, AudioInput * > m_audioInputs
 audio device index to audio input map (index -1 is default device) More...
 
QMap< QString, InputDeviceInfom_audioInputInfos
 audio device name to audio input device info More...
 

Friends

class MainSettings
 

Detailed Description

Definition at line 35 of file audiodevicemanager.h.

Constructor & Destructor Documentation

◆ AudioDeviceManager()

AudioDeviceManager::AudioDeviceManager ( )

Definition at line 75 of file audiodevicemanager.cpp.

References i, m_inputDevicesInfo, and m_outputDevicesInfo.

76 {
77  qDebug("AudioDeviceManager::AudioDeviceManager: scan input devices");
78  m_inputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
79 
80  for (int i = 0; i < m_inputDevicesInfo.size(); i++) {
81  qDebug("AudioDeviceManager::AudioDeviceManager: input device #%d: %s", i, qPrintable(m_inputDevicesInfo[i].deviceName()));
82  }
83 
84  qDebug("AudioDeviceManager::AudioDeviceManager: scan output devices");
85  m_outputDevicesInfo = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
86 
87  for (int i = 0; i < m_outputDevicesInfo.size(); i++) {
88  qDebug("AudioDeviceManager::AudioDeviceManager: output device #%d: %s", i, qPrintable(m_outputDevicesInfo[i].deviceName()));
89  }
90 }
QList< QAudioDeviceInfo > m_inputDevicesInfo
int32_t i
Definition: decimators.h:244
QList< QAudioDeviceInfo > m_outputDevicesInfo

◆ ~AudioDeviceManager()

AudioDeviceManager::~AudioDeviceManager ( )

Definition at line 92 of file audiodevicemanager.cpp.

References m_audioOutputs.

93 {
94  QMap<int, AudioOutput*>::iterator it = m_audioOutputs.begin();
95 
96  for (; it != m_audioOutputs.end(); ++it) {
97  delete(*it);
98  }
99 }
QMap< int, AudioOutput * > m_audioOutputs
audio device index to audio output map (index -1 is default device)

Member Function Documentation

◆ addAudioSink()

void AudioDeviceManager::addAudioSink ( AudioFifo audioFifo,
MessageQueue sampleSinkMessageQueue,
int  outputDeviceIndex = -1 
)

Add the audio sink.

Definition at line 249 of file audiodevicemanager.cpp.

References m_audioFifoToSinkMessageQueues, m_audioOutputs, m_audioSinkFifos, m_outputDeviceSinkMessageQueues, removeAudioSink(), and startAudioOutput().

Referenced by AMDemod::AMDemod(), AMMod::AMMod(), WFMDemod::applySettings(), AMDemod::applySettings(), UDPSink::applySettings(), NFMDemod::applySettings(), DSDDemod::applySettings(), BFMDemod::applySettings(), AMMod::applySettings(), NFMMod::applySettings(), SSBDemod::applySettings(), SSBMod::applySettings(), FreeDVDemod::applySettings(), DATVDemod::applySettings(), BFMDemod::BFMDemod(), DATVDemod::DATVDemod(), DSDDemod::DSDDemod(), FreeDVDemod::FreeDVDemod(), NFMDemod::NFMDemod(), NFMMod::NFMMod(), SSBDemod::SSBDemod(), SSBMod::SSBMod(), and WFMDemod::WFMDemod().

250 {
251  qDebug("AudioDeviceManager::addAudioSink: %d: %p", outputDeviceIndex, audioFifo);
252 
253  if (m_audioOutputs.find(outputDeviceIndex) == m_audioOutputs.end()) {
254  m_audioOutputs[outputDeviceIndex] = new AudioOutput();
255  }
256 
257  if (m_audioOutputs[outputDeviceIndex]->getNbFifos() == 0) {
258  startAudioOutput(outputDeviceIndex);
259  }
260 
261  if (m_audioSinkFifos.find(audioFifo) == m_audioSinkFifos.end()) // new FIFO
262  {
263  m_audioOutputs[outputDeviceIndex]->addFifo(audioFifo);
264  m_audioSinkFifos[audioFifo] = outputDeviceIndex; // register audio FIFO
265  m_audioFifoToSinkMessageQueues[audioFifo] = sampleSinkMessageQueue;
266  m_outputDeviceSinkMessageQueues[outputDeviceIndex].append(sampleSinkMessageQueue);
267  }
268  else
269  {
270  int audioOutputDeviceIndex = m_audioSinkFifos[audioFifo];
271 
272  if (audioOutputDeviceIndex != outputDeviceIndex) // change of audio device
273  {
274  removeAudioSink(audioFifo); // remove from current
275  m_audioOutputs[outputDeviceIndex]->addFifo(audioFifo); // add to new
276  m_audioSinkFifos[audioFifo] = outputDeviceIndex; // new index
277  m_outputDeviceSinkMessageQueues[audioOutputDeviceIndex].removeOne(sampleSinkMessageQueue);
278  m_outputDeviceSinkMessageQueues[outputDeviceIndex].append(sampleSinkMessageQueue);
279  }
280  }
281 }
void startAudioOutput(int outputDeviceIndex)
void removeAudioSink(AudioFifo *audioFifo)
Remove the audio sink.
QMap< int, QList< MessageQueue * > > m_outputDeviceSinkMessageQueues
sink message queues attached to device
QMap< AudioFifo *, MessageQueue * > m_audioFifoToSinkMessageQueues
audio sink FIFO to attached sink message queue
QMap< AudioFifo *, int > m_audioSinkFifos
QMap< int, AudioOutput * > m_audioOutputs
audio device index to audio output map (index -1 is default device)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addAudioSource()

void AudioDeviceManager::addAudioSource ( AudioFifo audioFifo,
MessageQueue sampleSourceMessageQueue,
int  inputDeviceIndex = -1 
)

Add an audio source.

Definition at line 305 of file audiodevicemanager.cpp.

References m_audioFifoToSourceMessageQueues, m_audioInputs, m_audioSourceFifos, m_outputDeviceSinkMessageQueues, removeAudioSource(), and startAudioInput().

Referenced by AMMod::AMMod(), WFMMod::applySettings(), AMMod::applySettings(), NFMMod::applySettings(), FreeDVMod::applySettings(), SSBMod::applySettings(), FreeDVMod::FreeDVMod(), NFMMod::NFMMod(), SSBMod::SSBMod(), and WFMMod::WFMMod().

306 {
307  qDebug("AudioDeviceManager::addAudioSource: %d: %p", inputDeviceIndex, audioFifo);
308 
309  if (m_audioInputs.find(inputDeviceIndex) == m_audioInputs.end()) {
310  m_audioInputs[inputDeviceIndex] = new AudioInput();
311  }
312 
313  if (m_audioInputs[inputDeviceIndex]->getNbFifos() == 0) {
314  startAudioInput(inputDeviceIndex);
315  }
316 
317  if (m_audioSourceFifos.find(audioFifo) == m_audioSourceFifos.end()) // new FIFO
318  {
319  m_audioInputs[inputDeviceIndex]->addFifo(audioFifo);
320  }
321  else
322  {
323  int audioInputDeviceIndex = m_audioSourceFifos[audioFifo];
324 
325  if (audioInputDeviceIndex != inputDeviceIndex) // change of audio device
326  {
327  removeAudioSource(audioFifo); // remove from current
328  m_audioInputs[inputDeviceIndex]->addFifo(audioFifo); // add to new
329  }
330  }
331 
332  m_audioSourceFifos[audioFifo] = inputDeviceIndex; // register audio FIFO
333  m_audioFifoToSourceMessageQueues[audioFifo] = sampleSourceMessageQueue;
334  m_outputDeviceSinkMessageQueues[inputDeviceIndex].append(sampleSourceMessageQueue);
335 }
QMap< int, AudioInput * > m_audioInputs
audio device index to audio input map (index -1 is default device)
QMap< int, QList< MessageQueue * > > m_outputDeviceSinkMessageQueues
sink message queues attached to device
QMap< AudioFifo *, MessageQueue * > m_audioFifoToSourceMessageQueues
audio source FIFO to attached source message queue
void startAudioInput(int inputDeviceIndex)
QMap< AudioFifo *, int > m_audioSourceFifos
void removeAudioSource(AudioFifo *audioFifo)
Remove an audio source.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ debugAudioInputInfos()

void AudioDeviceManager::debugAudioInputInfos ( ) const
private

Definition at line 760 of file audiodevicemanager.cpp.

References m_audioInputInfos.

Referenced by deserialize(), and serialize().

761 {
762  QMap<QString, InputDeviceInfo>::const_iterator it = m_audioInputInfos.begin();
763 
764  for (; it != m_audioInputInfos.end(); ++it)
765  {
766  qDebug() << "AudioDeviceManager::debugAudioInputInfos:"
767  << " name: " << it.key()
768  << " sampleRate: " << it.value().sampleRate
769  << " volume: " << it.value().volume;
770  }
771 }
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
+ Here is the caller graph for this function:

◆ debugAudioOutputInfos()

void AudioDeviceManager::debugAudioOutputInfos ( ) const
private

Definition at line 773 of file audiodevicemanager.cpp.

References m_audioOutputInfos.

Referenced by deserialize(), and serialize().

774 {
775  QMap<QString, OutputDeviceInfo>::const_iterator it = m_audioOutputInfos.begin();
776 
777  for (; it != m_audioOutputInfos.end(); ++it)
778  {
779  qDebug() << "AudioDeviceManager::debugAudioOutputInfos:"
780  << " name: " << it.key()
781  << " sampleRate: " << it.value().sampleRate
782  << " udpAddress: " << it.value().udpAddress
783  << " udpPort: " << it.value().udpPort
784  << " copyToUDP: " << it.value().copyToUDP
785  << " udpUseRTP: " << it.value().udpUseRTP
786  << " udpChannelMode: " << (int) it.value().udpChannelMode
787  << " udpChannelCodec: " << (int) it.value().udpChannelCodec
788  << " decimationFactor: " << it.value().udpDecimationFactor;
789  }
790 }
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
+ Here is the caller graph for this function:

◆ deserialize()

bool AudioDeviceManager::deserialize ( const QByteArray &  data)
private

Definition at line 205 of file audiodevicemanager.cpp.

References debugAudioInputInfos(), debugAudioOutputInfos(), deserializeInputMap(), deserializeOutputMap(), SimpleDeserializer::getVersion(), SimpleDeserializer::isValid(), SimpleDeserializer::readBlob(), and resetToDefaults().

Referenced by MainSettings::load().

206 {
207  qDebug("AudioDeviceManager::deserialize");
208 
209  SimpleDeserializer d(data);
210 
211  if(!d.isValid()) {
212  resetToDefaults();
213  return false;
214  }
215 
216  if(d.getVersion() == 1)
217  {
218  QByteArray data;
219 
220  d.readBlob(1, &data);
221  deserializeInputMap(data);
222  d.readBlob(2, &data);
223  deserializeOutputMap(data);
224 
227 
228  return true;
229  }
230  else
231  {
232  resetToDefaults();
233  return false;
234  }
235 }
void deserializeOutputMap(QByteArray &data)
void debugAudioInputInfos() const
void deserializeInputMap(QByteArray &data)
void debugAudioOutputInfos() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserializeInputMap()

void AudioDeviceManager::deserializeInputMap ( QByteArray &  data)
private

Definition at line 237 of file audiodevicemanager.cpp.

References m_audioInputInfos.

Referenced by deserialize().

238 {
239  QDataStream readStream(&data, QIODevice::ReadOnly);
240  readStream >> m_audioInputInfos;
241 }
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
+ Here is the caller graph for this function:

◆ deserializeOutputMap()

void AudioDeviceManager::deserializeOutputMap ( QByteArray &  data)
private

Definition at line 243 of file audiodevicemanager.cpp.

References m_audioOutputInfos.

Referenced by deserialize().

244 {
245  QDataStream readStream(&data, QIODevice::ReadOnly);
246  readStream >> m_audioOutputInfos;
247 }
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
+ Here is the caller graph for this function:

◆ getInputDeviceIndex()

int AudioDeviceManager::getInputDeviceIndex ( const QString &  deviceName) const

Definition at line 156 of file audiodevicemanager.cpp.

References i, and m_inputDevicesInfo.

Referenced by WFMMod::applySettings(), AMMod::applySettings(), NFMMod::applySettings(), FreeDVMod::applySettings(), SSBMod::applySettings(), FCDProPlusInput::openFCDAudio(), and FCDProInput::openFCDAudio().

157 {
158  for (int i = 0; i < m_inputDevicesInfo.size(); i++)
159  {
160  //qDebug("AudioDeviceManager::getInputDeviceIndex: %d: %s|%s", i, qPrintable(deviceName), qPrintable(m_inputDevicesInfo[i].deviceName()));
161  if (deviceName == m_inputDevicesInfo[i].deviceName()) {
162  return i;
163  }
164  }
165 
166  return -1; // system default
167 }
QList< QAudioDeviceInfo > m_inputDevicesInfo
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ getInputDeviceInfo()

bool AudioDeviceManager::getInputDeviceInfo ( const QString &  deviceName,
InputDeviceInfo deviceInfo 
) const

Definition at line 452 of file audiodevicemanager.cpp.

References m_audioInputInfos.

Referenced by AudioDialogX::AudioDialogX(), AudioSelectDialog::getDeviceInfos(), getInputSampleRate(), WebAPIAdapterSrv::instanceAudioGet(), WebAPIAdapterGUI::instanceAudioGet(), WebAPIAdapterGUI::instanceAudioInputDelete(), WebAPIAdapterSrv::instanceAudioInputDelete(), WebAPIAdapterGUI::instanceAudioInputPatch(), WebAPIAdapterSrv::instanceAudioInputPatch(), AudioDialogX::on_audioInTree_currentItemChanged(), setInputDeviceInfo(), and unsetInputDeviceInfo().

453 {
454  if (m_audioInputInfos.find(deviceName) == m_audioInputInfos.end())
455  {
456  return false;
457  }
458  else
459  {
460  deviceInfo = m_audioInputInfos[deviceName];
461  return true;
462  }
463 }
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
+ Here is the caller graph for this function:

◆ getInputDeviceName()

bool AudioDeviceManager::getInputDeviceName ( int  inputDeviceIndex,
QString &  deviceName 
) const

Definition at line 122 of file audiodevicemanager.cpp.

References m_defaultDeviceName, and m_inputDevicesInfo.

Referenced by AudioSelectDialog::accept(), getInputSampleRate(), WebAPIAdapterSrv::instanceAudioInputDelete(), WebAPIAdapterGUI::instanceAudioInputDelete(), WebAPIAdapterSrv::instanceAudioInputPatch(), WebAPIAdapterGUI::instanceAudioInputPatch(), setInputDeviceInfo(), startAudioInput(), and unsetInputDeviceInfo().

123 {
124  if (inputDeviceIndex < 0)
125  {
126  deviceName = m_defaultDeviceName;
127  return true;
128  }
129  else
130  {
131  if (inputDeviceIndex < m_inputDevicesInfo.size())
132  {
133  deviceName = m_inputDevicesInfo[inputDeviceIndex].deviceName();
134  return true;
135  }
136  else
137  {
138  return false;
139  }
140  }
141 }
static const QString m_defaultDeviceName
QList< QAudioDeviceInfo > m_inputDevicesInfo
+ Here is the caller graph for this function:

◆ getInputDevices()

const QList<QAudioDeviceInfo>& AudioDeviceManager::getInputDevices ( ) const
inline

◆ getInputSampleRate()

int AudioDeviceManager::getInputSampleRate ( int  inputDeviceIndex = -1)

Definition at line 478 of file audiodevicemanager.cpp.

References getInputDeviceInfo(), getInputDeviceName(), m_defaultAudioSampleRate, and AudioDeviceManager::InputDeviceInfo::sampleRate.

Referenced by AMMod::AMMod(), WFMMod::applySettings(), AMMod::applySettings(), NFMMod::applySettings(), FreeDVMod::applySettings(), SSBMod::applySettings(), FreeDVMod::FreeDVMod(), NFMMod::NFMMod(), SSBMod::SSBMod(), and WFMMod::WFMMod().

479 {
480  QString deviceName;
481 
482  if (!getInputDeviceName(inputDeviceIndex, deviceName))
483  {
484  qDebug("AudioDeviceManager::getInputSampleRate: unknown device index %d", inputDeviceIndex);
486  }
487 
488  InputDeviceInfo deviceInfo;
489 
490  if (!getInputDeviceInfo(deviceName, deviceInfo))
491  {
492  qDebug("AudioDeviceManager::getInputSampleRate: unknown device %s", qPrintable(deviceName));
494  }
495  else
496  {
497  return deviceInfo.sampleRate;
498  }
499 }
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const
bool getInputDeviceInfo(const QString &deviceName, InputDeviceInfo &deviceInfo) const
static const unsigned int m_defaultAudioSampleRate
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOutputDeviceIndex()

int AudioDeviceManager::getOutputDeviceIndex ( const QString &  deviceName) const

Definition at line 143 of file audiodevicemanager.cpp.

References i, and m_outputDevicesInfo.

Referenced by WFMDemod::applySettings(), AMDemod::applySettings(), NFMDemod::applySettings(), DSDDemod::applySettings(), BFMDemod::applySettings(), AMMod::applySettings(), NFMMod::applySettings(), SSBDemod::applySettings(), SSBMod::applySettings(), FreeDVDemod::applySettings(), and DATVDemod::applySettings().

144 {
145  for (int i = 0; i < m_outputDevicesInfo.size(); i++)
146  {
147  //qDebug("AudioDeviceManager::getOutputDeviceIndex: %d: %s|%s", i, qPrintable(deviceName), qPrintable(m_outputDevicesInfo[i].deviceName()));
148  if (deviceName == m_outputDevicesInfo[i].deviceName()) {
149  return i;
150  }
151  }
152 
153  return -1; // system default
154 }
int32_t i
Definition: decimators.h:244
QList< QAudioDeviceInfo > m_outputDevicesInfo
+ Here is the caller graph for this function:

◆ getOutputDeviceInfo()

bool AudioDeviceManager::getOutputDeviceInfo ( const QString &  deviceName,
OutputDeviceInfo deviceInfo 
) const

Definition at line 465 of file audiodevicemanager.cpp.

References m_audioOutputInfos.

Referenced by AudioDialogX::AudioDialogX(), AudioSelectDialog::getDeviceInfos(), getOutputSampleRate(), WebAPIAdapterSrv::instanceAudioGet(), WebAPIAdapterGUI::instanceAudioGet(), WebAPIAdapterGUI::instanceAudioOutputDelete(), WebAPIAdapterSrv::instanceAudioOutputDelete(), WebAPIAdapterGUI::instanceAudioOutputPatch(), WebAPIAdapterSrv::instanceAudioOutputPatch(), AudioDialogX::on_audioOutTree_currentItemChanged(), setOutputDeviceInfo(), and unsetOutputDeviceInfo().

466 {
467  if (m_audioOutputInfos.find(deviceName) == m_audioOutputInfos.end())
468  {
469  return false;
470  }
471  else
472  {
473  deviceInfo = m_audioOutputInfos[deviceName];
474  return true;
475  }
476 }
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
+ Here is the caller graph for this function:

◆ getOutputDeviceName()

bool AudioDeviceManager::getOutputDeviceName ( int  outputDeviceIndex,
QString &  deviceName 
) const

Definition at line 101 of file audiodevicemanager.cpp.

References m_defaultDeviceName, and m_outputDevicesInfo.

Referenced by AudioSelectDialog::accept(), getOutputSampleRate(), WebAPIAdapterSrv::instanceAudioOutputDelete(), WebAPIAdapterGUI::instanceAudioOutputDelete(), WebAPIAdapterSrv::instanceAudioOutputPatch(), WebAPIAdapterGUI::instanceAudioOutputPatch(), setOutputDeviceInfo(), startAudioOutput(), and unsetOutputDeviceInfo().

102 {
103  if (outputDeviceIndex < 0)
104  {
105  deviceName = m_defaultDeviceName;
106  return true;
107  }
108  else
109  {
110  if (outputDeviceIndex < m_outputDevicesInfo.size())
111  {
112  deviceName = m_outputDevicesInfo[outputDeviceIndex].deviceName();
113  return true;
114  }
115  else
116  {
117  return false;
118  }
119  }
120 }
static const QString m_defaultDeviceName
QList< QAudioDeviceInfo > m_outputDevicesInfo
+ Here is the caller graph for this function:

◆ getOutputDevices()

const QList<QAudioDeviceInfo>& AudioDeviceManager::getOutputDevices ( ) const
inline

Definition at line 93 of file audiodevicemanager.h.

Referenced by AudioDialogX::AudioDialogX(), AudioSelectDialog::AudioSelectDialog(), WebAPIAdapterGUI::instanceAudioGet(), and WebAPIAdapterSrv::instanceAudioGet().

93 { return m_outputDevicesInfo; }
QList< QAudioDeviceInfo > m_outputDevicesInfo
+ Here is the caller graph for this function:

◆ getOutputSampleRate()

int AudioDeviceManager::getOutputSampleRate ( int  outputDeviceIndex = -1)

Definition at line 501 of file audiodevicemanager.cpp.

References getOutputDeviceInfo(), getOutputDeviceName(), m_defaultAudioSampleRate, and AudioDeviceManager::OutputDeviceInfo::sampleRate.

Referenced by AMDemod::AMDemod(), AMMod::AMMod(), WFMDemod::applySettings(), AMDemod::applySettings(), NFMDemod::applySettings(), DSDDemod::applySettings(), BFMDemod::applySettings(), AMMod::applySettings(), NFMMod::applySettings(), SSBDemod::applySettings(), SSBMod::applySettings(), FreeDVDemod::applySettings(), BFMDemod::BFMDemod(), DSDDemod::DSDDemod(), FreeDVDemod::FreeDVDemod(), NFMDemod::NFMDemod(), NFMMod::NFMMod(), SSBDemod::SSBDemod(), SSBMod::SSBMod(), and WFMDemod::WFMDemod().

502 {
503  QString deviceName;
504 
505  if (!getOutputDeviceName(outputDeviceIndex, deviceName))
506  {
507  qDebug("AudioDeviceManager::getOutputSampleRate: unknown device index %d", outputDeviceIndex);
509  }
510 
511  OutputDeviceInfo deviceInfo;
512 
513  if (!getOutputDeviceInfo(deviceName, deviceInfo))
514  {
515  qDebug("AudioDeviceManager::getOutputSampleRate: unknown device %s", qPrintable(deviceName));
517  }
518  else
519  {
520  return deviceInfo.sampleRate;
521  }
522 }
bool getOutputDeviceInfo(const QString &deviceName, OutputDeviceInfo &deviceInfo) const
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const
static const unsigned int m_defaultAudioSampleRate
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ inputInfosCleanup()

void AudioDeviceManager::inputInfosCleanup ( )

Remove input info from map for input devices not present.

Definition at line 704 of file audiodevicemanager.cpp.

References m_audioInputInfos, m_defaultDeviceName, and m_inputDevicesInfo.

Referenced by WebAPIAdapterGUI::instanceAudioInputCleanupPatch(), WebAPIAdapterSrv::instanceAudioInputCleanupPatch(), and AudioDialogX::on_inputCleanup_clicked().

705 {
706  QSet<QString> deviceNames;
707  deviceNames.insert(m_defaultDeviceName);
708  QList<QAudioDeviceInfo>::const_iterator itd = m_inputDevicesInfo.begin();
709 
710  for (; itd != m_inputDevicesInfo.end(); ++itd)
711  {
712  qDebug("AudioDeviceManager::inputInfosCleanup: device: %s", qPrintable(itd->deviceName()));
713  deviceNames.insert(itd->deviceName());
714  }
715 
716  QMap<QString, InputDeviceInfo>::iterator itm = m_audioInputInfos.begin();
717 
718  for (; itm != m_audioInputInfos.end();)
719  {
720  if (!deviceNames.contains(itm.key()))
721  {
722  qDebug("AudioDeviceManager::inputInfosCleanup: removing key: %s", qPrintable(itm.key()));
723  m_audioInputInfos.erase(itm++);
724  }
725  else
726  {
727  ++itm;
728  }
729  }
730 }
static const QString m_defaultDeviceName
QList< QAudioDeviceInfo > m_inputDevicesInfo
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
+ Here is the caller graph for this function:

◆ outputInfosCleanup()

void AudioDeviceManager::outputInfosCleanup ( )

Remove output info from map for output devices not present.

Definition at line 732 of file audiodevicemanager.cpp.

References m_audioOutputInfos, m_defaultDeviceName, and m_outputDevicesInfo.

Referenced by WebAPIAdapterGUI::instanceAudioOutputCleanupPatch(), WebAPIAdapterSrv::instanceAudioOutputCleanupPatch(), and AudioDialogX::on_outputCleanup_clicked().

733 {
734  QSet<QString> deviceNames;
735  deviceNames.insert(m_defaultDeviceName);
736  QList<QAudioDeviceInfo>::const_iterator itd = m_outputDevicesInfo.begin();
737 
738  for (; itd != m_outputDevicesInfo.end(); ++itd)
739  {
740  qDebug("AudioDeviceManager::outputInfosCleanup: device: %s", qPrintable(itd->deviceName()));
741  deviceNames.insert(itd->deviceName());
742  }
743 
744  QMap<QString, OutputDeviceInfo>::iterator itm = m_audioOutputInfos.begin();
745 
746  for (; itm != m_audioOutputInfos.end();)
747  {
748  if (!deviceNames.contains(itm.key()))
749  {
750  qDebug("AudioDeviceManager::outputInfosCleanup: removing key: %s", qPrintable(itm.key()));
751  m_audioOutputInfos.erase(itm++);
752  }
753  else
754  {
755  ++itm;
756  }
757  }
758 }
static const QString m_defaultDeviceName
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
QList< QAudioDeviceInfo > m_outputDevicesInfo
+ Here is the caller graph for this function:

◆ removeAudioSink()

void AudioDeviceManager::removeAudioSink ( AudioFifo audioFifo)

Remove the audio sink.

Definition at line 283 of file audiodevicemanager.cpp.

References m_audioFifoToSinkMessageQueues, m_audioOutputs, m_audioSinkFifos, m_outputDeviceSinkMessageQueues, and stopAudioOutput().

Referenced by addAudioSink(), UDPSink::applySettings(), AMDemod::~AMDemod(), AMMod::~AMMod(), BFMDemod::~BFMDemod(), DATVDemod::~DATVDemod(), DSDDemod::~DSDDemod(), FreeDVDemod::~FreeDVDemod(), NFMDemod::~NFMDemod(), NFMMod::~NFMMod(), SSBDemod::~SSBDemod(), SSBMod::~SSBMod(), UDPSink::~UDPSink(), and WFMDemod::~WFMDemod().

284 {
285  qDebug("AudioDeviceManager::removeAudioSink: %p", audioFifo);
286 
287  if (m_audioSinkFifos.find(audioFifo) == m_audioSinkFifos.end())
288  {
289  qWarning("AudioDeviceManager::removeAudioSink: audio FIFO %p not found", audioFifo);
290  return;
291  }
292 
293  int audioOutputDeviceIndex = m_audioSinkFifos[audioFifo];
294  m_audioOutputs[audioOutputDeviceIndex]->removeFifo(audioFifo);
295 
296  if (m_audioOutputs[audioOutputDeviceIndex]->getNbFifos() == 0) {
297  stopAudioOutput(audioOutputDeviceIndex);
298  }
299 
300  m_audioSinkFifos.remove(audioFifo); // unregister audio FIFO
301  m_outputDeviceSinkMessageQueues[audioOutputDeviceIndex].removeOne(m_audioFifoToSinkMessageQueues[audioFifo]);
302  m_audioFifoToSinkMessageQueues.remove(audioFifo);
303 }
void stopAudioOutput(int outputDeviceIndex)
QMap< int, QList< MessageQueue * > > m_outputDeviceSinkMessageQueues
sink message queues attached to device
QMap< AudioFifo *, MessageQueue * > m_audioFifoToSinkMessageQueues
audio sink FIFO to attached sink message queue
QMap< AudioFifo *, int > m_audioSinkFifos
QMap< int, AudioOutput * > m_audioOutputs
audio device index to audio output map (index -1 is default device)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAudioSource()

void AudioDeviceManager::removeAudioSource ( AudioFifo audioFifo)

Remove an audio source.

Definition at line 337 of file audiodevicemanager.cpp.

References m_audioFifoToSourceMessageQueues, m_audioInputs, m_audioSourceFifos, m_inputDeviceSourceMessageQueues, and stopAudioInput().

Referenced by addAudioSource(), AMMod::~AMMod(), FreeDVMod::~FreeDVMod(), NFMMod::~NFMMod(), SSBMod::~SSBMod(), and WFMMod::~WFMMod().

338 {
339  qDebug("AudioDeviceManager::removeAudioSource: %p", audioFifo);
340 
341  if (m_audioSourceFifos.find(audioFifo) == m_audioSourceFifos.end())
342  {
343  qWarning("AudioDeviceManager::removeAudioSource: audio FIFO %p not found", audioFifo);
344  return;
345  }
346 
347  int audioInputDeviceIndex = m_audioSourceFifos[audioFifo];
348  m_audioInputs[audioInputDeviceIndex]->removeFifo(audioFifo);
349 
350  if (m_audioInputs[audioInputDeviceIndex]->getNbFifos() == 0) {
351  stopAudioInput(audioInputDeviceIndex);
352  }
353 
354  m_audioSourceFifos.remove(audioFifo); // unregister audio FIFO
355  m_inputDeviceSourceMessageQueues[audioInputDeviceIndex].removeOne(m_audioFifoToSourceMessageQueues[audioFifo]);
356  m_audioFifoToSourceMessageQueues.remove(audioFifo);
357 }
QMap< int, QList< MessageQueue * > > m_inputDeviceSourceMessageQueues
sink message queues attached to device
void stopAudioInput(int inputDeviceIndex)
QMap< int, AudioInput * > m_audioInputs
audio device index to audio input map (index -1 is default device)
QMap< AudioFifo *, MessageQueue * > m_audioFifoToSourceMessageQueues
audio source FIFO to attached source message queue
QMap< AudioFifo *, int > m_audioSourceFifos
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetToDefaults()

void AudioDeviceManager::resetToDefaults ( )
private

Definition at line 170 of file audiodevicemanager.cpp.

Referenced by deserialize().

171 {
172 }
+ Here is the caller graph for this function:

◆ serialize()

QByteArray AudioDeviceManager::serialize ( ) const
private

Definition at line 174 of file audiodevicemanager.cpp.

References debugAudioInputInfos(), debugAudioOutputInfos(), SimpleSerializer::final(), serializeInputMap(), serializeOutputMap(), and SimpleSerializer::writeBlob().

Referenced by MainSettings::save().

175 {
176  qDebug("AudioDeviceManager::serialize");
179 
180  SimpleSerializer s(1);
181  QByteArray data;
182 
183  serializeInputMap(data);
184  s.writeBlob(1, data);
185  serializeOutputMap(data);
186  s.writeBlob(2, data);
187 
188  return s.final();
189 }
void serializeOutputMap(QByteArray &data) const
void debugAudioInputInfos() const
void serializeInputMap(QByteArray &data) const
void debugAudioOutputInfos() const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serializeInputMap()

void AudioDeviceManager::serializeInputMap ( QByteArray &  data) const
private

Definition at line 191 of file audiodevicemanager.cpp.

References m_audioInputInfos.

Referenced by serialize().

192 {
193  QDataStream *stream = new QDataStream(&data, QIODevice::WriteOnly);
194  *stream << m_audioInputInfos;
195  delete stream;
196 }
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
+ Here is the caller graph for this function:

◆ serializeOutputMap()

void AudioDeviceManager::serializeOutputMap ( QByteArray &  data) const
private

Definition at line 198 of file audiodevicemanager.cpp.

References m_audioOutputInfos.

Referenced by serialize().

199 {
200  QDataStream *stream = new QDataStream(&data, QIODevice::WriteOnly);
201  *stream << m_audioOutputInfos;
202  delete stream;
203 }
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
+ Here is the caller graph for this function:

◆ setInputDeviceInfo()

void AudioDeviceManager::setInputDeviceInfo ( int  inputDeviceIndex,
const InputDeviceInfo deviceInfo 
)

Definition at line 525 of file audiodevicemanager.cpp.

References DSPConfigureAudio::AudioInput, getInputDeviceInfo(), getInputDeviceName(), AudioInput::getRate(), m_audioInputInfos, m_audioInputs, m_inputDeviceSourceMessageQueues, AudioDeviceManager::InputDeviceInfo::sampleRate, AudioInput::setVolume(), AudioInput::start(), AudioInput::stop(), and AudioDeviceManager::InputDeviceInfo::volume.

Referenced by AudioDialogX::accept(), WebAPIAdapterSrv::instanceAudioInputPatch(), and WebAPIAdapterGUI::instanceAudioInputPatch().

526 {
527  QString deviceName;
528 
529  if (!getInputDeviceName(inputDeviceIndex, deviceName))
530  {
531  qWarning("AudioDeviceManager::setInputDeviceInfo: unknown device index %d", inputDeviceIndex);
532  return;
533  }
534 
535  InputDeviceInfo oldDeviceInfo;
536 
537  if (!getInputDeviceInfo(deviceName, oldDeviceInfo))
538  {
539  qDebug("AudioDeviceManager::setInputDeviceInfo: unknown device %s", qPrintable(deviceName));
540  }
541 
542  m_audioInputInfos[deviceName] = deviceInfo;
543 
544  if (m_audioInputs.find(inputDeviceIndex) == m_audioInputs.end()) { // no FIFO registered yet hence no audio input has been allocated yet
545  return;
546  }
547 
548  AudioInput *audioInput = m_audioInputs[inputDeviceIndex];
549 
550  if (oldDeviceInfo.sampleRate != deviceInfo.sampleRate)
551  {
552  audioInput->stop();
553  audioInput->start(inputDeviceIndex, deviceInfo.sampleRate);
554  m_audioInputInfos[deviceName].sampleRate = audioInput->getRate(); // store actual sample rate
555 
556  // send message to attached channels
557  QList<MessageQueue *>::const_iterator it = m_inputDeviceSourceMessageQueues[inputDeviceIndex].begin();
558 
559  for (; it != m_inputDeviceSourceMessageQueues[inputDeviceIndex].end(); ++it)
560  {
562  (*it)->push(msg);
563  }
564  }
565 
566  audioInput->setVolume(deviceInfo.volume);
567 }
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
QMap< int, QList< MessageQueue * > > m_inputDeviceSourceMessageQueues
sink message queues attached to device
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const
QMap< int, AudioInput * > m_audioInputs
audio device index to audio input map (index -1 is default device)
bool getInputDeviceInfo(const QString &deviceName, InputDeviceInfo &deviceInfo) const
bool start(int device, int rate)
Definition: audioinput.cpp:49
void stop()
Definition: audioinput.cpp:121
void setVolume(float volume)
Definition: audioinput.h:47
uint getRate() const
Definition: audioinput.h:45
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOutputDeviceInfo()

void AudioDeviceManager::setOutputDeviceInfo ( int  outputDeviceIndex,
const OutputDeviceInfo deviceInfo 
)

Definition at line 569 of file audiodevicemanager.cpp.

References DSPConfigureAudio::AudioOutput, AudioDeviceManager::OutputDeviceInfo::copyToUDP, getOutputDeviceInfo(), getOutputDeviceName(), AudioOutput::getRate(), m_audioOutputInfos, m_audioOutputs, m_outputDeviceSinkMessageQueues, AudioDeviceManager::OutputDeviceInfo::sampleRate, AudioOutput::setUdpChannelFormat(), AudioOutput::setUdpChannelMode(), AudioOutput::setUdpCopyToUDP(), AudioOutput::setUdpDecimation(), AudioOutput::setUdpDestination(), AudioOutput::setUdpUseRTP(), AudioOutput::start(), AudioOutput::stop(), AudioDeviceManager::OutputDeviceInfo::udpAddress, AudioDeviceManager::OutputDeviceInfo::udpChannelCodec, AudioDeviceManager::OutputDeviceInfo::udpChannelMode, AudioOutput::UDPChannelStereo, AudioDeviceManager::OutputDeviceInfo::udpDecimationFactor, AudioDeviceManager::OutputDeviceInfo::udpPort, and AudioDeviceManager::OutputDeviceInfo::udpUseRTP.

Referenced by AudioDialogX::accept(), WebAPIAdapterSrv::instanceAudioOutputPatch(), and WebAPIAdapterGUI::instanceAudioOutputPatch().

570 {
571  QString deviceName;
572 
573  if (!getOutputDeviceName(outputDeviceIndex, deviceName))
574  {
575  qWarning("AudioDeviceManager::setOutputDeviceInfo: unknown device index %d", outputDeviceIndex);
576  return;
577  }
578 
579  OutputDeviceInfo oldDeviceInfo;
580 
581  if (!getOutputDeviceInfo(deviceName, oldDeviceInfo))
582  {
583  qInfo("AudioDeviceManager::setOutputDeviceInfo: unknown device %s", qPrintable(deviceName));
584  }
585 
586  m_audioOutputInfos[deviceName] = deviceInfo;
587 
588  if (m_audioOutputs.find(outputDeviceIndex) == m_audioOutputs.end())
589  {
590  qWarning("AudioDeviceManager::setOutputDeviceInfo: index: %d device: %s no FIFO registered yet hence no audio output has been allocated yet",
591  outputDeviceIndex, qPrintable(deviceName));
592  return;
593  }
594 
595  AudioOutput *audioOutput = m_audioOutputs[outputDeviceIndex];
596 
597  if (oldDeviceInfo.sampleRate != deviceInfo.sampleRate)
598  {
599  audioOutput->stop();
600  audioOutput->start(outputDeviceIndex, deviceInfo.sampleRate);
601  m_audioOutputInfos[deviceName].sampleRate = audioOutput->getRate(); // store actual sample rate
602 
603  // send message to attached channels
604  QList<MessageQueue *>::const_iterator it = m_outputDeviceSinkMessageQueues[outputDeviceIndex].begin();
605 
606  for (; it != m_outputDeviceSinkMessageQueues[outputDeviceIndex].end(); ++it)
607  {
609  (*it)->push(msg);
610  }
611  }
612 
613  audioOutput->setUdpCopyToUDP(deviceInfo.copyToUDP);
614  audioOutput->setUdpDestination(deviceInfo.udpAddress, deviceInfo.udpPort);
615  audioOutput->setUdpUseRTP(deviceInfo.udpUseRTP);
616  audioOutput->setUdpChannelMode(deviceInfo.udpChannelMode);
617  audioOutput->setUdpChannelFormat(deviceInfo.udpChannelCodec, deviceInfo.udpChannelMode == AudioOutput::UDPChannelStereo, deviceInfo.sampleRate);
618  audioOutput->setUdpDecimation(deviceInfo.udpDecimationFactor);
619 
620  qDebug("AudioDeviceManager::setOutputDeviceInfo: index: %d device: %s updated",
621  outputDeviceIndex, qPrintable(deviceName));
622 }
void setUdpChannelMode(UDPChannelMode udpChannelMode)
unsigned int getRate() const
Definition: audiooutput.h:65
void setUdpCopyToUDP(bool copyToUDP)
bool start(int device, int rate)
Definition: audiooutput.cpp:54
void setUdpDecimation(uint32_t decimation)
void setUdpChannelFormat(UDPChannelCodec udpChannelCodec, bool stereo, int sampleRate)
QMap< int, QList< MessageQueue * > > m_outputDeviceSinkMessageQueues
sink message queues attached to device
bool getOutputDeviceInfo(const QString &deviceName, OutputDeviceInfo &deviceInfo) const
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const
void setUdpDestination(const QString &address, uint16_t port)
void setUdpUseRTP(bool useRTP)
QMap< int, AudioOutput * > m_audioOutputs
audio device index to audio output map (index -1 is default device)
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startAudioInput()

void AudioDeviceManager::startAudioInput ( int  inputDeviceIndex)
private

Definition at line 417 of file audiodevicemanager.cpp.

References getInputDeviceName(), m_audioInputInfos, m_audioInputs, m_defaultAudioInputVolume, and m_defaultAudioSampleRate.

Referenced by addAudioSource(), and unsetInputDeviceInfo().

418 {
419  unsigned int sampleRate;
420  float volume;
421  QString deviceName;
422 
423  if (getInputDeviceName(inputDeviceIndex, deviceName))
424  {
425  if (m_audioInputInfos.find(deviceName) == m_audioInputInfos.end())
426  {
427  sampleRate = m_defaultAudioSampleRate;
428  volume = m_defaultAudioInputVolume;
429  }
430  else
431  {
432  sampleRate = m_audioInputInfos[deviceName].sampleRate;
433  volume = m_audioInputInfos[deviceName].volume;
434  }
435 
436  m_audioInputs[inputDeviceIndex]->start(inputDeviceIndex, sampleRate);
437  m_audioInputs[inputDeviceIndex]->setVolume(volume);
438  m_audioInputInfos[deviceName].sampleRate = m_audioInputs[inputDeviceIndex]->getRate();
439  m_audioInputInfos[deviceName].volume = volume;
440  }
441  else
442  {
443  qWarning("AudioDeviceManager::startAudioInput: unknown device index %d", inputDeviceIndex);
444  }
445 }
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const
QMap< int, AudioInput * > m_audioInputs
audio device index to audio input map (index -1 is default device)
static const unsigned int m_defaultAudioSampleRate
static const float m_defaultAudioInputVolume
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startAudioOutput()

void AudioDeviceManager::startAudioOutput ( int  outputDeviceIndex)
private

Definition at line 359 of file audiodevicemanager.cpp.

References getOutputDeviceName(), m_audioOutputInfos, m_audioOutputs, m_defaultAudioSampleRate, m_defaultUDPAddress, m_defaultUDPPort, AudioOutput::UDPChannelLeft, and AudioOutput::UDPCodecL16.

Referenced by addAudioSink(), and unsetOutputDeviceInfo().

360 {
361  unsigned int sampleRate;
362  QString udpAddress;
363  quint16 udpPort;
364  bool copyAudioToUDP;
365  bool udpUseRTP;
366  AudioOutput::UDPChannelMode udpChannelMode;
367  AudioOutput::UDPChannelCodec udpChannelCodec;
368  uint32_t decimationFactor;
369  QString deviceName;
370 
371  if (getOutputDeviceName(outputDeviceIndex, deviceName))
372  {
373  if (m_audioOutputInfos.find(deviceName) == m_audioOutputInfos.end())
374  {
375  sampleRate = m_defaultAudioSampleRate;
376  udpAddress = m_defaultUDPAddress;
377  udpPort = m_defaultUDPPort;
378  copyAudioToUDP = false;
379  udpUseRTP = false;
380  udpChannelMode = AudioOutput::UDPChannelLeft;
381  udpChannelCodec = AudioOutput::UDPCodecL16;
382  decimationFactor = 1;
383  }
384  else
385  {
386  sampleRate = m_audioOutputInfos[deviceName].sampleRate;
387  udpAddress = m_audioOutputInfos[deviceName].udpAddress;
388  udpPort = m_audioOutputInfos[deviceName].udpPort;
389  copyAudioToUDP = m_audioOutputInfos[deviceName].copyToUDP;
390  udpUseRTP = m_audioOutputInfos[deviceName].udpUseRTP;
391  udpChannelMode = m_audioOutputInfos[deviceName].udpChannelMode;
392  udpChannelCodec = m_audioOutputInfos[deviceName].udpChannelCodec;
393  decimationFactor = m_audioOutputInfos[deviceName].udpDecimationFactor;
394  }
395 
396  m_audioOutputs[outputDeviceIndex]->start(outputDeviceIndex, sampleRate);
397  m_audioOutputInfos[deviceName].sampleRate = m_audioOutputs[outputDeviceIndex]->getRate(); // update with actual rate
398  m_audioOutputInfos[deviceName].udpAddress = udpAddress;
399  m_audioOutputInfos[deviceName].udpPort = udpPort;
400  m_audioOutputInfos[deviceName].copyToUDP = copyAudioToUDP;
401  m_audioOutputInfos[deviceName].udpUseRTP = udpUseRTP;
402  m_audioOutputInfos[deviceName].udpChannelMode = udpChannelMode;
403  m_audioOutputInfos[deviceName].udpChannelCodec = udpChannelCodec;
404  m_audioOutputInfos[deviceName].udpDecimationFactor = decimationFactor;
405  }
406  else
407  {
408  qWarning("AudioDeviceManager::startAudioOutput: unknown device index %d", outputDeviceIndex);
409  }
410 }
static const quint16 m_defaultUDPPort
static const QString m_defaultUDPAddress
unsigned int uint32_t
Definition: rtptypes_win.h:46
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const
Linear 16 bit (no codec)
Definition: audiooutput.h:47
static const unsigned int m_defaultAudioSampleRate
QMap< int, AudioOutput * > m_audioOutputs
audio device index to audio output map (index -1 is default device)
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stopAudioInput()

void AudioDeviceManager::stopAudioInput ( int  inputDeviceIndex)
private

Definition at line 447 of file audiodevicemanager.cpp.

References m_audioInputs.

Referenced by removeAudioSource(), and unsetInputDeviceInfo().

448 {
449  m_audioInputs[inputDeviceIndex]->stop();
450 }
QMap< int, AudioInput * > m_audioInputs
audio device index to audio input map (index -1 is default device)
+ Here is the caller graph for this function:

◆ stopAudioOutput()

void AudioDeviceManager::stopAudioOutput ( int  outputDeviceIndex)
private

Definition at line 412 of file audiodevicemanager.cpp.

References m_audioOutputs.

Referenced by removeAudioSink(), and unsetOutputDeviceInfo().

413 {
414  m_audioOutputs[outputDeviceIndex]->stop();
415 }
QMap< int, AudioOutput * > m_audioOutputs
audio device index to audio output map (index -1 is default device)
+ Here is the caller graph for this function:

◆ unsetInputDeviceInfo()

void AudioDeviceManager::unsetInputDeviceInfo ( int  inputDeviceIndex)

Definition at line 664 of file audiodevicemanager.cpp.

References DSPConfigureAudio::AudioInput, getInputDeviceInfo(), getInputDeviceName(), m_audioInputInfos, m_audioInputs, m_inputDeviceSourceMessageQueues, AudioDeviceManager::InputDeviceInfo::sampleRate, startAudioInput(), and stopAudioInput().

Referenced by AudioDialogX::accept(), WebAPIAdapterGUI::instanceAudioInputDelete(), WebAPIAdapterSrv::instanceAudioInputDelete(), WebAPIAdapterGUI::instanceAudioOutputDelete(), and WebAPIAdapterSrv::instanceAudioOutputDelete().

665 {
666  QString deviceName;
667 
668  if (!getInputDeviceName(inputDeviceIndex, deviceName))
669  {
670  qWarning("AudioDeviceManager::unsetInputDeviceInfo: unknown device index %d", inputDeviceIndex);
671  return;
672  }
673 
674  InputDeviceInfo oldDeviceInfo;
675 
676  if (!getInputDeviceInfo(deviceName, oldDeviceInfo))
677  {
678  qDebug("AudioDeviceManager::unsetInputDeviceInfo: unregistered device %s", qPrintable(deviceName));
679  return;
680  }
681 
682  m_audioInputInfos.remove(deviceName);
683 
684  if (m_audioInputs.find(inputDeviceIndex) == m_audioInputs.end()) { // no FIFO registered yet hence no audio input has been allocated yet
685  return;
686  }
687 
688  stopAudioInput(inputDeviceIndex);
689  startAudioInput(inputDeviceIndex);
690 
691  if (oldDeviceInfo.sampleRate != m_audioInputInfos[deviceName].sampleRate)
692  {
693  // send message to attached channels
694  QList<MessageQueue *>::const_iterator it = m_inputDeviceSourceMessageQueues[inputDeviceIndex].begin();
695 
696  for (; it != m_inputDeviceSourceMessageQueues[inputDeviceIndex].end(); ++it)
697  {
699  (*it)->push(msg);
700  }
701  }
702 }
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
QMap< int, QList< MessageQueue * > > m_inputDeviceSourceMessageQueues
sink message queues attached to device
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const
void stopAudioInput(int inputDeviceIndex)
QMap< int, AudioInput * > m_audioInputs
audio device index to audio input map (index -1 is default device)
bool getInputDeviceInfo(const QString &deviceName, InputDeviceInfo &deviceInfo) const
void startAudioInput(int inputDeviceIndex)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unsetOutputDeviceInfo()

void AudioDeviceManager::unsetOutputDeviceInfo ( int  outputDeviceIndex)

Definition at line 624 of file audiodevicemanager.cpp.

References DSPConfigureAudio::AudioOutput, getOutputDeviceInfo(), getOutputDeviceName(), m_audioOutputInfos, m_audioOutputs, m_outputDeviceSinkMessageQueues, AudioDeviceManager::OutputDeviceInfo::sampleRate, startAudioOutput(), and stopAudioOutput().

Referenced by AudioDialogX::accept().

625 {
626  QString deviceName;
627 
628  if (!getOutputDeviceName(outputDeviceIndex, deviceName))
629  {
630  qWarning("AudioDeviceManager::unsetOutputDeviceInfo: unknown device index %d", outputDeviceIndex);
631  return;
632  }
633 
634  OutputDeviceInfo oldDeviceInfo;
635 
636  if (!getOutputDeviceInfo(deviceName, oldDeviceInfo))
637  {
638  qDebug("AudioDeviceManager::unsetOutputDeviceInfo: unregistered device %s", qPrintable(deviceName));
639  return;
640  }
641 
642  m_audioOutputInfos.remove(deviceName);
643 
644  if (m_audioOutputs.find(outputDeviceIndex) == m_audioOutputs.end()) { // no FIFO registered yet hence no audio output has been allocated yet
645  return;
646  }
647 
648  stopAudioOutput(outputDeviceIndex);
649  startAudioOutput(outputDeviceIndex);
650 
651  if (oldDeviceInfo.sampleRate != m_audioOutputInfos[deviceName].sampleRate)
652  {
653  // send message to attached channels
654  QList<MessageQueue *>::const_iterator it = m_outputDeviceSinkMessageQueues[outputDeviceIndex].begin();
655 
656  for (; it != m_outputDeviceSinkMessageQueues[outputDeviceIndex].end(); ++it)
657  {
659  (*it)->push(msg);
660  }
661  }
662 }
void startAudioOutput(int outputDeviceIndex)
void stopAudioOutput(int outputDeviceIndex)
QMap< int, QList< MessageQueue * > > m_outputDeviceSinkMessageQueues
sink message queues attached to device
bool getOutputDeviceInfo(const QString &deviceName, OutputDeviceInfo &deviceInfo) const
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const
QMap< int, AudioOutput * > m_audioOutputs
audio device index to audio output map (index -1 is default device)
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ MainSettings

friend class MainSettings
friend

Definition at line 156 of file audiodevicemanager.h.

Member Data Documentation

◆ m_audioFifoToSinkMessageQueues

QMap<AudioFifo*, MessageQueue*> AudioDeviceManager::m_audioFifoToSinkMessageQueues
private

audio sink FIFO to attached sink message queue

Definition at line 128 of file audiodevicemanager.h.

Referenced by addAudioSink(), and removeAudioSink().

◆ m_audioFifoToSourceMessageQueues

QMap<AudioFifo*, MessageQueue*> AudioDeviceManager::m_audioFifoToSourceMessageQueues
private

audio source FIFO to attached source message queue

Definition at line 134 of file audiodevicemanager.h.

Referenced by addAudioSource(), and removeAudioSource().

◆ m_audioInputInfos

QMap<QString, InputDeviceInfo> AudioDeviceManager::m_audioInputInfos
private

◆ m_audioInputs

QMap<int, AudioInput*> AudioDeviceManager::m_audioInputs
private

audio device index to audio input map (index -1 is default device)

Definition at line 136 of file audiodevicemanager.h.

Referenced by addAudioSource(), removeAudioSource(), setInputDeviceInfo(), startAudioInput(), stopAudioInput(), and unsetInputDeviceInfo().

◆ m_audioOutputInfos

QMap<QString, OutputDeviceInfo> AudioDeviceManager::m_audioOutputInfos
private

◆ m_audioOutputs

QMap<int, AudioOutput*> AudioDeviceManager::m_audioOutputs
private

audio device index to audio output map (index -1 is default device)

Definition at line 130 of file audiodevicemanager.h.

Referenced by addAudioSink(), removeAudioSink(), setOutputDeviceInfo(), startAudioOutput(), stopAudioOutput(), unsetOutputDeviceInfo(), and ~AudioDeviceManager().

◆ m_audioSinkFifos

QMap<AudioFifo*, int> AudioDeviceManager::m_audioSinkFifos
private

Definition at line 127 of file audiodevicemanager.h.

Referenced by addAudioSink(), and removeAudioSink().

◆ m_audioSourceFifos

QMap<AudioFifo*, int> AudioDeviceManager::m_audioSourceFifos
private

Definition at line 133 of file audiodevicemanager.h.

Referenced by addAudioSource(), and removeAudioSource().

◆ m_defaultAudioInputVolume

const float AudioDeviceManager::m_defaultAudioInputVolume = 1.0f
static

Definition at line 118 of file audiodevicemanager.h.

Referenced by startAudioInput().

◆ m_defaultAudioSampleRate

const unsigned int AudioDeviceManager::m_defaultAudioSampleRate = 48000
static

◆ m_defaultDeviceName

const QString AudioDeviceManager::m_defaultDeviceName = "System default device"
static

◆ m_defaultUDPAddress

const QString AudioDeviceManager::m_defaultUDPAddress = "127.0.0.1"
static

Definition at line 119 of file audiodevicemanager.h.

Referenced by startAudioOutput().

◆ m_defaultUDPPort

const quint16 AudioDeviceManager::m_defaultUDPPort = 9998
static

Definition at line 120 of file audiodevicemanager.h.

Referenced by startAudioOutput().

◆ m_inputDevicesInfo

QList<QAudioDeviceInfo> AudioDeviceManager::m_inputDevicesInfo
private

◆ m_inputDeviceSourceMessageQueues

QMap<int, QList<MessageQueue*> > AudioDeviceManager::m_inputDeviceSourceMessageQueues
private

sink message queues attached to device

Definition at line 135 of file audiodevicemanager.h.

Referenced by removeAudioSource(), setInputDeviceInfo(), and unsetInputDeviceInfo().

◆ m_outputDevicesInfo

QList<QAudioDeviceInfo> AudioDeviceManager::m_outputDevicesInfo
private

◆ m_outputDeviceSinkMessageQueues

QMap<int, QList<MessageQueue*> > AudioDeviceManager::m_outputDeviceSinkMessageQueues
private

sink message queues attached to device

Definition at line 129 of file audiodevicemanager.h.

Referenced by addAudioSink(), addAudioSource(), removeAudioSink(), setOutputDeviceInfo(), and unsetOutputDeviceInfo().


The documentation for this class was generated from the following files: