diff options
author | Chris Robinson <[email protected]> | 2011-05-19 15:55:27 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-05-19 15:55:27 -0700 |
commit | 555ccce4eec6afbe3a14fe5a9de6d04e1e74fdcd (patch) | |
tree | 843c321857af176a45c40b6943956f30f9f15962 /Alc/mmdevapi.c | |
parent | b838d123f899359e791450271d09324668f2d25c (diff) |
Update the device update fields after initializing the MMDevApi device
Diffstat (limited to 'Alc/mmdevapi.c')
-rw-r--r-- | Alc/mmdevapi.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Alc/mmdevapi.c b/Alc/mmdevapi.c index 9feef4ad..39628c95 100644 --- a/Alc/mmdevapi.c +++ b/Alc/mmdevapi.c @@ -245,6 +245,8 @@ static ALCboolean MMDevApiResetPlayback(ALCdevice *device) MMDevApiData *data = device->ExtraData; WAVEFORMATEXTENSIBLE OutputType; WAVEFORMATEX *wfx = NULL; + REFERENCE_TIME def_per; + UINT32 buffer_len; HRESULT hr; hr = IAudioClient_GetMixFormat(data->client, &wfx); @@ -458,10 +460,28 @@ static ALCboolean MMDevApiResetPlayback(ALCdevice *device) return ALC_FALSE; } + hr = IAudioClient_GetDevicePeriod(data->client, &def_per, NULL); + if(SUCCEEDED(hr)) + hr = IAudioClient_GetBufferSize(data->client, &buffer_len); + if(FAILED(hr)) + { + AL_PRINT("Failed to get audio buffer info: 0x%08lx\n", hr); + return ALC_FALSE; + } + + device->NumUpdates = (ALuint)((REFERENCE_TIME)buffer_len * 10000000 / + device->Frequency / def_per); + if(device->NumUpdates <= 1) + { + device->NumUpdates = 1; + AL_PRINT("Audio client returned default_period > buffer_len/2; expect break up\n"); + } + device->UpdateSize = buffer_len / device->NumUpdates; + hr = IAudioClient_Start(data->client); if(FAILED(hr)) { - AL_PRINT("Failed to start audio client\n"); + AL_PRINT("Failed to start audio client: 0x%08lx\n", hr); return ALC_FALSE; } |