OSDN Git Service

android/client: Simplify playback_thread in if-audio
authorSzymon Janc <szymon.janc@gmail.com>
Wed, 2 Apr 2014 20:00:07 +0000 (22:00 +0200)
committerSzymon Janc <szymon.janc@gmail.com>
Thu, 3 Apr 2014 19:56:07 +0000 (21:56 +0200)
Thread is never cancelled so no need to use pthread_cleanup_push and
pthread_cleanup_pop.

android/client/if-audio.c

index ce9e534..9921b30 100644 (file)
@@ -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;
 }