mirror of https://github.com/mpv-player/mpv
Revert "ao_wasapi: address premature buffer fills in exclusive mode"
This reverts commit 6863eefc3d
.
This commit is contained in:
parent
76367dae35
commit
7f0961479a
|
@ -193,17 +193,19 @@ static void thread_resume(struct ao *ao)
|
|||
thread_unpause(ao);
|
||||
}
|
||||
|
||||
static void set_state_and_wakeup_thread(struct ao *ao,
|
||||
enum wasapi_thread_state thread_state)
|
||||
static void thread_wakeup(void *ptr)
|
||||
{
|
||||
struct ao *ao = ptr;
|
||||
struct wasapi_state *state = ao->priv;
|
||||
atomic_store(&state->thread_state, thread_state);
|
||||
SetEvent(state->hWake);
|
||||
}
|
||||
|
||||
static void thread_process_dispatch(void *ptr)
|
||||
static void set_thread_state(struct ao *ao,
|
||||
enum wasapi_thread_state thread_state)
|
||||
{
|
||||
set_state_and_wakeup_thread(ptr, WASAPI_THREAD_DISPATCH);
|
||||
struct wasapi_state *state = ao->priv;
|
||||
atomic_store(&state->thread_state, thread_state);
|
||||
thread_wakeup(ao);
|
||||
}
|
||||
|
||||
static DWORD __stdcall AudioThread(void *lpParameter)
|
||||
|
@ -223,6 +225,8 @@ static DWORD __stdcall AudioThread(void *lpParameter)
|
|||
if (WaitForSingleObject(state->hWake, INFINITE) != WAIT_OBJECT_0)
|
||||
MP_ERR(ao, "Unexpected return value from WaitForSingleObject\n");
|
||||
|
||||
mp_dispatch_queue_process(state->dispatch, 0);
|
||||
|
||||
int thread_state = atomic_load(&state->thread_state);
|
||||
switch (thread_state) {
|
||||
case WASAPI_THREAD_FEED:
|
||||
|
@ -230,9 +234,6 @@ static DWORD __stdcall AudioThread(void *lpParameter)
|
|||
if (thread_feed(ao) && thread_feed(ao))
|
||||
MP_ERR(ao, "Unable to fill buffer fast enough\n");
|
||||
break;
|
||||
case WASAPI_THREAD_DISPATCH:
|
||||
mp_dispatch_queue_process(state->dispatch, 0);
|
||||
break;
|
||||
case WASAPI_THREAD_RESET:
|
||||
thread_reset(ao);
|
||||
break;
|
||||
|
@ -268,7 +269,7 @@ static void uninit(struct ao *ao)
|
|||
MP_DBG(ao, "Uninit wasapi\n");
|
||||
struct wasapi_state *state = ao->priv;
|
||||
if (state->hWake)
|
||||
set_state_and_wakeup_thread(ao, WASAPI_THREAD_SHUTDOWN);
|
||||
set_thread_state(ao, WASAPI_THREAD_SHUTDOWN);
|
||||
|
||||
if (state->hAudioThread &&
|
||||
WaitForSingleObject(state->hAudioThread, INFINITE) != WAIT_OBJECT_0)
|
||||
|
@ -319,7 +320,7 @@ static int init(struct ao *ao)
|
|||
}
|
||||
|
||||
state->dispatch = mp_dispatch_create(state);
|
||||
mp_dispatch_set_wakeup_fn(state->dispatch, thread_process_dispatch, ao);
|
||||
mp_dispatch_set_wakeup_fn(state->dispatch, thread_wakeup, ao);
|
||||
|
||||
state->init_ok = false;
|
||||
state->hAudioThread = CreateThread(NULL, 0, &AudioThread, ao, 0, NULL);
|
||||
|
@ -474,12 +475,12 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
|
|||
|
||||
static void audio_reset(struct ao *ao)
|
||||
{
|
||||
set_state_and_wakeup_thread(ao, WASAPI_THREAD_RESET);
|
||||
set_thread_state(ao, WASAPI_THREAD_RESET);
|
||||
}
|
||||
|
||||
static void audio_resume(struct ao *ao)
|
||||
{
|
||||
set_state_and_wakeup_thread(ao, WASAPI_THREAD_RESUME);
|
||||
set_thread_state(ao, WASAPI_THREAD_RESUME);
|
||||
}
|
||||
|
||||
static bool audio_set_pause(struct ao *ao, bool paused)
|
||||
|
|
|
@ -48,7 +48,6 @@ void wasapi_change_uninit(struct ao* ao);
|
|||
|
||||
enum wasapi_thread_state {
|
||||
WASAPI_THREAD_FEED = 0,
|
||||
WASAPI_THREAD_DISPATCH,
|
||||
WASAPI_THREAD_RESUME,
|
||||
WASAPI_THREAD_RESET,
|
||||
WASAPI_THREAD_SHUTDOWN,
|
||||
|
|
Loading…
Reference in New Issue