diff options
author | J. Alexander Treuman <jat@spatialrift.net> | 2007-06-04 22:29:55 +0000 |
---|---|---|
committer | J. Alexander Treuman <jat@spatialrift.net> | 2007-06-04 22:29:55 +0000 |
commit | 89eca9eebcec92efaf7bf5ecada3af4fbf540c9f (patch) | |
tree | 0c6fc19a0e495694f652a91f6dc0cef3da98d2b1 /src/decode.c | |
parent | 4734a2e2b4d17ec4a03a1fdf08ed0f04bf8d431c (diff) | |
download | mpd-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/decode.c')
-rw-r--r-- | src/decode.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/decode.c b/src/decode.c index 8ed5776f9..ce94833e8 100644 --- a/src/decode.c +++ b/src/decode.c @@ -75,6 +75,8 @@ static void stopDecode(DecoderControl * dc) static void quitDecode(PlayerControl * pc, DecoderControl * dc) { + int pid; + stopDecode(dc); pc->state = PLAYER_STATE_STOP; dc->seek = 0; @@ -82,6 +84,10 @@ static void quitDecode(PlayerControl * pc, DecoderControl * dc) pc->stop = 0; pc->pause = 0; kill(getppid(), SIGUSR1); + + pid = decode_pid; + if (pid > 0) + kill(pid, SIGSTOP); } static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) @@ -396,6 +402,14 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb, static int decoderInit(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) { + int pid; + + pid = decode_pid; + if (pid > 0) { + kill(pid, SIGCONT); + return 0; + } + blockSignals(); getPlayerData()->playerControl.decode_pid = 0; decode_pid = fork(); @@ -691,10 +705,8 @@ void decode(void) dc->stop = 0; dc->start = 1; - if (decode_pid <= 0) { - if (decoderInit(pc, cb, dc) < 0) - return; - } + if (decoderInit(pc, cb, dc) < 0) + return; decodeParent(pc, dc, cb); } |