Tell the player process (and thus also the decode process) to quit when
playback is stopped completely. This means the player process will no longer have to wake up 100 times per second to see if it's been told to start playing (the main process will just spawn a new player process when it needs to). On the downside, this means an extra pair of forks() and the re-initializing of the player and decode processes each time playback is restarted. git-svn-id: https://svn.musicpd.org/mpd/trunk@6446 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
88638f4821
commit
6d7e0eb166
23
src/player.c
23
src/player.c
@ -155,6 +155,9 @@ int playerInit(void)
|
||||
} else if (pc->cycleLogFiles) {
|
||||
cycle_log_files();
|
||||
pc->cycleLogFiles = 0;
|
||||
} else if (pc->quit) {
|
||||
pc->quit = 0;
|
||||
break;
|
||||
} else
|
||||
my_usleep(10000);
|
||||
}
|
||||
@ -174,6 +177,24 @@ int playerInit(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int playerQuit(int fd)
|
||||
{
|
||||
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||
|
||||
if (playerStop(fd) < 0)
|
||||
return -1;
|
||||
|
||||
playerCloseAudio();
|
||||
|
||||
if (player_pid > 0) {
|
||||
pc->quit = 1;
|
||||
while (player_pid > 0 && pc->quit)
|
||||
my_usleep(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int playerPlay(int fd, Song * song)
|
||||
{
|
||||
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||
@ -341,6 +362,8 @@ void playerCloseAudio(void)
|
||||
if (playerStop(STDERR_FILENO) < 0)
|
||||
return;
|
||||
pc->closeAudio = 1;
|
||||
while (player_pid > 0 && pc->closeAudio)
|
||||
my_usleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@
|
||||
#define PLAYER_METADATA_STATE_WRITE 2
|
||||
|
||||
typedef struct _PlayerControl {
|
||||
volatile mpd_sint8 quit;
|
||||
volatile mpd_sint8 stop;
|
||||
volatile mpd_sint8 play;
|
||||
volatile mpd_sint8 pause;
|
||||
@ -121,6 +122,8 @@ int getPlayerError(void);
|
||||
|
||||
int playerInit(void);
|
||||
|
||||
int playerQuit(int fd);
|
||||
|
||||
int queueSong(Song * song);
|
||||
|
||||
int getPlayerQueueState(void);
|
||||
|
@ -118,6 +118,7 @@ void initPlayerData(void)
|
||||
buffered_chunks * sizeof(mpd_sint8));
|
||||
buffer->acceptMetadata = 0;
|
||||
|
||||
playerData_pd->playerControl.quit = 0;
|
||||
playerData_pd->playerControl.stop = 0;
|
||||
playerData_pd->playerControl.pause = 0;
|
||||
playerData_pd->playerControl.play = 0;
|
||||
|
@ -786,7 +786,7 @@ int deleteFromPlaylist(int fd, int song)
|
||||
&& playlist.current == songOrder) {
|
||||
/*if(playlist.current>=playlist.length) return playerStop(fd);
|
||||
else return playPlaylistOrderNumber(fd,playlist.current); */
|
||||
playerStop(STDERR_FILENO);
|
||||
playerQuit(STDERR_FILENO);
|
||||
playlist_noGoToNext = 1;
|
||||
}
|
||||
|
||||
@ -827,9 +827,8 @@ void deleteASongFromPlaylist(Song * song)
|
||||
int stopPlaylist(int fd)
|
||||
{
|
||||
DEBUG("playlist: stop\n");
|
||||
if (playerStop(fd) < 0)
|
||||
if (playerQuit(fd) < 0)
|
||||
return -1;
|
||||
playerCloseAudio();
|
||||
playlist.queued = -1;
|
||||
playlist_state = PLAYLIST_STATE_STOP;
|
||||
playlist_noGoToNext = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user