summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2016-02-26 10:31:54 -0800
committerKevin Mitchell <kevmitch@gmail.com>2016-02-26 15:43:51 -0800
commit1841cac9f83c8f3a0ba589587e3b111ccdae09a1 (patch)
tree79a165a571e7c6d0815e7484782949d7aa8c2d9e
parent82f102cfe3e700e6b09604b2f659f7a123a8ea87 (diff)
downloadmpv-1841cac9f83c8f3a0ba589587e3b111ccdae09a1.tar.bz2
mpv-1841cac9f83c8f3a0ba589587e3b111ccdae09a1.tar.xz
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.
-rw-r--r--audio/out/ao_wasapi.c14
1 files changed, 3 insertions, 11 deletions
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);