From 5d17cef55fe291ceed83402c1d2af4da93e0f6d7 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 15 Feb 2012 22:54:17 -0800 Subject: Calculate the buffer time before modifying the frequency --- Alc/backends/mmdevapi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Alc') diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index fae14ff9..0c2e00b0 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -223,6 +223,9 @@ static HRESULT DoReset(ALCdevice *device) CoTaskMemFree(wfx); wfx = NULL; + buf_time = ((REFERENCE_TIME)device->UpdateSize*device->NumUpdates*10000000 + + device->Frequency-1) / device->Frequency; + if(!(device->Flags&DEVICE_FREQUENCY_REQUEST)) device->Frequency = OutputType.Format.nSamplesPerSec; if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) @@ -391,8 +394,6 @@ static HRESULT DoReset(ALCdevice *device) SetDefaultWFXChannelOrder(device); - buf_time = ((REFERENCE_TIME)device->UpdateSize*device->NumUpdates*10000000 + - device->Frequency-1) / device->Frequency; hr = IAudioClient_Initialize(data->client, AUDCLNT_SHAREMODE_SHARED, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, buf_time, 0, &OutputType.Format, NULL); -- cgit v1.2.3