use the notify API in the player
git-svn-id: https://svn.musicpd.org/mpd/trunk@7282 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:

committed by
Eric Wong

parent
701cf6884c
commit
b7ac3fab46
14
src/player.c
14
src/player.c
@ -33,9 +33,6 @@
|
|||||||
#include "sig_handlers.h"
|
#include "sig_handlers.h"
|
||||||
#include "os_compat.h"
|
#include "os_compat.h"
|
||||||
|
|
||||||
static pthread_cond_t player_wakeup = PTHREAD_COND_INITIALIZER;
|
|
||||||
static pthread_mutex_t player_wakeup_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
|
|
||||||
static pthread_cond_t main_wakeup = PTHREAD_COND_INITIALIZER;
|
static pthread_cond_t main_wakeup = PTHREAD_COND_INITIALIZER;
|
||||||
static pthread_mutex_t main_wakeup_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t main_wakeup_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
@ -43,12 +40,14 @@ static void playerCloseAudio(void);
|
|||||||
|
|
||||||
void wakeup_player_nb(void)
|
void wakeup_player_nb(void)
|
||||||
{
|
{
|
||||||
pthread_cond_signal(&player_wakeup);
|
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||||
|
notifySignal(&pc->notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wakeup_player(void)
|
static void wakeup_player(void)
|
||||||
{
|
{
|
||||||
pthread_cond_signal(&player_wakeup);
|
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||||
|
notifySignal(&pc->notify);
|
||||||
pthread_cond_wait(&main_wakeup, &main_wakeup_mutex);
|
pthread_cond_wait(&main_wakeup, &main_wakeup_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +58,16 @@ void wakeup_main_task(void)
|
|||||||
|
|
||||||
void player_sleep(void)
|
void player_sleep(void)
|
||||||
{
|
{
|
||||||
pthread_cond_wait(&player_wakeup, &player_wakeup_mutex);
|
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||||
|
notifyWait(&pc->notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * player_task(mpd_unused void *unused)
|
static void * player_task(mpd_unused void *unused)
|
||||||
{
|
{
|
||||||
PlayerControl *pc = &(getPlayerData()->playerControl);
|
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||||
|
|
||||||
|
notifyEnter(&pc->notify);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (pc->play) {
|
if (pc->play) {
|
||||||
decode();
|
decode();
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#define PLAYER_QUEUE_LOCKED 1
|
#define PLAYER_QUEUE_LOCKED 1
|
||||||
|
|
||||||
typedef struct _PlayerControl {
|
typedef struct _PlayerControl {
|
||||||
|
Notify notify;
|
||||||
volatile mpd_sint8 stop;
|
volatile mpd_sint8 stop;
|
||||||
volatile mpd_sint8 play;
|
volatile mpd_sint8 play;
|
||||||
volatile mpd_sint8 pause;
|
volatile mpd_sint8 pause;
|
||||||
|
@ -96,6 +96,7 @@ void initPlayerData(void)
|
|||||||
initOutputBuffer(&(playerData_pd->buffer),
|
initOutputBuffer(&(playerData_pd->buffer),
|
||||||
(OutputBufferChunk*)(((char *)playerData_pd) + sizeof(PlayerData)));
|
(OutputBufferChunk*)(((char *)playerData_pd) + sizeof(PlayerData)));
|
||||||
|
|
||||||
|
notifyInit(&playerData_pd->playerControl.notify);
|
||||||
playerData_pd->playerControl.stop = 0;
|
playerData_pd->playerControl.stop = 0;
|
||||||
playerData_pd->playerControl.pause = 0;
|
playerData_pd->playerControl.pause = 0;
|
||||||
playerData_pd->playerControl.play = 0;
|
playerData_pd->playerControl.play = 0;
|
||||||
|
Reference in New Issue
Block a user