Don't use wrappers like player_wakeup_decoder_nb().  These have been
wrappers calling notify.c functions, for compatibility with the
existing code when we migrated to notify.c.
---

 src/decode.c       |   55 ++++++++++++++++------------------------------------
 src/decode.h       |    4 ----
 src/outputBuffer.c |    5 +++--
 src/player.c       |   18 ++++-------------
 src/player.h       |    4 ----
 5 files changed, 24 insertions(+), 62 deletions(-)

diff --git a/src/decode.c b/src/decode.c
index b6e91e9..628dca1 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -32,34 +32,10 @@ enum xfade_state {
        XFADE_ENABLED = 1
 };
 
-/* called inside decoder_task (inputPlugins) */
-void decoder_wakeup_player(void)
-{
-       wakeup_player_nb();
-}
-
-void decoder_sleep(void)
-{
-       notify_wait(&dc.notify);
-       wakeup_player_nb();
-}
-
-static void player_wakeup_decoder_nb(void)
-{
-       notify_signal(&dc.notify);
-}
-
-/* called from player_task */
-static void player_wakeup_decoder(void)
-{
-       notify_signal(&dc.notify);
-       player_sleep();
-}
-
 static void dc_command_wait(void)
 {
        while (dc.command != DECODE_COMMAND_NONE) {
-               player_wakeup_decoder_nb();
+               notify_signal(&dc.notify);
                notify_wait(&pc.notify);
        }
 }
@@ -72,10 +48,10 @@ static void dc_command(enum decoder_command cmd)
 
 void dc_command_finished(void)
 {
-       assert(dc.command != DECODE_COMMAND_NONE);
+       assert(dc.command != DECODE_COMMAND_NONE);
 
-       dc.command = DECODE_COMMAND_NONE;
-       decoder_wakeup_player();
+       dc.command = DECODE_COMMAND_NONE;
+       notify_signal(&pc.notify);
 }
 
 static void stopDecode(void)
@@ -354,9 +330,11 @@ static void * decoder_task(mpd_unused void *arg)
                    dc.command == DECODE_COMMAND_SEEK) {
                        decodeStart();
                } else if (dc.command == DECODE_COMMAND_STOP) {
-                       dc_command_finished();
+                       dc.command = DECODE_COMMAND_NONE;
+                       notify_signal(&pc.notify);
                } else {
-                       decoder_sleep();
+                       notify_wait(&dc.notify);
+                       notify_signal(&pc.notify);
                }
        }
 
@@ -445,7 +423,7 @@ static void decodeParent(void)
                if (buffering) {
                        if (ob_available() < bbp) {
                                /* not enough decoded buffer space yet */
-                               player_sleep();
+                               notify_wait(&pc.notify);
                                continue;
                        } else {
                                /* buffering is complete */
@@ -469,7 +447,8 @@ static void decodeParent(void)
                                        break;
                                }
 
-                               player_wakeup_decoder();
+                               notify_signal(&dc.notify);
+                               notify_wait(&pc.notify);
 
                                if (do_pause) {
                                        dropBufferedAudio();
@@ -490,7 +469,7 @@ static void decodeParent(void)
                        else {
                                /* the decoder is not yet ready; wait
                                   some more */
-                               player_sleep();
+                               notify_wait(&pc.notify);
                                continue;
                        }
                }
@@ -506,7 +485,7 @@ static void decodeParent(void)
                        dc.command = DECODE_COMMAND_START;
                        pc.queueState = PLAYER_QUEUE_DECODE;
                        wakeup_main_task();
-                       player_wakeup_decoder_nb();
+                       notify_signal(&dc.notify);
                }
                if (next >= 0 && do_xfade == XFADE_UNKNOWN &&
                    dc.command != DECODE_COMMAND_START &&
@@ -527,7 +506,7 @@ static void decodeParent(void)
                }
 
                if (do_pause)
-                       player_sleep();
+                       notify_wait(&pc.notify);
                else if (!ob_is_empty() && (int)ob.begin != next) {
                        ob_chunk *beginChunk = ob_get_chunk(ob.begin);
                        unsigned int fadePosition;
@@ -563,7 +542,7 @@ static void decodeParent(void)
                                                /* wait for the
                                                   decoder */
                                                ob_set_lazy(0);
-                                               player_sleep();
+                                               notify_wait(&pc.notify);
                                                continue;
                                        }
                                }
@@ -574,7 +553,7 @@ static void decodeParent(void)
                                      sizeToTime) < 0)
                                break;
                        ob_shift();
-                       player_wakeup_decoder_nb();
+                       notify_signal(&dc.notify);
                } else if (!ob_is_empty() && (int)ob.begin == next) {
                        /* at the beginning of a new song */
 
@@ -590,7 +569,7 @@ static void decodeParent(void)
                        /* wait for the decoder to work on the new song */
                        if (pc.queueState == PLAYER_QUEUE_DECODE ||
                            pc.queueLockState == PLAYER_QUEUE_LOCKED) {
-                               player_sleep();
+                               notify_wait(&pc.notify);
                                continue;
                        }
                        if (pc.queueState != PLAYER_QUEUE_PLAY)
diff --git a/src/decode.h b/src/decode.h
index 2f60319..5c4d0e8 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -61,10 +61,6 @@ typedef struct _DecoderControl {
 
 void decode(void);
 
-void decoder_wakeup_player(void);
-
-void decoder_sleep(void);
-
 void decoderInit(void);
 
 /**
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index f4c56a3..ff8cf75 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -73,7 +73,7 @@ static void output_buffer_expand(unsigned i)
                /* if the buffer was empty, the player thread might be
                   waiting for us; wake it up now that another decoded
                   buffer has become available. */
-               decoder_wakeup_player();
+               notify_signal(&pc.notify);
 }
 
 void ob_flush(void)
@@ -183,7 +183,8 @@ static int tailChunk(InputStream * inStream,
                                }
                        }
                        if (!inStream || bufferInputStream(inStream) <= 0) {
-                               decoder_sleep();
+                               notify_wait(&dc.notify);
+                               notify_signal(&pc.notify);
                        }
                }
 
diff --git a/src/player.c b/src/player.c
index 61b380b..e7ec926 100644
--- a/src/player.c
+++ b/src/player.c
@@ -27,22 +27,12 @@
 
 static void playerCloseAudio(void);
 
-void wakeup_player_nb(void)
-{
-       notify_signal(&pc.notify);
-}
-
 static void wakeup_player(void)
 {
        notify_signal(&pc.notify);
        wait_main_task();
 }
 
-void player_sleep(void)
-{
-       notify_wait(&pc.notify);
-}
-
 static void * player_task(mpd_unused void *arg)
 {
        notify_enter(&pc.notify);
@@ -67,7 +57,7 @@ static void * player_task(mpd_unused void *arg)
                        pc.queueLockState = PLAYER_QUEUE_UNLOCKED;
                        pc.unlockQueue = 0;
                } else {
-                       player_sleep();
+                       notify_wait(&pc.notify);
                        continue;
                }
                /* we did something, tell the main task about it */
@@ -112,7 +102,7 @@ int playerPlay(int fd, Song * song)
 
        pc.play = 1;
        /* FIXME: _nb() variant is probably wrong here, and everywhere... */
-       do { wakeup_player_nb(); } while (pc.play);
+       do { notify_signal(&pc.notify); } while (pc.play);
 
        return 0;
 }
@@ -249,7 +239,7 @@ int getPlayerQueueState(void)
 void setQueueState(int queueState)
 {
        pc.queueState = queueState;
-       wakeup_player_nb();
+       notify_signal(&pc.notify);
 }
 
 void playerQueueLock(void)
@@ -285,7 +275,7 @@ int playerSeek(int fd, Song * song, float seek_time)
                pc.seekWhere = seek_time;
                pc.seek = 1;
                /* FIXME: _nb() is probably wrong here, too */
-               do { wakeup_player_nb(); } while (pc.seek);
+               do { notify_signal(&pc.notify); } while (pc.seek);
        }
 
        return 0;
diff --git a/src/player.h b/src/player.h
index db8f44d..e204639 100644
--- a/src/player.h
+++ b/src/player.h
@@ -76,10 +76,6 @@ typedef struct _PlayerControl {
        volatile double totalPlayTime;
 } PlayerControl;
 
-void wakeup_player_nb(void);
-
-void player_sleep(void);
-
 int playerPlay(int fd, Song * song);
 
 int playerSetPause(int fd, int pause_flag);


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to