diff options
author | wm4 <wm4@nowhere> | 2014-09-27 04:54:17 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-27 04:54:17 +0200 |
commit | 650af294716e34a3992770aab23aafebb358bac8 (patch) | |
tree | 1956f28c510fb6fdc5c999dec7c3f69de396c8f1 | |
parent | e79de41b97b497c355f113362da66988d6719260 (diff) | |
download | mpv-650af294716e34a3992770aab23aafebb358bac8.tar.bz2 mpv-650af294716e34a3992770aab23aafebb358bac8.tar.xz |
audio/out/push: clean up properly on init error
Close the wakeup pipes, free the mutex and condition var.
-rw-r--r-- | audio/out/push.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/audio/out/push.c b/audio/out/push.c index 2a84028e13..75b4db0568 100644 --- a/audio/out/push.c +++ b/audio/out/push.c @@ -364,17 +364,10 @@ static void *playthread(void *arg) return NULL; } -static void uninit(struct ao *ao) +static void destroy_no_thread(struct ao *ao) { struct ao_push_state *p = ao->api_priv; - pthread_mutex_lock(&p->lock); - p->terminate = true; - wakeup_playthread(ao); - pthread_mutex_unlock(&p->lock); - - pthread_join(p->thread, NULL); - ao->driver->uninit(ao); for (int n = 0; n < 2; n++) @@ -385,6 +378,20 @@ static void uninit(struct ao *ao) pthread_mutex_destroy(&p->lock); } +static void uninit(struct ao *ao) +{ + struct ao_push_state *p = ao->api_priv; + + pthread_mutex_lock(&p->lock); + p->terminate = true; + wakeup_playthread(ao); + pthread_mutex_unlock(&p->lock); + + pthread_join(p->thread, NULL); + + destroy_no_thread(ao); +} + static int init(struct ao *ao) { struct ao_push_state *p = ao->api_priv; @@ -407,7 +414,7 @@ static int init(struct ao *ao) goto err; return 0; err: - ao->driver->uninit(ao); + destroy_no_thread(ao); return -1; } |