From 7d467ecc660604414f3983d7567d15fb9af786be Mon Sep 17 00:00:00 2001 From: GZharun Date: Sat, 14 Feb 2015 11:56:07 +0200 Subject: [PATCH] [Summary] Fixed issue when device supports only 0 sample rate [Details] Removed commented out code --- .../WCMRCoreAudioDeviceManager.cpp | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp index 203c291b08..b37ef232c8 100644 --- a/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp +++ b/libs/backends/wavesaudio/wavesapi/devicemanager/WCMRCoreAudioDeviceManager.cpp @@ -941,21 +941,6 @@ WTErr WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate (int newRate) OSStatus err = kAudioHardwareNoError; UInt32 propSize = 0; - // Check current sample rate - /* - propSize = sizeof (Float64); - Float64 currentSamplingRate = 0.0; - err = AudioDeviceGetProperty(m_DeviceID, 0, 0, kAudioDevicePropertyNominalSampleRate, &propSize, ¤tSamplingRate); - if (err == kAudioHardwareNoError) - { - if (currentSamplingRate == newRate) - { - // nothing to do - return (retVal); - } - }*/ - - // 1. Set new sampling rate Float64 newNominalRate = newRate; propSize = sizeof (Float64); @@ -1016,15 +1001,28 @@ WTErr WCMRCoreAudioDevice::SetAndCheckCurrentSamplingRate (int newRate) // If sample rate did not change after time out else { - // Update member with last read value - m_CurrentSamplingRate = static_cast(actualSamplingRate); + // Check if current device sample rate is supported + bool found = false; + for(int i = 0; gAllSampleRates[i] > 0; i++) + { + if (gAllSampleRates[i] - actualSamplingRate < 0.01) { + found = true; + } + } - char debugMsg[128]; - snprintf (debugMsg, sizeof(debugMsg), "Unable to change SR, even after waiting for %d milliseconds", actualWait * PROPERTY_CHANGE_SLEEP_TIME_MILLISECONDS); - m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)debugMsg); - - float sample_rate_update = actualSamplingRate; - m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::SamplingRateChanged, (void *)&sample_rate_update); + if (found) { + // Update member with last read value + m_CurrentSamplingRate = static_cast(actualSamplingRate); + + char debugMsg[128]; + snprintf (debugMsg, sizeof(debugMsg), "Unable to change SR, even after waiting for %d milliseconds", actualWait * PROPERTY_CHANGE_SLEEP_TIME_MILLISECONDS); + m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::DeviceDebugInfo, (void *)debugMsg); + + float sample_rate_update = actualSamplingRate; + m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::SamplingRateChanged, (void *)&sample_rate_update); + } else { + retVal = eGenericErr; + } } }