summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-06-28 18:32:01 +0200
committerwm4 <wm4@nowhere>2017-06-28 18:43:19 +0200
commit3a3a0aced2c95563c9fe0867cad9d67378de286a (patch)
tree5c024af4f60c50217a7a558f3742fe9d03f8d637
parent3b7e292844f52783cdefe068bb7bc5cd35a8dcdb (diff)
downloadmpv-3a3a0aced2c95563c9fe0867cad9d67378de286a.tar.bz2
mpv-3a3a0aced2c95563c9fe0867cad9d67378de286a.tar.xz
ao_wasapi: remove subtly duplicated code
Seems like this can be slightly simplified.
-rw-r--r--audio/out/ao_wasapi_utils.c13
1 files 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");