From 650af294716e34a3992770aab23aafebb358bac8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 27 Sep 2014 04:54:17 +0200 Subject: audio/out/push: clean up properly on init error Close the wakeup pipes, free the mutex and condition var. --- audio/out/push.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'audio/out/push.c') 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; } -- cgit v1.2.3