mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
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.
This commit is contained in:
parent
82f102cfe3
commit
1841cac9f8
@ -155,17 +155,11 @@ static void thread_resume(struct ao *ao)
|
|||||||
MP_DBG(state, "Thread Resume\n");
|
MP_DBG(state, "Thread Resume\n");
|
||||||
thread_feed(ao);
|
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);
|
hr = IAudioClient_Start(state->pAudioClient);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
MP_ERR(state, "IAudioClient_Start returned %s\n",
|
MP_ERR(state, "IAudioClient_Start returned %s\n",
|
||||||
mp_HRESULT_to_str(hr));
|
mp_HRESULT_to_str(hr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void thread_reset(struct ao *ao)
|
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));
|
MP_ERR(state, "IAudioClient_Reset returned: %s\n", mp_HRESULT_to_str(hr));
|
||||||
|
|
||||||
atomic_store(&state->sample_count, 0);
|
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)
|
static void thread_wakeup(void *ptr)
|
||||||
@ -242,6 +231,9 @@ static DWORD __stdcall AudioThread(void *lpParameter)
|
|||||||
default:
|
default:
|
||||||
MP_ERR(ao, "Unhandled thread state: %d\n", thread_state);
|
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:
|
exit_label:
|
||||||
wasapi_thread_uninit(ao);
|
wasapi_thread_uninit(ao);
|
||||||
|
Loading…
Reference in New Issue
Block a user