From 1841cac9f83c8f3a0ba589587e3b111ccdae09a1 Mon Sep 17 00:00:00 2001 From: Kevin Mitchell Date: Fri, 26 Feb 2016 10:31:54 -0800 Subject: ao_wasapi: move resetting the thread state into main loop This was previously duplicated between the reset/resume functions, and not properly handled in the "impossible" invalid thread state case. --- audio/out/ao_wasapi.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'audio/out') diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index 75090791b5..7d74cf2e2d 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -155,17 +155,11 @@ static void thread_resume(struct ao *ao) MP_DBG(state, "Thread Resume\n"); thread_feed(ao); - // start feeding next wakeup if something else hasn't been requested - int expected = WASAPI_THREAD_RESUME; - atomic_compare_exchange_strong(&state->thread_state, &expected, - WASAPI_THREAD_FEED); hr = IAudioClient_Start(state->pAudioClient); if (FAILED(hr)) { MP_ERR(state, "IAudioClient_Start returned %s\n", mp_HRESULT_to_str(hr)); } - - return; } static void thread_reset(struct ao *ao) @@ -182,11 +176,6 @@ static void thread_reset(struct ao *ao) MP_ERR(state, "IAudioClient_Reset returned: %s\n", mp_HRESULT_to_str(hr)); atomic_store(&state->sample_count, 0); - // start feeding next wakeup if something else hasn't been requested - int expected = WASAPI_THREAD_RESET; - atomic_compare_exchange_strong(&state->thread_state, &expected, - WASAPI_THREAD_FEED); - return; } static void thread_wakeup(void *ptr) @@ -242,6 +231,9 @@ static DWORD __stdcall AudioThread(void *lpParameter) default: MP_ERR(ao, "Unhandled thread state: %d\n", thread_state); } + // the default is to feed unless something else is requested + atomic_compare_exchange_strong(&state->thread_state, &thread_state, + WASAPI_THREAD_FEED); } exit_label: wasapi_thread_uninit(ao); -- cgit v1.2.3