summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-27 04:54:17 +0200
committerwm4 <wm4@nowhere>2014-09-27 04:54:17 +0200
commit650af294716e34a3992770aab23aafebb358bac8 (patch)
tree1956f28c510fb6fdc5c999dec7c3f69de396c8f1
parente79de41b97b497c355f113362da66988d6719260 (diff)
downloadmpv-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.c25
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;
}