From d72718ca653ef37bd08abfe260df928ccc442312 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Sun, 23 Nov 2014 00:24:46 -0800 Subject: ao/wasapi: simplify the init retry --- audio/out/ao_wasapi_utils.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 7b37ef19b0..93866b067a 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -465,14 +465,15 @@ static HRESULT fix_format(struct ao *ao) /* integer multiple of device period close to 50ms */ bufferPeriod = bufferDuration = ceil( 50.0 * 10000.0 / devicePeriod ) * devicePeriod; - if (state->share_mode == AUDCLNT_SHAREMODE_SHARED) - bufferPeriod = 0; /* handle unsupported buffer size */ /* hopefully this shouldn't happen because of the above integer device period */ /* http://msdn.microsoft.com/en-us/library/windows/desktop/dd370875%28v=vs.85%29.aspx */ int retries=0; reinit: + if (state->share_mode == AUDCLNT_SHAREMODE_SHARED) + bufferPeriod = 0; + MP_DBG(state, "IAudioClient::Initialize\n"); hr = IAudioClient_Initialize(state->pAudioClient, state->share_mode, @@ -483,21 +484,18 @@ reinit: NULL); /* something about buffer sizes on Win7 */ if (hr == AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) { - MP_VERBOSE(state, "IAudioClient::Initialize negotiation failed with %s (0x%"PRIx32"), used %lld * 100ns\n", - wasapi_explain_err(hr), (uint32_t)hr, bufferDuration); - if (retries > 0) { - hr = E_FAIL; + if (retries > 0) EXIT_ON_ERROR(hr); - } else { + else retries ++; - } + + MP_VERBOSE(state, "IAudioClient::Initialize negotiation failed with %s (0x%"PRIx32"), used %lld * 100ns\n", + wasapi_explain_err(hr), (uint32_t)hr, bufferDuration); IAudioClient_GetBufferSize(state->pAudioClient, &state->bufferFrameCount); bufferPeriod = bufferDuration = (REFERENCE_TIME)((10000.0 * 1000 / state->format.Format.nSamplesPerSec * state->bufferFrameCount) + 0.5); - if (state->share_mode == AUDCLNT_SHAREMODE_SHARED) - bufferPeriod = 0; IAudioClient_Release(state->pAudioClient); state->pAudioClient = NULL; -- cgit v1.2.3