aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2007-02-11 20:36:26 +0000
committerWarren Dukes <warren.dukes@gmail.com>2007-02-11 20:36:26 +0000
commitb54c7c64c00dca82a5a1699140ec828343be0cbf (patch)
tree9cd41b36d785998fcc019596b289498e6cf49f61 /src/decode.c
parentc5933a164a2b25352becda8b0f103b42bc646348 (diff)
downloadmpd-b54c7c64c00dca82a5a1699140ec828343be0cbf.tar.gz
mpd-b54c7c64c00dca82a5a1699140ec828343be0cbf.tar.xz
mpd-b54c7c64c00dca82a5a1699140ec828343be0cbf.zip
#1) fix a few potential deadlock conditons in decode.c when crossfading is enabled
#2) fix a deadlock condition when attempting to seek if the decoder quit and returned to playerInit() git-svn-id: https://svn.musicpd.org/mpd/trunk@5325 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/decode.c')
-rw-r--r--src/decode.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/decode.c b/src/decode.c
index 2d4b137f5..656b7313a 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -481,10 +481,10 @@ static void advanceOutputBufferTo(OutputBuffer * cb, PlayerControl * pc,
while (cb->begin != to) {
handleMetadata(cb, pc, previous, currentChunkSent,
currentChunk);
- cb->begin++;
- if (cb->begin >= buffered_chunks) {
+ if (cb->begin + 1 >= buffered_chunks) {
cb->begin = 0;
}
+ else cb->begin++;
}
}
@@ -517,7 +517,8 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
pc->play = 0;
kill(getppid(), SIGUSR1);
- while (decode_pid > 0 && cb->end - cb->begin < bbp &&
+ while (decode_pid > 0 &&
+ cb->end - cb->begin < bbp &&
cb->end != buffered_chunks - 1 &&
dc->state != DECODE_STATE_STOP) {
processDecodeInput();
@@ -618,10 +619,10 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
cb->begin = 0;
} else
cb->begin++;
- } else if (next == cb->begin) {
+ } else if (cb->begin != end && cb->begin == next) {
if (doCrossFade == 1 && nextChunk >= 0) {
nextChunk = cb->begin + crossFadeChunks;
- test = cb->end;
+ test = end;
if (end < cb->begin)
test += buffered_chunks;
if (nextChunk < test) {