1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-16 20:27:23 +00:00

ao/wasapi: more missed cleanup on failure

This commit is contained in:
Kevin Mitchell 2014-11-28 07:31:05 -08:00
parent 7b5baf3b53
commit 8908b80b77

View File

@ -180,7 +180,8 @@ static void uninit(struct ao *ao)
MP_DBG(ao, "Uninit wasapi\n");
struct wasapi_state *state = (struct wasapi_state *)ao->priv;
wasapi_release_proxies(state);
SetEvent(state->hUninit);
if (state->hUninit)
SetEvent(state->hUninit);
/* wait up to 10 seconds */
if (WaitForSingleObject(state->threadLoop, 10000) == WAIT_TIMEOUT){
MP_ERR(ao, "Audio loop thread refuses to abort\n");
@ -229,7 +230,8 @@ static int init(struct ao *ao)
if (!state->init_done || !state->hFeed || !state->hUninit ||
!state->hForceFeed || !state->hFeedDone)
{
closehandles(ao);
MP_ERR(ao, "Error initing events\n");
uninit(ao);
/* failed to init events */
return -1;
}
@ -239,6 +241,7 @@ static int init(struct ao *ao)
if (!state->threadLoop) {
/* failed to init thread */
MP_ERR(ao, "Failed to create thread\n");
uninit(ao);
return -1;
}
@ -334,7 +337,6 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg)
}
}
static void audio_reset(struct ao *ao)
{
struct wasapi_state *state = (struct wasapi_state *)ao->priv;