From 70f1a7e3ca35754832dec92dc6c20a42ef08da26 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 15 Feb 2012 22:40:01 -0800 Subject: Get the mmdevapi device period after initialization --- Alc/backends/mmdevapi.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) (limited to 'Alc/backends/mmdevapi.c') diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index c6a25f81..fae14ff9 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -204,7 +204,7 @@ static HRESULT DoReset(ALCdevice *device) MMDevApiData *data = device->ExtraData; WAVEFORMATEXTENSIBLE OutputType; WAVEFORMATEX *wfx = NULL; - REFERENCE_TIME min_per; + REFERENCE_TIME min_per, buf_time; UINT32 buffer_len, min_len; HRESULT hr; @@ -391,38 +391,30 @@ static HRESULT DoReset(ALCdevice *device) SetDefaultWFXChannelOrder(device); - hr = IAudioClient_GetDevicePeriod(data->client, &min_per, NULL); - if(SUCCEEDED(hr)) - { - min_len = (min_per*device->Frequency + 10000000-1) / 10000000; - if(min_len < device->UpdateSize) - min_len *= (device->UpdateSize + min_len/2)/min_len; - - device->NumUpdates = (device->NumUpdates*device->UpdateSize + min_len/2) / - min_len; - device->NumUpdates = maxu(device->NumUpdates, 2); - device->UpdateSize = min_len; - - hr = IAudioClient_Initialize(data->client, AUDCLNT_SHAREMODE_SHARED, - AUDCLNT_STREAMFLAGS_EVENTCALLBACK, - ((REFERENCE_TIME)device->UpdateSize* - device->NumUpdates*10000000 + - device->Frequency-1) / device->Frequency, - 0, &OutputType.Format, NULL); - } + 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); if(FAILED(hr)) { ERR("Failed to initialize audio client: 0x%08lx\n", hr); return hr; } - hr = IAudioClient_GetBufferSize(data->client, &buffer_len); + hr = IAudioClient_GetDevicePeriod(data->client, &min_per, NULL); + if(SUCCEEDED(hr)) + { + min_len = (min_per*device->Frequency + 10000000-1) / 10000000; + hr = IAudioClient_GetBufferSize(data->client, &buffer_len); + } if(FAILED(hr)) { ERR("Failed to get audio buffer info: 0x%08lx\n", hr); return hr; } + device->UpdateSize = min_len; device->NumUpdates = buffer_len / device->UpdateSize; if(device->NumUpdates <= 1) { -- cgit v1.2.3