1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

AudioDeviceManager: make sure a negative or null sample rate is never returned

This commit is contained in:
f4exb 2020-05-15 19:37:50 +02:00
parent da06bc30cc
commit 0260c3aefc
2 changed files with 21 additions and 5 deletions

View File

@ -503,7 +503,15 @@ int AudioDeviceManager::getInputSampleRate(int inputDeviceIndex)
}
else
{
return deviceInfo.sampleRate;
if (deviceInfo.sampleRate > 0)
{
return deviceInfo.sampleRate;
}
else
{
qDebug("AudioDeviceManager::getInputSampleRate: device %s has invalid sample rate", qPrintable(deviceName));
return m_defaultAudioSampleRate;
}
}
}
@ -526,7 +534,15 @@ int AudioDeviceManager::getOutputSampleRate(int outputDeviceIndex)
}
else
{
return deviceInfo.sampleRate;
if (deviceInfo.sampleRate > 0)
{
return deviceInfo.sampleRate;
}
else
{
qDebug("AudioDeviceManager::getOutputSampleRate: device %s has invalid sample rate", qPrintable(deviceName));
return m_defaultAudioSampleRate;
}
}
}

View File

@ -45,7 +45,7 @@ public:
sampleRate = m_defaultAudioSampleRate;
volume = m_defaultAudioInputVolume;
}
unsigned int sampleRate;
int sampleRate;
float volume;
friend QDataStream& operator<<(QDataStream& ds, const InputDeviceInfo& info);
friend QDataStream& operator>>(QDataStream& ds, InputDeviceInfo& info);
@ -74,7 +74,7 @@ public:
udpChannelCodec = AudioOutput::UDPCodecL16;
udpDecimationFactor = 1;
}
unsigned int sampleRate;
int sampleRate;
QString udpAddress;
quint16 udpPort;
bool copyToUDP;
@ -114,7 +114,7 @@ public:
void inputInfosCleanup(); //!< Remove input info from map for input devices not present
void outputInfosCleanup(); //!< Remove output info from map for output devices not present
static const unsigned int m_defaultAudioSampleRate = 48000;
static const int m_defaultAudioSampleRate = 48000;
static const float m_defaultAudioInputVolume;
static const QString m_defaultUDPAddress;
static const quint16 m_defaultUDPPort = 9998;