1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Multiple audio support: new combo and enum for udp channel mode

This commit is contained in:
f4exb 2018-03-26 21:10:09 +02:00
parent a049e3aaa6
commit ddff6c91b1
6 changed files with 62 additions and 34 deletions

View File

@ -42,13 +42,15 @@ QDataStream& operator>>(QDataStream& ds, AudioDeviceManager::InputDeviceInfo& in
QDataStream& operator<<(QDataStream& ds, const AudioDeviceManager::OutputDeviceInfo& info)
{
ds << info.sampleRate << info.udpAddress << info.udpPort << info.copyToUDP << info.udpStereo << info.udpUseRTP;
ds << info.sampleRate << info.udpAddress << info.udpPort << info.copyToUDP << info.udpUseRTP << (int) info.udpChannelMode;
return ds;
}
QDataStream& operator>>(QDataStream& ds, AudioDeviceManager::OutputDeviceInfo& info)
{
ds >> info.sampleRate >> info.udpAddress >> info.udpPort >> info.copyToUDP >> info.udpStereo >> info.udpUseRTP;
int intChannelMode;
ds >> info.sampleRate >> info.udpAddress >> info.udpPort >> info.copyToUDP >> info.udpUseRTP >> intChannelMode;
info.udpChannelMode = (AudioOutput::UDPChannelMode) intChannelMode;
return ds;
}
@ -331,8 +333,8 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
QString udpAddress;
quint16 udpPort;
bool copyAudioToUDP;
bool udpStereo;
bool udpUseRTP;
AudioOutput::UDPChannelMode udpChannelMode;
QString deviceName;
if (getOutputDeviceName(outputDeviceIndex, deviceName))
@ -343,8 +345,8 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
udpAddress = m_defaultUDPAddress;
udpPort = m_defaultUDPPort;
copyAudioToUDP = false;
udpStereo = false;
udpUseRTP = false;
udpChannelMode = AudioOutput::UDPChannelLeft;
}
else
{
@ -352,8 +354,8 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
udpAddress = m_audioOutputInfos[deviceName].udpAddress;
udpPort = m_audioOutputInfos[deviceName].udpPort;
copyAudioToUDP = m_audioOutputInfos[deviceName].copyToUDP;
udpStereo = m_audioOutputInfos[deviceName].udpStereo;
udpUseRTP = m_audioOutputInfos[deviceName].udpUseRTP;
udpChannelMode = m_audioOutputInfos[deviceName].udpChannelMode;
}
m_audioOutputs[outputDeviceIndex]->start(outputDeviceIndex, sampleRate);
@ -361,8 +363,8 @@ void AudioDeviceManager::startAudioOutput(int outputDeviceIndex)
m_audioOutputInfos[deviceName].udpAddress = udpAddress;
m_audioOutputInfos[deviceName].udpPort = udpPort;
m_audioOutputInfos[deviceName].copyToUDP = copyAudioToUDP;
m_audioOutputInfos[deviceName].udpStereo = udpStereo;
m_audioOutputInfos[deviceName].udpUseRTP = udpUseRTP;
m_audioOutputInfos[deviceName].udpChannelMode = udpChannelMode;
}
else
{
@ -570,7 +572,6 @@ void AudioDeviceManager::setOutputDeviceInfo(int outputDeviceIndex, const Output
audioOutput->setUdpCopyToUDP(deviceInfo.copyToUDP);
audioOutput->setUdpDestination(deviceInfo.udpAddress, deviceInfo.udpPort);
audioOutput->setUdpStereo(deviceInfo.udpStereo);
audioOutput->setUdpUseRTP(deviceInfo.udpUseRTP);
}
@ -723,7 +724,7 @@ void AudioDeviceManager::debugAudioOutputInfos() const
<< " udpAddress: " << it.value().udpAddress
<< " udpPort: " << it.value().udpPort
<< " copyToUDP: " << it.value().copyToUDP
<< " udpStereo: " << it.value().udpStereo
<< " udpUseRTP: " << it.value().udpUseRTP;
<< " udpUseRTP: " << it.value().udpUseRTP
<< " udpChannelMode: " << (int) it.value().udpChannelMode;
}
}

View File

@ -58,23 +58,23 @@ public:
udpAddress(m_defaultUDPAddress),
udpPort(m_defaultUDPPort),
copyToUDP(false),
udpStereo(false),
udpUseRTP(false)
udpUseRTP(false),
udpChannelMode(AudioOutput::UDPChannelLeft)
{}
void resetToDefaults() {
sampleRate = m_defaultAudioSampleRate;
udpAddress = m_defaultUDPAddress;
udpPort = m_defaultUDPPort;
copyToUDP = false;
udpStereo = false;
udpUseRTP = false;
udpChannelMode = AudioOutput::UDPChannelLeft;
}
unsigned int sampleRate;
QString udpAddress;
quint16 udpPort;
bool copyToUDP;
bool udpStereo;
bool udpUseRTP;
AudioOutput::UDPChannelMode udpChannelMode;
friend QDataStream& operator<<(QDataStream& ds, const OutputDeviceInfo& info);
friend QDataStream& operator>>(QDataStream& ds, OutputDeviceInfo& info);
};

View File

@ -28,7 +28,7 @@ AudioOutput::AudioOutput() :
m_audioOutput(0),
m_audioNetSink(0),
m_copyAudioToUdp(false),
m_udpStereo(false),
m_udpChannelMode(UDPChannelLeft),
m_audioUsageCount(0),
m_onExit(false),
m_audioFifos()
@ -188,15 +188,6 @@ void AudioOutput::setUdpCopyToUDP(bool copyToUDP)
m_copyAudioToUdp = copyToUDP;
}
void AudioOutput::setUdpStereo(bool stereo)
{
if (m_audioNetSink) {
m_audioNetSink->setStereo(stereo);
}
m_udpStereo = stereo;
}
void AudioOutput::setUdpUseRTP(bool useRTP)
{
if (m_audioNetSink) {
@ -204,6 +195,14 @@ void AudioOutput::setUdpUseRTP(bool useRTP)
}
}
void AudioOutput::setUdpChannelMode(UDPChannelMode udpChannelMode)
{
if (m_audioNetSink) {
m_audioNetSink->setStereo(udpChannelMode == UDPChannelStereo);
}
m_udpChannelMode = udpChannelMode;
}
qint64 AudioOutput::readData(char* data, qint64 maxLen)
{

View File

@ -33,6 +33,14 @@ class AudioNetSink;
class SDRBASE_API AudioOutput : QIODevice {
public:
enum UDPChannelMode
{
UDPChannelLeft,
UDPChannelRight,
UDPChannelMixed,
UDPChannelStereo
};
AudioOutput();
virtual ~AudioOutput();
@ -48,15 +56,15 @@ public:
void setUdpDestination(const QString& address, uint16_t port);
void setUdpCopyToUDP(bool copyToUDP);
void setUdpStereo(bool stereo);
void setUdpUseRTP(bool useRTP);
void setUdpChannelMode(UDPChannelMode udpChannelMode);
private:
QMutex m_mutex;
QAudioOutput* m_audioOutput;
AudioNetSink* m_audioNetSink;
bool m_copyAudioToUdp;
bool m_udpStereo;
UDPChannelMode m_udpChannelMode;
uint m_audioUsageCount;
bool m_onExit;

View File

@ -198,8 +198,8 @@ void AudioDialogX::updateOutputDisplay()
ui->outputUDPAddress->setText(m_outputDeviceInfo.udpAddress);
ui->outputUDPPort->setText(tr("%1").arg(m_outputDeviceInfo.udpPort));
ui->outputUDPCopy->setChecked(m_outputDeviceInfo.copyToUDP);
ui->outputUDPStereo->setChecked(m_outputDeviceInfo.udpStereo);
ui->outputUDPUseRTP->setChecked(m_outputDeviceInfo.udpUseRTP);
ui->outputUDPChannelMode->setCurrentIndex((int) m_outputDeviceInfo.udpChannelMode);
}
void AudioDialogX::updateOutputDeviceInfo()
@ -208,7 +208,7 @@ void AudioDialogX::updateOutputDeviceInfo()
m_outputDeviceInfo.udpAddress = ui->outputUDPAddress->text();
m_outputDeviceInfo.udpPort = m_outputUDPPort;
m_outputDeviceInfo.copyToUDP = ui->outputUDPCopy->isChecked();
m_outputDeviceInfo.udpStereo = ui->outputUDPStereo->isChecked();
m_outputDeviceInfo.udpUseRTP = ui->outputUDPUseRTP->isChecked();
m_outputDeviceInfo.udpChannelMode = (AudioOutput::UDPChannelMode) ui->outputUDPChannelMode->currentIndex();
}

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>472</width>
<height>349</height>
</rect>
</property>
@ -204,13 +204,33 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="outputUDPStereo">
<property name="toolTip">
<string>Copy to UDP as stereo (no L+R mix)</string>
</property>
<property name="text">
<string>S</string>
<widget class="QComboBox" name="outputUDPChannelMode">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>Left</string>
</property>
</item>
<item>
<property name="text">
<string>Right</string>
</property>
</item>
<item>
<property name="text">
<string>Mixed</string>
</property>
</item>
<item>
<property name="text">
<string>Stereo</string>
</property>
</item>
</widget>
</item>
<item>