diff --git a/sdrbase/audio/audiodevicemanager.cpp b/sdrbase/audio/audiodevicemanager.cpp index 44ebe6f56..d5fd3aa41 100644 --- a/sdrbase/audio/audiodevicemanager.cpp +++ b/sdrbase/audio/audiodevicemanager.cpp @@ -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; + } } } diff --git a/sdrbase/audio/audiodevicemanager.h b/sdrbase/audio/audiodevicemanager.h index a95e53d2a..ba11bf4aa 100644 --- a/sdrbase/audio/audiodevicemanager.h +++ b/sdrbase/audio/audiodevicemanager.h @@ -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;