aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-08-27 09:36:11 +0000
committerEric Wong <normalperson@yhbt.net>2007-08-27 09:36:11 +0000
commitf18e52417639518545ebce3649f3ce3450bcb01c (patch)
tree7a6478788caa20347b76adae29da2e36d43f07ea
parent0f2e9ee6623ab30c190dfc5c575922af1990c9d9 (diff)
downloadmpd-f18e52417639518545ebce3649f3ce3450bcb01c.tar.gz
mpd-f18e52417639518545ebce3649f3ce3450bcb01c.tar.xz
mpd-f18e52417639518545ebce3649f3ce3450bcb01c.zip
send SIGSTOP to player and decoder processes on pause, too
as with the stop command, this will cause the player and decoder to suspend and not wake up hundreds of times a second to poll a variable for wakeup. This will reduce power consumption on some CPUs while mpd is paused and not playing. tests: pause && unpause => OK pause && stop && play => OK pause && exit && restart w/statefile && unpause => OK pause && block sound device && \ unpause => failed to open sound device \ => still paused and suspended => unblock sound device && unpause => OK (playing) In all cases, the player process releases the audio device when paused before going into the suspended state. git-svn-id: https://svn.musicpd.org/mpd/trunk@6822 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/decode.c14
-rw-r--r--src/player.c3
2 files changed, 13 insertions, 4 deletions
diff --git a/src/decode.c b/src/decode.c
index fcda78a19..d32799d31 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -69,6 +69,7 @@ static void stopDecode(DecoderControl * dc)
{
if (decode_pid > 0 && (dc->start || dc->state != DECODE_STATE_STOP)) {
dc->stop = 1;
+ kill(decode_pid, SIGCONT);
while (decode_pid > 0 && dc->stop)
my_usleep(10000);
}
@@ -124,7 +125,8 @@ static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af)
ERROR("problems opening audio device while playing \"%s\"\n", pc->utf8url); \
quitDecode(pc,dc); \
return; \
- } \
+ } else if (decode_pid > 0) { \
+ kill(decode_pid, SIGCONT); }\
if (pause) { \
dropBufferedAudio(); \
closeAudioDevice(); \
@@ -236,6 +238,8 @@ static int decodeSeek(PlayerControl * pc, DecoderControl * dc,
pc->state = PLAYER_STATE_PAUSE; \
} else { \
if (openAudioDevice(NULL) >= 0) { \
+ if (decode_pid > 0) \
+ kill(decode_pid, SIGCONT); \
pc->state = PLAYER_STATE_PLAY; \
} else { \
pathcpy_trunc(pc->erroredUrl, pc->utf8url); \
@@ -577,9 +581,11 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
race conditions and weirdness */
end = cb->end;
- if (pause)
- my_usleep(10000);
- else if (cb->begin != end && cb->begin != next) {
+ if (pause) {
+ if (decode_pid)
+ kill(decode_pid, SIGSTOP);
+ kill(getpid(), SIGSTOP);
+ } else if (cb->begin != end && cb->begin != next) {
if (doCrossFade == 1 && next >= 0 &&
((next > cb->begin &&
(fadePosition = next - cb->begin)
diff --git a/src/player.c b/src/player.c
index 096503b19..e84f31828 100644
--- a/src/player.c
+++ b/src/player.c
@@ -239,6 +239,7 @@ int playerStop(int fd)
if (player_pid > 0 && pc->state != PLAYER_STATE_STOP) {
pc->stop = 1;
+ kill(player_pid, SIGCONT);
while (player_pid > 0 && pc->stop)
my_usleep(1000);
}
@@ -266,6 +267,8 @@ int playerPause(int fd)
if (player_pid > 0 && pc->state != PLAYER_STATE_STOP) {
pc->pause = 1;
+ if (player_pid > 0 && pc->state == PLAYER_STATE_PAUSE)
+ kill(player_pid, SIGCONT);
while (player_pid > 0 && pc->pause)
my_usleep(1000);
}