diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 16 | ||||
-rw-r--r-- | src/player.c | 10 | ||||
-rw-r--r-- | src/player.h | 2 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c index 428ef2a91..1c513b171 100644 --- a/src/main.c +++ b/src/main.c @@ -56,6 +56,8 @@ typedef struct _Options { int verbose; } Options; +static Notify main_notify; + /* * from git-1.3.0, needed for solaris */ @@ -378,6 +380,16 @@ static void killFromPidFile(char *cmd, int killOption) exit(EXIT_SUCCESS); } +void wakeup_main_task(void) +{ + notifySignal(&main_notify); +} + +void wait_main_task(void) +{ + notifySignal(&main_notify); +} + int main(int argc, char *argv[]) { Options options; @@ -420,6 +432,8 @@ int main(int argc, char *argv[]) initNormalization(); initInputStream(); + notifyInit(&main_notify); + daemonize(&options); setup_log_output(options.stdOutput); @@ -433,6 +447,8 @@ int main(int argc, char *argv[]) playerInit(); read_state_file(); + notifyEnter(&main_notify); + while (COMMAND_RETURN_KILL != doIOForInterfaces() && COMMAND_RETURN_KILL != handlePendingSignals()) { syncPlayerAndPlaylist(); diff --git a/src/player.c b/src/player.c index a8bb2404d..07c074060 100644 --- a/src/player.c +++ b/src/player.c @@ -33,9 +33,6 @@ #include "sig_handlers.h" #include "os_compat.h" -static pthread_cond_t main_wakeup = PTHREAD_COND_INITIALIZER; -static pthread_mutex_t main_wakeup_mutex = PTHREAD_MUTEX_INITIALIZER; - static void playerCloseAudio(void); void wakeup_player_nb(void) @@ -48,12 +45,7 @@ static void wakeup_player(void) { PlayerControl *pc = &(getPlayerData()->playerControl); notifySignal(&pc->notify); - pthread_cond_wait(&main_wakeup, &main_wakeup_mutex); -} - -void wakeup_main_task(void) -{ - pthread_cond_signal(&main_wakeup); + wait_main_task(); } void player_sleep(void) diff --git a/src/player.h b/src/player.h index 8e2678ef1..7f43cc0d8 100644 --- a/src/player.h +++ b/src/player.h @@ -80,6 +80,8 @@ typedef struct _PlayerControl { void wakeup_main_task(void); +void wait_main_task(void); + void wakeup_player_nb(void); void player_sleep(void); |