From 8a16d7064583cd94686aca52b1b5cc393369bd9b Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 2 Apr 2014 22:00:07 +0200 Subject: [PATCH] android/client: Simplify playback_thread in if-audio Thread is never cancelled so no need to use pthread_cleanup_push and pthread_cleanup_pop. --- android/client/if-audio.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/android/client/if-audio.c b/android/client/if-audio.c index ce9e53486..9921b3034 100644 --- a/android/client/if-audio.c +++ b/android/client/if-audio.c @@ -116,15 +116,6 @@ static void init_p(int argc, const char **argv) if_audio = device; } -static void playthread_cleanup(void *arg) -{ - pthread_mutex_lock(&state_mutex); - current_state = STATE_STOPPED; - pthread_mutex_unlock(&state_mutex); - - haltest_info("Done playing.\n"); -} - static int feed_from_file(short *buffer, void *data) { FILE *in = data; @@ -185,8 +176,6 @@ static void *playback_thread(void *data) void *cb_data = NULL; float freq = 440.0; - pthread_cleanup_push(playthread_cleanup, NULL); - /* Use file or fall back to generator */ if (in) { filbuff_cb = feed_from_file; @@ -228,7 +217,12 @@ static void *playback_thread(void *data) if (in) fclose(in); - pthread_cleanup_pop(1); + pthread_mutex_lock(&state_mutex); + current_state = STATE_STOPPED; + pthread_mutex_unlock(&state_mutex); + + haltest_info("Done playing.\n"); + return NULL; } -- 2.47.3