diff options
author | Max Kellermann <max@duempel.org> | 2008-04-12 04:14:32 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-04-12 04:14:32 +0000 |
commit | 701cf6884ceb8a5a4791211258ce5d298d38e22f (patch) | |
tree | 3961c3ff3a05c34106e438ab851fe4e7d123fe16 /src | |
parent | 0146fbe3ceab96759f1e55e73daaa6d6d7bc4b9b (diff) | |
download | mpd-701cf6884ceb8a5a4791211258ce5d298d38e22f.tar.gz mpd-701cf6884ceb8a5a4791211258ce5d298d38e22f.tar.xz mpd-701cf6884ceb8a5a4791211258ce5d298d38e22f.zip |
use the notify API in the decoder
git-svn-id: https://svn.musicpd.org/mpd/trunk@7281 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r-- | src/decode.c | 14 | ||||
-rw-r--r-- | src/decode.h | 3 | ||||
-rw-r--r-- | src/playerData.c | 1 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/decode.c b/src/decode.c index 06c054e3b..d8534471a 100644 --- a/src/decode.c +++ b/src/decode.c @@ -30,9 +30,6 @@ #include "utf8.h" #include "os_compat.h" -static pthread_cond_t decoder_wakeup_cond = PTHREAD_COND_INITIALIZER; -static pthread_mutex_t decoder_wakeup_mutex = PTHREAD_MUTEX_INITIALIZER; - /* called inside decoder_task (inputPlugins) */ void decoder_wakeup_player(void) { @@ -41,19 +38,22 @@ void decoder_wakeup_player(void) void decoder_sleep(void) { - pthread_cond_wait(&decoder_wakeup_cond, &decoder_wakeup_mutex); + DecoderControl *dc = &(getPlayerData()->decoderControl); + notifyWait(&dc->notify); wakeup_player_nb(); } static void player_wakeup_decoder_nb(void) { - pthread_cond_signal(&decoder_wakeup_cond); + DecoderControl *dc = &(getPlayerData()->decoderControl); + notifySignal(&dc->notify); } /* called from player_task */ static void player_wakeup_decoder(void) { - pthread_cond_signal(&decoder_wakeup_cond); + DecoderControl *dc = &(getPlayerData()->decoderControl); + notifySignal(&dc->notify); player_sleep(); } @@ -332,6 +332,8 @@ static void * decoder_task(mpd_unused void *unused) PlayerControl *pc = &(getPlayerData()->playerControl); DecoderControl *dc = &(getPlayerData()->decoderControl); + notifyEnter(&dc->notify); + while (1) { if (dc->start || dc->seek) { decodeStart(pc, cb, dc); diff --git a/src/decode.h b/src/decode.h index 704caf990..ed9a25081 100644 --- a/src/decode.h +++ b/src/decode.h @@ -26,6 +26,7 @@ #include "mpd_types.h" #include "audio.h" +#include "notify.h" #include "os_compat.h" @@ -41,6 +42,8 @@ #define DECODE_ERROR_FILE 20 typedef struct _DecoderControl { + Notify notify; + volatile mpd_sint8 state; volatile mpd_sint8 stop; volatile mpd_sint8 start; diff --git a/src/playerData.c b/src/playerData.c index f9cc314a9..3261d444a 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -113,6 +113,7 @@ void initPlayerData(void) playerData_pd->playerControl.softwareVolume = 1000; playerData_pd->playerControl.totalPlayTime = 0; + notifyInit(&playerData_pd->decoderControl.notify); playerData_pd->decoderControl.stop = 0; playerData_pd->decoderControl.start = 0; playerData_pd->decoderControl.state = DECODE_STATE_STOP; |