24 #include <QDataStream> 77 qDebug(
"AudioDeviceManager::AudioDeviceManager: scan input devices");
81 qDebug(
"AudioDeviceManager::AudioDeviceManager: input device #%d: %s",
i, qPrintable(
m_inputDevicesInfo[
i].deviceName()));
84 qDebug(
"AudioDeviceManager::AudioDeviceManager: scan output devices");
88 qDebug(
"AudioDeviceManager::AudioDeviceManager: output device #%d: %s",
i, qPrintable(
m_outputDevicesInfo[
i].deviceName()));
103 if (outputDeviceIndex < 0)
124 if (inputDeviceIndex < 0)
176 qDebug(
"AudioDeviceManager::serialize");
193 QDataStream *stream =
new QDataStream(&data, QIODevice::WriteOnly);
200 QDataStream *stream =
new QDataStream(&data, QIODevice::WriteOnly);
207 qDebug(
"AudioDeviceManager::deserialize");
239 QDataStream readStream(&data, QIODevice::ReadOnly);
245 QDataStream readStream(&data, QIODevice::ReadOnly);
251 qDebug(
"AudioDeviceManager::addAudioSink: %d: %p", outputDeviceIndex, audioFifo);
272 if (audioOutputDeviceIndex != outputDeviceIndex)
285 qDebug(
"AudioDeviceManager::removeAudioSink: %p", audioFifo);
289 qWarning(
"AudioDeviceManager::removeAudioSink: audio FIFO %p not found", audioFifo);
307 qDebug(
"AudioDeviceManager::addAudioSource: %d: %p", inputDeviceIndex, audioFifo);
325 if (audioInputDeviceIndex != inputDeviceIndex)
339 qDebug(
"AudioDeviceManager::removeAudioSource: %p", audioFifo);
343 qWarning(
"AudioDeviceManager::removeAudioSource: audio FIFO %p not found", audioFifo);
350 if (
m_audioInputs[audioInputDeviceIndex]->getNbFifos() == 0) {
361 unsigned int sampleRate;
378 copyAudioToUDP =
false;
382 decimationFactor = 1;
396 m_audioOutputs[outputDeviceIndex]->start(outputDeviceIndex, sampleRate);
408 qWarning(
"AudioDeviceManager::startAudioOutput: unknown device index %d", outputDeviceIndex);
419 unsigned int sampleRate;
436 m_audioInputs[inputDeviceIndex]->start(inputDeviceIndex, sampleRate);
443 qWarning(
"AudioDeviceManager::startAudioInput: unknown device index %d", inputDeviceIndex);
484 qDebug(
"AudioDeviceManager::getInputSampleRate: unknown device index %d", inputDeviceIndex);
492 qDebug(
"AudioDeviceManager::getInputSampleRate: unknown device %s", qPrintable(deviceName));
507 qDebug(
"AudioDeviceManager::getOutputSampleRate: unknown device index %d", outputDeviceIndex);
515 qDebug(
"AudioDeviceManager::getOutputSampleRate: unknown device %s", qPrintable(deviceName));
531 qWarning(
"AudioDeviceManager::setInputDeviceInfo: unknown device index %d", inputDeviceIndex);
539 qDebug(
"AudioDeviceManager::setInputDeviceInfo: unknown device %s", qPrintable(deviceName));
575 qWarning(
"AudioDeviceManager::setOutputDeviceInfo: unknown device index %d", outputDeviceIndex);
583 qInfo(
"AudioDeviceManager::setOutputDeviceInfo: unknown device %s", qPrintable(deviceName));
590 qWarning(
"AudioDeviceManager::setOutputDeviceInfo: index: %d device: %s no FIFO registered yet hence no audio output has been allocated yet",
591 outputDeviceIndex, qPrintable(deviceName));
620 qDebug(
"AudioDeviceManager::setOutputDeviceInfo: index: %d device: %s updated",
621 outputDeviceIndex, qPrintable(deviceName));
630 qWarning(
"AudioDeviceManager::unsetOutputDeviceInfo: unknown device index %d", outputDeviceIndex);
638 qDebug(
"AudioDeviceManager::unsetOutputDeviceInfo: unregistered device %s", qPrintable(deviceName));
670 qWarning(
"AudioDeviceManager::unsetInputDeviceInfo: unknown device index %d", inputDeviceIndex);
678 qDebug(
"AudioDeviceManager::unsetInputDeviceInfo: unregistered device %s", qPrintable(deviceName));
706 QSet<QString> deviceNames;
712 qDebug(
"AudioDeviceManager::inputInfosCleanup: device: %s", qPrintable(itd->deviceName()));
713 deviceNames.insert(itd->deviceName());
720 if (!deviceNames.contains(itm.key()))
722 qDebug(
"AudioDeviceManager::inputInfosCleanup: removing key: %s", qPrintable(itm.key()));
734 QSet<QString> deviceNames;
740 qDebug(
"AudioDeviceManager::outputInfosCleanup: device: %s", qPrintable(itd->deviceName()));
741 deviceNames.insert(itd->deviceName());
748 if (!deviceNames.contains(itm.key()))
750 qDebug(
"AudioDeviceManager::outputInfosCleanup: removing key: %s", qPrintable(itm.key()));
766 qDebug() <<
"AudioDeviceManager::debugAudioInputInfos:" 767 <<
" name: " << it.key()
768 <<
" sampleRate: " << it.value().sampleRate
769 <<
" volume: " << it.value().volume;
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;
static const QString m_defaultDeviceName
void setUdpChannelMode(UDPChannelMode udpChannelMode)
QList< QAudioDeviceInfo > m_inputDevicesInfo
void addAudioSink(AudioFifo *audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex=-1)
Add the audio sink.
uint32_t udpDecimationFactor
int getOutputSampleRate(int outputDeviceIndex=-1)
void startAudioOutput(int outputDeviceIndex)
QMap< QString, InputDeviceInfo > m_audioInputInfos
audio device name to audio input device info
static const quint16 m_defaultUDPPort
static const QString m_defaultUDPAddress
QMap< int, QList< MessageQueue * > > m_inputDeviceSourceMessageQueues
sink message queues attached to device
int getInputSampleRate(int inputDeviceIndex=-1)
void serializeOutputMap(QByteArray &data) const
unsigned int getRate() const
void outputInfosCleanup()
Remove output info from map for output devices not present.
int getOutputDeviceIndex(const QString &deviceName) const
bool deserialize(const QByteArray &data)
QByteArray serialize() const
void removeAudioSink(AudioFifo *audioFifo)
Remove the audio sink.
void stopAudioOutput(int outputDeviceIndex)
void writeBlob(quint32 id, const QByteArray &value)
void setUdpCopyToUDP(bool copyToUDP)
bool start(int device, int rate)
void deserializeOutputMap(QByteArray &data)
AudioOutput::UDPChannelCodec udpChannelCodec
void debugAudioInputInfos() const
void deserializeInputMap(QByteArray &data)
void addAudioSource(AudioFifo *audioFifo, MessageQueue *sampleSourceMessageQueue, int inputDeviceIndex=-1)
Add an audio source.
void setUdpDecimation(uint32_t decimation)
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const
void setOutputDeviceInfo(int outputDeviceIndex, const OutputDeviceInfo &deviceInfo)
void stopAudioInput(int inputDeviceIndex)
QMap< int, AudioInput * > m_audioInputs
audio device index to audio input map (index -1 is default device)
void setUdpChannelFormat(UDPChannelCodec udpChannelCodec, bool stereo, int sampleRate)
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
void serializeInputMap(QByteArray &data) const
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
bool getInputDeviceInfo(const QString &deviceName, InputDeviceInfo &deviceInfo) const
void inputInfosCleanup()
Remove input info from map for input devices not present.
QDataStream & operator>>(QDataStream &ds, AudioDeviceManager::InputDeviceInfo &info)
bool getOutputDeviceInfo(const QString &deviceName, OutputDeviceInfo &deviceInfo) const
QDataStream & operator<<(QDataStream &ds, const AudioDeviceManager::InputDeviceInfo &info)
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const
quint32 getVersion() const
void unsetInputDeviceInfo(int inputDeviceIndex)
QMap< AudioFifo *, MessageQueue * > m_audioFifoToSourceMessageQueues
audio source FIFO to attached source message queue
QMap< AudioFifo *, int > m_audioSinkFifos
AudioOutput::UDPChannelMode udpChannelMode
void setUdpDestination(const QString &address, uint16_t port)
static const unsigned int m_defaultAudioSampleRate
void startAudioInput(int inputDeviceIndex)
void setInputDeviceInfo(int inputDeviceIndex, const InputDeviceInfo &deviceInfo)
int getInputDeviceIndex(const QString &deviceName) const
void setUdpUseRTP(bool useRTP)
QMap< AudioFifo *, int > m_audioSourceFifos
void debugAudioOutputInfos() const
QMap< int, AudioOutput * > m_audioOutputs
audio device index to audio output map (index -1 is default device)
static const float m_defaultAudioInputVolume
void unsetOutputDeviceInfo(int outputDeviceIndex)
const QByteArray & final()
QMap< QString, OutputDeviceInfo > m_audioOutputInfos
audio device name to audio output info
void removeAudioSource(AudioFifo *audioFifo)
Remove an audio source.
QList< QAudioDeviceInfo > m_outputDevicesInfo