WASAPI Sample Rate Change Not Reflected Correctly


#1

Hi Jules,

Related issues to the changes done from this post: when a device’s sample rate has changed from the WASAPI control panel, the WASAPIAudioIODevice’s “currentSampleRate” is updated, but the audio device manager’s configuration isn’t. The reason is a bit of missing code, and that WASAPIAudioIODeviceType::systemDeviceChanged() is called too early, or needs to be called again somehow after the device has re-opened to get the new sample rate.

Here’s an edit to update the ADM’s setup:

void AudioDeviceManager::audioDeviceListChanged()
{
    currentSetup.sampleRate = currentAudioDevice->getCurrentSampleRate();
    currentSetup.bufferSize = currentAudioDevice->getCurrentBufferSizeSamples(); //Here just in case

    sendChangeMessage();
}

#2

Ah, good idea, thanks!


#3

Because WASAPIAudioIODevice::handleAsyncUpdate() occurs after ChangeNotificationClient is notified, my current solution is:
[list]
[]having WASAPIAudioIODevice inherit ChangeBroadcaster[/]
[]having WASAPIAudioIODeviceType inherit ChangeListener[/]
[]sending a change message after the device is reopened in WASAPIAudioIODevice::handleAsyncUpdate()[/]
[]calling WASAPIAudioIODeviceType::systemDeviceChanged() in WASAPIAudioIODeviceType::changeListenerCallback()[/][/list]

I think this renders ChangeNotificationClient moot for sample rates changes though! (Sorry 'bout that)


#4

I’ve had a hasty go at this… Sanity-checking appreciated!


#5

Works for me - merci!