diff options
author | Chris Robinson <[email protected]> | 2012-03-13 01:39:57 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-03-13 01:39:57 -0700 |
commit | 5c59e6e7040dc74760b3c66a5c771d6227547051 (patch) | |
tree | 25c7d3e7240d234a9da9b7163b78b04775c26a81 | |
parent | ef2f2372763deca289f6029bcf5da54441bb8499 (diff) |
Try to ensure the full mmdevapi buffer is used
-rw-r--r-- | Alc/backends/mmdevapi.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index 6d54a4ab..6861430e 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -216,8 +216,8 @@ static ALuint MMDevApiProc(ALvoid *ptr) { ALCdevice *device = ptr; MMDevApiData *data = device->ExtraData; - UINT32 update_size, num_updates; - UINT32 written, len; + UINT32 buffer_len, written; + ALuint update_size, len; BYTE *buffer; HRESULT hr; @@ -229,10 +229,18 @@ static ALuint MMDevApiProc(ALvoid *ptr) return 0; } + hr = IAudioClient_GetBufferSize(data->client, &buffer_len); + if(FAILED(hr)) + { + ERR("Failed to get audio buffer size: 0x%08lx\n", hr); + aluHandleDisconnect(device); + CoUninitialize(); + return 0; + } + SetRTPriority(); update_size = device->UpdateSize; - num_updates = device->NumUpdates; while(!data->killNow) { hr = IAudioClient_GetCurrentPadding(data->client, &written); @@ -243,7 +251,7 @@ static ALuint MMDevApiProc(ALvoid *ptr) break; } - len = update_size*num_updates - written; + len = buffer_len - written; if(len < update_size) { DWORD res; |