summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2014-11-23 00:24:46 -0800
committerKevin Mitchell <kevmitch@gmail.com>2014-11-28 08:02:16 -0800
commitecb491fd958689632191d57acf3f9cfba9014cc7 (patch)
tree99c5806399ea2c400d2035e1074dc4e3a9bc5a0e
parente4aaaf69dfc4d6537cb23b2904b238601f6da2fd (diff)
downloadmpv-ecb491fd958689632191d57acf3f9cfba9014cc7.tar.bz2
mpv-ecb491fd958689632191d57acf3f9cfba9014cc7.tar.xz
ao/wasapi: simplify the init retry
-rwxr-xr-xaudio/out/ao_wasapi_utils.c18
1 files 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;