aboutsummaryrefslogtreecommitdiffstats
path: root/src/player.c
diff options
context:
space:
mode:
authorJ. Alexander Treuman <jat@spatialrift.net>2007-06-04 22:29:55 +0000
committerJ. Alexander Treuman <jat@spatialrift.net>2007-06-04 22:29:55 +0000
commit89eca9eebcec92efaf7bf5ecada3af4fbf540c9f (patch)
tree0c6fc19a0e495694f652a91f6dc0cef3da98d2b1 /src/player.c
parent4734a2e2b4d17ec4a03a1fdf08ed0f04bf8d431c (diff)
downloadmpd-89eca9eebcec92efaf7bf5ecada3af4fbf540c9f.tar.gz
mpd-89eca9eebcec92efaf7bf5ecada3af4fbf540c9f.tar.xz
mpd-89eca9eebcec92efaf7bf5ecada3af4fbf540c9f.zip
Don't kill the player process (and effectively the decode process) when
completely stopped. Instead, send them SIGSTOP to pause the process until they're needed again. Then send them SIGCONT instead of re-spawning them. git-svn-id: https://svn.musicpd.org/mpd/trunk@6485 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/player.c b/src/player.c
index e2dc21064..beff9b389 100644
--- a/src/player.c
+++ b/src/player.c
@@ -110,6 +110,14 @@ void player_sigChldHandler(int pid, int status)
int playerInit(void)
{
+ int pid;
+
+ pid = player_pid;
+ if (pid > 0) {
+ kill(pid, SIGCONT);
+ return 0;
+ }
+
blockSignals();
player_pid = fork();
if (player_pid==0)
@@ -155,9 +163,6 @@ 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);
}
@@ -177,20 +182,18 @@ int playerInit(void)
return 0;
}
-int playerQuit(int fd)
+int playerWait(int fd)
{
- PlayerControl *pc = &(getPlayerData()->playerControl);
+ int pid;
if (playerStop(fd) < 0)
return -1;
playerCloseAudio();
- if (player_pid > 0) {
- pc->quit = 1;
- while (player_pid > 0 && pc->quit)
- my_usleep(1000);
- }
+ pid = player_pid;
+ if (pid > 0)
+ kill(pid, SIGSTOP);
return 0;
}
@@ -212,7 +215,7 @@ int playerPlay(int fd, Song * song)
pathcpy_trunc(pc->utf8url, getSongUrl(song));
pc->play = 1;
- if (player_pid == 0 && playerInit() < 0) {
+ if (playerInit() < 0) {
pc->play = 0;
return -1;
}
@@ -245,8 +248,10 @@ void playerKill(void)
int pid;
pid = player_pid;
- if (pid > 0)
+ if (pid > 0) {
+ kill(pid, SIGCONT);
kill(pid, SIGTERM);
+ }
}
int playerPause(int fd)