summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-02-15 22:40:01 -0800
committerChris Robinson <[email protected]>2012-02-15 22:40:01 -0800
commit70f1a7e3ca35754832dec92dc6c20a42ef08da26 (patch)
tree638dad298d0fb21486c7c58398a3e3bafecdd3fa /Alc
parent60785eab8e7c893b652ca8ebfa031a70588c6683 (diff)
Get the mmdevapi device period after initialization
Diffstat (limited to 'Alc')
-rw-r--r--Alc/backends/mmdevapi.c34
1 files changed, 13 insertions, 21 deletions
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)
{