From 3a3a0aced2c95563c9fe0867cad9d67378de286a Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 28 Jun 2017 18:32:01 +0200 Subject: ao_wasapi: remove subtly duplicated code Seems like this can be slightly simplified. --- audio/out/ao_wasapi_utils.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 9751b82fac..1adb766644 100644 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -596,20 +596,17 @@ static HRESULT fix_format(struct ao *ao, bool align_hack) { struct wasapi_state *state = ao->priv; - REFERENCE_TIME devicePeriod, bufferDuration, bufferPeriod; MP_DBG(state, "IAudioClient::GetDevicePeriod\n"); + REFERENCE_TIME devicePeriod; HRESULT hr = IAudioClient_GetDevicePeriod(state->pAudioClient,&devicePeriod, NULL); MP_VERBOSE(state, "Device period: %.2g ms\n", (double) devicePeriod / 10000.0 ); + REFERENCE_TIME bufferDuration = devicePeriod; if (state->share_mode == AUDCLNT_SHAREMODE_SHARED) { // for shared mode, use integer multiple of device period close to 50ms bufferDuration = devicePeriod * ceil(50.0 * 10000.0 / devicePeriod); - bufferPeriod = 0; - } else { - // in exclusive mode, these should all be the same - bufferPeriod = bufferDuration = devicePeriod; } // handle unsupported buffer size if AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED was @@ -620,10 +617,12 @@ static HRESULT fix_format(struct ao *ao, bool align_hack) bufferDuration = (REFERENCE_TIME) (0.5 + (10000.0 * 1000 / state->format.Format.nSamplesPerSec * state->bufferFrameCount)); - if (state->share_mode == AUDCLNT_SHAREMODE_EXCLUSIVE) - bufferPeriod = bufferDuration; } + // in exclusive mode, these should all be the same + REFERENCE_TIME bufferPeriod = + state->share_mode == AUDCLNT_SHAREMODE_EXCLUSIVE ? bufferDuration : 0; + ao->format = af_fmt_from_planar(ao->format); MP_DBG(state, "IAudioClient::Initialize\n"); -- cgit v1.2.3