1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-04 16:01:14 -05:00

Renamed sdrbase AudioOutput to AudioOutputDevice

This commit is contained in:
f4exb 2020-11-12 22:13:44 +01:00
parent 00b234b85c
commit d2710806bf
21 changed files with 81 additions and 86 deletions

View File

@ -22,7 +22,6 @@
#include <stdio.h> #include <stdio.h>
#include "device/deviceapi.h" #include "device/deviceapi.h"
#include "audio/audiooutput.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "chanalyzer.h" #include "chanalyzer.h"

View File

@ -21,7 +21,6 @@
#include "util/stepfunctions.h" #include "util/stepfunctions.h"
#include "util/db.h" #include "util/db.h"
#include "audio/audiooutput.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/devicesamplemimo.h" #include "dsp/devicesamplemimo.h"

View File

@ -19,7 +19,7 @@
#include <complex.h> #include <complex.h>
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "dsp/fftfilt.h" #include "dsp/fftfilt.h"
#include "util/db.h" #include "util/db.h"
#include "util/stepfunctions.h" #include "util/stepfunctions.h"

View File

@ -21,8 +21,6 @@
#include <stdio.h> #include <stdio.h>
#include <complex.h> #include <complex.h>
#include "audio/audiooutput.h"
#include "atvdemodsink.h" #include "atvdemodsink.h"
const int ATVDemodSink::m_ssbFftLen = 1024; const int ATVDemodSink::m_ssbFftLen = 1024;

View File

@ -22,7 +22,7 @@
#include <QTime> #include <QTime>
#include <QDebug> #include <QDebug>
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/devicesamplemimo.h" #include "dsp/devicesamplemimo.h"

View File

@ -22,7 +22,7 @@
#include <QDebug> #include <QDebug>
#include <QObject> #include <QObject>
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "device/deviceapi.h" #include "device/deviceapi.h"

View File

@ -33,7 +33,7 @@
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/basebandsamplesink.h" #include "dsp/basebandsamplesink.h"
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "util/db.h" #include "util/db.h"
#include "dsddemodsink.h" #include "dsddemodsink.h"

View File

@ -21,7 +21,7 @@
#include "codec2/modem_stats.h" #include "codec2/modem_stats.h"
#include "dsp/basebandsamplesink.h" #include "dsp/basebandsamplesink.h"
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "util/db.h" #include "util/db.h"
#include "freedvdemodsink.h" #include "freedvdemodsink.h"

View File

@ -23,7 +23,7 @@
#include "util/stepfunctions.h" #include "util/stepfunctions.h"
#include "util/db.h" #include "util/db.h"
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/devicesamplemimo.h" #include "dsp/devicesamplemimo.h"

View File

@ -20,7 +20,7 @@
#include <QTime> #include <QTime>
#include <QDebug> #include <QDebug>
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/devicesamplemimo.h" #include "dsp/devicesamplemimo.h"

View File

@ -33,7 +33,7 @@
#include "SWGWFMDemodReport.h" #include "SWGWFMDemodReport.h"
#include "device/deviceapi.h" #include "device/deviceapi.h"
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/devicesamplemimo.h" #include "dsp/devicesamplemimo.h"

View File

@ -21,7 +21,7 @@
#include <QTime> #include <QTime>
#include <QDebug> #include <QDebug>
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/devicesamplemimo.h" #include "dsp/devicesamplemimo.h"

View File

@ -33,7 +33,6 @@
#include "SWGChannelReport.h" #include "SWGChannelReport.h"
#include "SWGFreqTrackerReport.h" #include "SWGFreqTrackerReport.h"
#include "audio/audiooutput.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "dsp/fftfilt.h" #include "dsp/fftfilt.h"

View File

@ -75,7 +75,7 @@ set(sdrbase_SOURCES
audio/audiofilter.cpp audio/audiofilter.cpp
audio/audiog722.cpp audio/audiog722.cpp
audio/audioopus.cpp audio/audioopus.cpp
audio/audiooutput.cpp audio/audiooutputdevice.cpp
audio/audioinputdevice.cpp audio/audioinputdevice.cpp
audio/audionetsink.cpp audio/audionetsink.cpp
audio/audioresampler.cpp audio/audioresampler.cpp
@ -214,7 +214,7 @@ set(sdrbase_HEADERS
audio/audiofifo.h audio/audiofifo.h
audio/audiofilter.h audio/audiofilter.h
audio/audiog722.h audio/audiog722.h
audio/audiooutput.h audio/audiooutputdevice.h
audio/audioopus.h audio/audioopus.h
audio/audioinputdevice.h audio/audioinputdevice.h
audio/audionetsink.h audio/audionetsink.h

View File

@ -67,8 +67,8 @@ QDataStream& operator>>(QDataStream& ds, AudioDeviceManager::OutputDeviceInfo& i
>> intChannelMode >> intChannelMode
>> intChannelCodec >> intChannelCodec
>> info.udpDecimationFactor; >> info.udpDecimationFactor;
info.udpChannelMode = (AudioOutput::UDPChannelMode) intChannelMode; info.udpChannelMode = (AudioOutputDevice::UDPChannelMode) intChannelMode;
info.udpChannelCodec = (AudioOutput::UDPChannelCodec) intChannelCodec; info.udpChannelCodec = (AudioOutputDevice::UDPChannelCodec) intChannelCodec;
return ds; return ds;
} }
@ -94,7 +94,7 @@ AudioDeviceManager::AudioDeviceManager()
AudioDeviceManager::~AudioDeviceManager() AudioDeviceManager::~AudioDeviceManager()
{ {
QMap<int, AudioOutput*>::iterator it = m_audioOutputs.begin(); QMap<int, AudioOutputDevice*>::iterator it = m_audioOutputs.begin();
for (; it != m_audioOutputs.end(); ++it) { for (; it != m_audioOutputs.end(); ++it) {
delete(*it); delete(*it);
@ -254,7 +254,7 @@ void AudioDeviceManager::addAudioSink(AudioFifo* audioFifo, MessageQueue *sample
qDebug("AudioDeviceManager::addAudioSink: %d: %p", outputDeviceIndex, audioFifo); qDebug("AudioDeviceManager::addAudioSink: %d: %p", outputDeviceIndex, audioFifo);
if (m_audioOutputs.find(outputDeviceIndex) == m_audioOutputs.end()) { if (m_audioOutputs.find(outputDeviceIndex) == m_audioOutputs.end()) {
m_audioOutputs[outputDeviceIndex] = new AudioOutput(); m_audioOutputs[outputDeviceIndex] = new AudioOutputDevice();
} }
if ((m_audioOutputs[outputDeviceIndex]->getNbFifos() == 0) && if ((m_audioOutputs[outputDeviceIndex]->getNbFifos() == 0) &&
@ -370,8 +370,8 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
quint16 udpPort; quint16 udpPort;
bool copyAudioToUDP; bool copyAudioToUDP;
bool udpUseRTP; bool udpUseRTP;
AudioOutput::UDPChannelMode udpChannelMode; AudioOutputDevice::UDPChannelMode udpChannelMode;
AudioOutput::UDPChannelCodec udpChannelCodec; AudioOutputDevice::UDPChannelCodec udpChannelCodec;
uint32_t decimationFactor; uint32_t decimationFactor;
QString deviceName; QString deviceName;
@ -384,8 +384,8 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
udpPort = m_defaultUDPPort; udpPort = m_defaultUDPPort;
copyAudioToUDP = false; copyAudioToUDP = false;
udpUseRTP = false; udpUseRTP = false;
udpChannelMode = AudioOutput::UDPChannelLeft; udpChannelMode = AudioOutputDevice::UDPChannelLeft;
udpChannelCodec = AudioOutput::UDPCodecL16; udpChannelCodec = AudioOutputDevice::UDPCodecL16;
decimationFactor = 1; decimationFactor = 1;
} }
else else
@ -617,7 +617,7 @@ void AudioDeviceManager::setOutputDeviceInfo(int outputDeviceIndex, const Output
return; return;
} }
AudioOutput *audioOutput = m_audioOutputs[outputDeviceIndex]; AudioOutputDevice *audioOutput = m_audioOutputs[outputDeviceIndex];
if (oldDeviceInfo.sampleRate != deviceInfo.sampleRate) if (oldDeviceInfo.sampleRate != deviceInfo.sampleRate)
{ {
@ -639,7 +639,7 @@ void AudioDeviceManager::setOutputDeviceInfo(int outputDeviceIndex, const Output
audioOutput->setUdpDestination(deviceInfo.udpAddress, deviceInfo.udpPort); audioOutput->setUdpDestination(deviceInfo.udpAddress, deviceInfo.udpPort);
audioOutput->setUdpUseRTP(deviceInfo.udpUseRTP); audioOutput->setUdpUseRTP(deviceInfo.udpUseRTP);
audioOutput->setUdpChannelMode(deviceInfo.udpChannelMode); audioOutput->setUdpChannelMode(deviceInfo.udpChannelMode);
audioOutput->setUdpChannelFormat(deviceInfo.udpChannelCodec, deviceInfo.udpChannelMode == AudioOutput::UDPChannelStereo, deviceInfo.sampleRate); audioOutput->setUdpChannelFormat(deviceInfo.udpChannelCodec, deviceInfo.udpChannelMode == AudioOutputDevice::UDPChannelStereo, deviceInfo.sampleRate);
audioOutput->setUdpDecimation(deviceInfo.udpDecimationFactor); audioOutput->setUdpDecimation(deviceInfo.udpDecimationFactor);
qDebug("AudioDeviceManager::setOutputDeviceInfo: index: %d device: %s updated", qDebug("AudioDeviceManager::setOutputDeviceInfo: index: %d device: %s updated",

View File

@ -25,7 +25,7 @@
#include <QAudioDeviceInfo> #include <QAudioDeviceInfo>
#include "audio/audioinputdevice.h" #include "audio/audioinputdevice.h"
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "export.h" #include "export.h"
class QDataStream; class QDataStream;
@ -60,8 +60,8 @@ public:
udpPort(m_defaultUDPPort), udpPort(m_defaultUDPPort),
copyToUDP(false), copyToUDP(false),
udpUseRTP(false), udpUseRTP(false),
udpChannelMode(AudioOutput::UDPChannelLeft), udpChannelMode(AudioOutputDevice::UDPChannelLeft),
udpChannelCodec(AudioOutput::UDPCodecL16), udpChannelCodec(AudioOutputDevice::UDPCodecL16),
udpDecimationFactor(1) udpDecimationFactor(1)
{} {}
void resetToDefaults() { void resetToDefaults() {
@ -70,8 +70,8 @@ public:
udpPort = m_defaultUDPPort; udpPort = m_defaultUDPPort;
copyToUDP = false; copyToUDP = false;
udpUseRTP = false; udpUseRTP = false;
udpChannelMode = AudioOutput::UDPChannelLeft; udpChannelMode = AudioOutputDevice::UDPChannelLeft;
udpChannelCodec = AudioOutput::UDPCodecL16; udpChannelCodec = AudioOutputDevice::UDPCodecL16;
udpDecimationFactor = 1; udpDecimationFactor = 1;
} }
int sampleRate; int sampleRate;
@ -79,8 +79,8 @@ public:
quint16 udpPort; quint16 udpPort;
bool copyToUDP; bool copyToUDP;
bool udpUseRTP; bool udpUseRTP;
AudioOutput::UDPChannelMode udpChannelMode; AudioOutputDevice::UDPChannelMode udpChannelMode;
AudioOutput::UDPChannelCodec udpChannelCodec; AudioOutputDevice::UDPChannelCodec udpChannelCodec;
uint32_t udpDecimationFactor; uint32_t udpDecimationFactor;
friend QDataStream& operator<<(QDataStream& ds, const OutputDeviceInfo& info); friend QDataStream& operator<<(QDataStream& ds, const OutputDeviceInfo& info);
friend QDataStream& operator>>(QDataStream& ds, OutputDeviceInfo& info); friend QDataStream& operator>>(QDataStream& ds, OutputDeviceInfo& info);
@ -127,7 +127,7 @@ private:
QMap<AudioFifo*, int> m_audioSinkFifos; //< audio sink FIFO to audio output device index-1 map QMap<AudioFifo*, int> m_audioSinkFifos; //< audio sink FIFO to audio output device index-1 map
QMap<AudioFifo*, MessageQueue*> m_audioFifoToSinkMessageQueues; //!< audio sink FIFO to attached sink message queue QMap<AudioFifo*, MessageQueue*> m_audioFifoToSinkMessageQueues; //!< audio sink FIFO to attached sink message queue
QMap<int, QList<MessageQueue*> > m_outputDeviceSinkMessageQueues; //!< sink message queues attached to device QMap<int, QList<MessageQueue*> > m_outputDeviceSinkMessageQueues; //!< sink message queues attached to device
QMap<int, AudioOutput*> m_audioOutputs; //!< audio device index to audio output map (index -1 is default device) QMap<int, AudioOutputDevice*> 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 QMap<QString, OutputDeviceInfo> m_audioOutputInfos; //!< audio device name to audio output info
QMap<AudioFifo*, int> m_audioSourceFifos; //< audio source FIFO to audio input device index-1 map QMap<AudioFifo*, int> m_audioSourceFifos; //< audio source FIFO to audio input device index-1 map

View File

@ -20,11 +20,11 @@
#include <QAudioFormat> #include <QAudioFormat>
#include <QAudioDeviceInfo> #include <QAudioDeviceInfo>
#include <QAudioOutput> #include <QAudioOutput>
#include "audiooutput.h" #include "audiooutputdevice.h"
#include "audiofifo.h" #include "audiofifo.h"
#include "audionetsink.h" #include "audionetsink.h"
AudioOutput::AudioOutput() : AudioOutputDevice::AudioOutputDevice() :
m_mutex(QMutex::Recursive), m_mutex(QMutex::Recursive),
m_audioOutput(0), m_audioOutput(0),
m_audioNetSink(0), m_audioNetSink(0),
@ -37,7 +37,7 @@ AudioOutput::AudioOutput() :
{ {
} }
AudioOutput::~AudioOutput() AudioOutputDevice::~AudioOutputDevice()
{ {
// stop(); // stop();
// //
@ -51,7 +51,7 @@ AudioOutput::~AudioOutput()
// m_audioFifos.clear(); // m_audioFifos.clear();
} }
bool AudioOutput::start(int device, int rate) bool AudioOutputDevice::start(int device, int rate)
{ {
// if (m_audioUsageCount == 0) // if (m_audioUsageCount == 0)
@ -62,7 +62,7 @@ bool AudioOutput::start(int device, int rate)
if (device < 0) if (device < 0)
{ {
devInfo = QAudioDeviceInfo::defaultOutputDevice(); devInfo = QAudioDeviceInfo::defaultOutputDevice();
qWarning("AudioOutput::start: using system default device %s", qPrintable(devInfo.defaultOutputDevice().deviceName())); qWarning("AudioOutputDevice::start: using system default device %s", qPrintable(devInfo.defaultOutputDevice().deviceName()));
} }
else else
{ {
@ -71,12 +71,12 @@ bool AudioOutput::start(int device, int rate)
if (device < devicesInfo.size()) if (device < devicesInfo.size())
{ {
devInfo = devicesInfo[device]; devInfo = devicesInfo[device];
qWarning("AudioOutput::start: using audio device #%d: %s", device, qPrintable(devInfo.deviceName())); qWarning("AudioOutputDevice::start: using audio device #%d: %s", device, qPrintable(devInfo.deviceName()));
} }
else else
{ {
devInfo = QAudioDeviceInfo::defaultOutputDevice(); devInfo = QAudioDeviceInfo::defaultOutputDevice();
qWarning("AudioOutput::start: audio device #%d does not exist. Using system default device %s", device, qPrintable(devInfo.defaultOutputDevice().deviceName())); qWarning("AudioOutputDevice::start: audio device #%d does not exist. Using system default device %s", device, qPrintable(devInfo.defaultOutputDevice().deviceName()));
} }
} }
@ -99,16 +99,16 @@ bool AudioOutput::start(int device, int rate)
<< " codec: " << m_audioFormat.codec().toStdString() << " codec: " << m_audioFormat.codec().toStdString()
<< " byteOrder: " << (m_audioFormat.byteOrder() == QAudioFormat::BigEndian ? "BE" : "LE") << " byteOrder: " << (m_audioFormat.byteOrder() == QAudioFormat::BigEndian ? "BE" : "LE")
<< " sampleType: " << (int) m_audioFormat.sampleType(); << " sampleType: " << (int) m_audioFormat.sampleType();
qWarning("AudioOutput::start: format %d Hz 2xS16LE audio/pcm not supported. Using: %s", rate, os.str().c_str()); qWarning("AudioOutputDevice::start: format %d Hz 2xS16LE audio/pcm not supported. Using: %s", rate, os.str().c_str());
} }
else else
{ {
qInfo("AudioOutput::start: audio format OK"); qInfo("AudioOutputDevice::start: audio format OK");
} }
if (m_audioFormat.sampleSize() != 16) if (m_audioFormat.sampleSize() != 16)
{ {
qWarning("AudioOutput::start: Audio device '%s' failed", qPrintable(devInfo.defaultOutputDevice().deviceName())); qWarning("AudioOutputDevice::start: Audio device '%s' failed", qPrintable(devInfo.defaultOutputDevice().deviceName()));
return false; return false;
} }
@ -121,7 +121,7 @@ bool AudioOutput::start(int device, int rate)
if (m_audioOutput->state() != QAudio::ActiveState) if (m_audioOutput->state() != QAudio::ActiveState)
{ {
qWarning("AudioOutput::start: cannot start"); qWarning("AudioOutputDevice::start: cannot start");
} }
// } // }
// //
@ -130,9 +130,9 @@ bool AudioOutput::start(int device, int rate)
return true; return true;
} }
void AudioOutput::stop() void AudioOutputDevice::stop()
{ {
qDebug("AudioOutput::stop"); qDebug("AudioOutputDevice::stop");
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
m_audioOutput->stop(); m_audioOutput->stop();
@ -157,14 +157,14 @@ void AudioOutput::stop()
// } // }
} }
void AudioOutput::addFifo(AudioFifo* audioFifo) void AudioOutputDevice::addFifo(AudioFifo* audioFifo)
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
m_audioFifos.push_back(audioFifo); m_audioFifos.push_back(audioFifo);
} }
void AudioOutput::removeFifo(AudioFifo* audioFifo) void AudioOutputDevice::removeFifo(AudioFifo* audioFifo)
{ {
QMutexLocker mutexLocker(&m_mutex); QMutexLocker mutexLocker(&m_mutex);
@ -172,37 +172,37 @@ void AudioOutput::removeFifo(AudioFifo* audioFifo)
} }
/* /*
bool AudioOutput::open(OpenMode mode) bool AudioOutputDevice::open(OpenMode mode)
{ {
Q_UNUSED(mode); Q_UNUSED(mode);
return false; return false;
}*/ }*/
void AudioOutput::setUdpDestination(const QString& address, uint16_t port) void AudioOutputDevice::setUdpDestination(const QString& address, uint16_t port)
{ {
if (m_audioNetSink) { if (m_audioNetSink) {
m_audioNetSink->setDestination(address, port); m_audioNetSink->setDestination(address, port);
} }
} }
void AudioOutput::setUdpCopyToUDP(bool copyToUDP) void AudioOutputDevice::setUdpCopyToUDP(bool copyToUDP)
{ {
m_copyAudioToUdp = copyToUDP; m_copyAudioToUdp = copyToUDP;
} }
void AudioOutput::setUdpUseRTP(bool useRTP) void AudioOutputDevice::setUdpUseRTP(bool useRTP)
{ {
if (m_audioNetSink) { if (m_audioNetSink) {
m_audioNetSink->selectType(useRTP ? AudioNetSink::SinkRTP : AudioNetSink::SinkUDP); m_audioNetSink->selectType(useRTP ? AudioNetSink::SinkRTP : AudioNetSink::SinkUDP);
} }
} }
void AudioOutput::setUdpChannelMode(UDPChannelMode udpChannelMode) void AudioOutputDevice::setUdpChannelMode(UDPChannelMode udpChannelMode)
{ {
m_udpChannelMode = udpChannelMode; m_udpChannelMode = udpChannelMode;
} }
void AudioOutput::setUdpChannelFormat(UDPChannelCodec udpChannelCodec, bool stereo, int sampleRate) void AudioOutputDevice::setUdpChannelFormat(UDPChannelCodec udpChannelCodec, bool stereo, int sampleRate)
{ {
m_udpChannelCodec = udpChannelCodec; m_udpChannelCodec = udpChannelCodec;
@ -211,16 +211,16 @@ void AudioOutput::setUdpChannelFormat(UDPChannelCodec udpChannelCodec, bool ster
} }
} }
void AudioOutput::setUdpDecimation(uint32_t decimation) void AudioOutputDevice::setUdpDecimation(uint32_t decimation)
{ {
if (m_audioNetSink) { if (m_audioNetSink) {
m_audioNetSink->setDecimation(decimation); m_audioNetSink->setDecimation(decimation);
} }
} }
qint64 AudioOutput::readData(char* data, qint64 maxLen) qint64 AudioOutputDevice::readData(char* data, qint64 maxLen)
{ {
//qDebug("AudioOutput::readData: %lld", maxLen); //qDebug("AudioOutputDevice::readData: %lld", maxLen);
// Study this mutex on OSX, for now deadlocks possible // Study this mutex on OSX, for now deadlocks possible
// Removed as it may indeed cause lockups and is in fact useless. // Removed as it may indeed cause lockups and is in fact useless.
@ -258,7 +258,7 @@ qint64 AudioOutput::readData(char* data, qint64 maxLen)
// if (samples != framesPerBuffer) // if (samples != framesPerBuffer)
// { // {
// qDebug("AudioOutput::readData: read %d samples vs %d requested", samples, framesPerBuffer); // qDebug("AudioOutputDevice::readData: read %d samples vs %d requested", samples, framesPerBuffer);
// } // }
for (unsigned int i = 0; i < samples; i++) for (unsigned int i = 0; i < samples; i++)
@ -335,7 +335,7 @@ qint64 AudioOutput::readData(char* data, qint64 maxLen)
return samplesPerBuffer * 4; return samplesPerBuffer * 4;
} }
qint64 AudioOutput::writeData(const char* data, qint64 len) qint64 AudioOutputDevice::writeData(const char* data, qint64 len)
{ {
Q_UNUSED(data); Q_UNUSED(data);
Q_UNUSED(len); Q_UNUSED(len);

View File

@ -16,8 +16,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // // along with this program. If not, see <http://www.gnu.org/licenses/>. //
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AUDIOOUTPUT_H #ifndef INCLUDE_AUDIOOUTPUTDEVICE_H
#define INCLUDE_AUDIOOUTPUT_H #define INCLUDE_AUDIOOUTPUTDEVICE_H
#include <QMutex> #include <QMutex>
#include <QIODevice> #include <QIODevice>
@ -32,7 +32,7 @@ class AudioFifo;
class AudioOutputPipe; class AudioOutputPipe;
class AudioNetSink; class AudioNetSink;
class SDRBASE_API AudioOutput : QIODevice { class SDRBASE_API AudioOutputDevice : QIODevice {
public: public:
enum UDPChannelMode enum UDPChannelMode
{ {
@ -52,8 +52,8 @@ public:
UDPCodecOpus //!< Opus compression UDPCodecOpus //!< Opus compression
}; };
AudioOutput(); AudioOutputDevice();
virtual ~AudioOutput(); virtual ~AudioOutputDevice();
bool start(int device, int rate); bool start(int device, int rate);
void stop(); void stop();
@ -94,4 +94,4 @@ private:
friend class AudioOutputPipe; friend class AudioOutputPipe;
}; };
#endif // INCLUDE_AUDIOOUTPUT_H #endif // INCLUDE_AUDIOOUTPUTDEVICE_H

View File

@ -24,7 +24,7 @@
#include <vector> #include <vector>
#include "audio/audiodevicemanager.h" #include "audio/audiodevicemanager.h"
#include "audio/audiooutput.h" #include "audio/audiooutputdevice.h"
#include "export.h" #include "export.h"
#include "ambe/ambeengine.h" #include "ambe/ambeengine.h"

View File

@ -550,10 +550,10 @@ int WebAPIAdapter::instanceAudioOutputPatch(
outputDeviceInfo.udpUseRTP = response.getUdpUsesRtp() == 0 ? 0 : 1; outputDeviceInfo.udpUseRTP = response.getUdpUsesRtp() == 0 ? 0 : 1;
} }
if (audioOutputKeys.contains("udpChannelMode")) { if (audioOutputKeys.contains("udpChannelMode")) {
outputDeviceInfo.udpChannelMode = static_cast<AudioOutput::UDPChannelMode>(response.getUdpChannelMode()); outputDeviceInfo.udpChannelMode = static_cast<AudioOutputDevice::UDPChannelMode>(response.getUdpChannelMode());
} }
if (audioOutputKeys.contains("udpChannelCodec")) { if (audioOutputKeys.contains("udpChannelCodec")) {
outputDeviceInfo.udpChannelCodec = static_cast<AudioOutput::UDPChannelCodec>(response.getUdpChannelCodec()); outputDeviceInfo.udpChannelCodec = static_cast<AudioOutputDevice::UDPChannelCodec>(response.getUdpChannelCodec());
} }
if (audioOutputKeys.contains("udpDecimationFactor")) { if (audioOutputKeys.contains("udpDecimationFactor")) {
outputDeviceInfo.udpDecimationFactor = response.getUdpDecimationFactor(); outputDeviceInfo.udpDecimationFactor = response.getUdpDecimationFactor();

View File

@ -247,14 +247,14 @@ void AudioDialogX::on_decimationFactor_currentIndexChanged(int index)
void AudioDialogX::on_outputUDPChannelCodec_currentIndexChanged(int index) void AudioDialogX::on_outputUDPChannelCodec_currentIndexChanged(int index)
{ {
m_outputDeviceInfo.udpChannelCodec = (AudioOutput::UDPChannelCodec) index; m_outputDeviceInfo.udpChannelCodec = (AudioOutputDevice::UDPChannelCodec) index;
updateOutputSDPString(); updateOutputSDPString();
check(); check();
} }
void AudioDialogX::on_outputUDPChannelMode_currentIndexChanged(int index) void AudioDialogX::on_outputUDPChannelMode_currentIndexChanged(int index)
{ {
m_outputDeviceInfo.udpChannelMode = (AudioOutput::UDPChannelMode) index; m_outputDeviceInfo.udpChannelMode = (AudioOutputDevice::UDPChannelMode) index;
updateOutputSDPString(); updateOutputSDPString();
check(); check();
} }
@ -290,38 +290,38 @@ void AudioDialogX::updateOutputDeviceInfo()
m_outputDeviceInfo.udpPort = m_outputUDPPort; m_outputDeviceInfo.udpPort = m_outputUDPPort;
m_outputDeviceInfo.copyToUDP = ui->outputUDPCopy->isChecked(); m_outputDeviceInfo.copyToUDP = ui->outputUDPCopy->isChecked();
m_outputDeviceInfo.udpUseRTP = ui->outputUDPUseRTP->isChecked(); m_outputDeviceInfo.udpUseRTP = ui->outputUDPUseRTP->isChecked();
m_outputDeviceInfo.udpChannelMode = (AudioOutput::UDPChannelMode) ui->outputUDPChannelMode->currentIndex(); m_outputDeviceInfo.udpChannelMode = (AudioOutputDevice::UDPChannelMode) ui->outputUDPChannelMode->currentIndex();
m_outputDeviceInfo.udpChannelCodec = (AudioOutput::UDPChannelCodec) ui->outputUDPChannelCodec->currentIndex(); m_outputDeviceInfo.udpChannelCodec = (AudioOutputDevice::UDPChannelCodec) ui->outputUDPChannelCodec->currentIndex();
m_outputDeviceInfo.udpDecimationFactor = ui->decimationFactor->currentIndex() + 1; m_outputDeviceInfo.udpDecimationFactor = ui->decimationFactor->currentIndex() + 1;
} }
void AudioDialogX::updateOutputSDPString() void AudioDialogX::updateOutputSDPString()
{ {
QString format; QString format;
int nChannels = m_outputDeviceInfo.udpChannelMode == AudioOutput::UDPChannelStereo ? 2 : 1; int nChannels = m_outputDeviceInfo.udpChannelMode == AudioOutputDevice::UDPChannelStereo ? 2 : 1;
uint32_t effectiveSampleRate = m_outputDeviceInfo.sampleRate / (m_outputDeviceInfo.udpDecimationFactor == 0 ? 1 : m_outputDeviceInfo.udpDecimationFactor); uint32_t effectiveSampleRate = m_outputDeviceInfo.sampleRate / (m_outputDeviceInfo.udpDecimationFactor == 0 ? 1 : m_outputDeviceInfo.udpDecimationFactor);
switch (m_outputDeviceInfo.udpChannelCodec) switch (m_outputDeviceInfo.udpChannelCodec)
{ {
case AudioOutput::UDPCodecALaw: case AudioOutputDevice::UDPCodecALaw:
format = "PCMA"; format = "PCMA";
break; break;
case AudioOutput::UDPCodecULaw: case AudioOutputDevice::UDPCodecULaw:
format = "PCMU"; format = "PCMU";
break; break;
case AudioOutput::UDPCodecG722: case AudioOutputDevice::UDPCodecG722:
format = "G722"; format = "G722";
effectiveSampleRate /= 2; // codec does a decimation by 2 effectiveSampleRate /= 2; // codec does a decimation by 2
break; break;
case AudioOutput::UDPCodecL8: case AudioOutputDevice::UDPCodecL8:
format = "L8"; format = "L8";
break; break;
case AudioOutput::UDPCodecOpus: case AudioOutputDevice::UDPCodecOpus:
format = "opus"; format = "opus";
nChannels = 2; // always 2 even for mono nChannels = 2; // always 2 even for mono
effectiveSampleRate = 48000; // always 48000 regardless of input rate effectiveSampleRate = 48000; // always 48000 regardless of input rate
break; break;
case AudioOutput::UDPCodecL16: case AudioOutputDevice::UDPCodecL16:
default: default:
format = "L16"; format = "L16";
break; break;
@ -332,28 +332,28 @@ void AudioDialogX::updateOutputSDPString()
void AudioDialogX::check() void AudioDialogX::check()
{ {
int nChannels = m_outputDeviceInfo.udpChannelMode == AudioOutput::UDPChannelStereo ? 2 : 1; int nChannels = m_outputDeviceInfo.udpChannelMode == AudioOutputDevice::UDPChannelStereo ? 2 : 1;
uint32_t decimationFactor = m_outputDeviceInfo.udpDecimationFactor == 0 ? 1 : m_outputDeviceInfo.udpDecimationFactor; uint32_t decimationFactor = m_outputDeviceInfo.udpDecimationFactor == 0 ? 1 : m_outputDeviceInfo.udpDecimationFactor;
if (m_outputDeviceInfo.udpChannelCodec == AudioOutput::UDPCodecALaw) if (m_outputDeviceInfo.udpChannelCodec == AudioOutputDevice::UDPCodecALaw)
{ {
if ((nChannels != 1) || (m_outputDeviceInfo.sampleRate/decimationFactor != 8000)) { if ((nChannels != 1) || (m_outputDeviceInfo.sampleRate/decimationFactor != 8000)) {
QMessageBox::information(this, tr("Message"), tr("PCMA must be 8000 Hz single channel")); QMessageBox::information(this, tr("Message"), tr("PCMA must be 8000 Hz single channel"));
} }
} }
else if (m_outputDeviceInfo.udpChannelCodec == AudioOutput::UDPCodecULaw) else if (m_outputDeviceInfo.udpChannelCodec == AudioOutputDevice::UDPCodecULaw)
{ {
if ((nChannels != 1) || (m_outputDeviceInfo.sampleRate/decimationFactor != 8000)) { if ((nChannels != 1) || (m_outputDeviceInfo.sampleRate/decimationFactor != 8000)) {
QMessageBox::information(this, tr("Message"), tr("PCMU must be 8000 Hz single channel")); QMessageBox::information(this, tr("Message"), tr("PCMU must be 8000 Hz single channel"));
} }
} }
else if (m_outputDeviceInfo.udpChannelCodec == AudioOutput::UDPCodecG722) else if (m_outputDeviceInfo.udpChannelCodec == AudioOutputDevice::UDPCodecG722)
{ {
if ((nChannels != 1) || (m_outputDeviceInfo.sampleRate/decimationFactor != 16000)) { if ((nChannels != 1) || (m_outputDeviceInfo.sampleRate/decimationFactor != 16000)) {
QMessageBox::information(this, tr("Message"), tr("G722 must be 16000 Hz single channel")); QMessageBox::information(this, tr("Message"), tr("G722 must be 16000 Hz single channel"));
} }
} }
else if (m_outputDeviceInfo.udpChannelCodec == AudioOutput::UDPCodecOpus) else if (m_outputDeviceInfo.udpChannelCodec == AudioOutputDevice::UDPCodecOpus)
{ {
int effectiveSampleRate = m_outputDeviceInfo.sampleRate/decimationFactor; int effectiveSampleRate = m_outputDeviceInfo.sampleRate/decimationFactor;
if ((effectiveSampleRate != 48000) && (effectiveSampleRate != 24000) && (effectiveSampleRate != 16000) && (effectiveSampleRate != 12000)) { if ((effectiveSampleRate != 48000) && (effectiveSampleRate != 24000) && (effectiveSampleRate != 16000) && (effectiveSampleRate != 12000)) {