aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-30 13:33:13 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-30 13:33:13 +0000
commitd80093fed6c084e38a4c3808e62649bd723adc5b (patch)
treec44e0ba8d87662d78e8e0ad1b9b90a174aee02fb /src/decode.c
parentc4396a6be687907583972cb64c42a2923a5bf5c9 (diff)
downloadmpd-d80093fed6c084e38a4c3808e62649bd723adc5b.tar.gz
mpd-d80093fed6c084e38a4c3808e62649bd723adc5b.tar.xz
mpd-d80093fed6c084e38a4c3808e62649bd723adc5b.zip
fixed seek, its now blocking again
git-svn-id: https://svn.musicpd.org/mpd/trunk@1237 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/decode.c')
-rw-r--r--src/decode.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/decode.c b/src/decode.c
index 7582c4e93..d5d3ab41b 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -173,7 +173,7 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
{
int ret = -1;
- if(decode_pid && *decode_pid>0 && !dc->seek) {
+ if(decode_pid && *decode_pid>0) {
cb->next = -1;
if(dc->state==DECODE_STATE_STOP || dc->error ||
strcmp(dc->file,pc->file)!=0)
@@ -186,16 +186,21 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
dc->start = 1;
waitOnDecode(pc,dc,cb,decodeWaitedOn);
}
- if(*decode_pid>0 && dc->state!=DECODE_STATE_STOP) {
+ if(*decode_pid>0 && dc->state!=DECODE_STATE_STOP &&
+ dc->seekable)
+ {
dc->seekWhere = pc->seekWhere > pc->totalTime-0.1 ?
pc->totalTime-0.1 :
pc->seekWhere;
dc->seekWhere = 0 > dc->seekWhere ? 0 : dc->seekWhere;
- dc->seekChunk = -1;
+ dc->seekError = 0;
dc->seek = 1;
- pc->elapsedTime = dc->seekWhere;
- pc->beginTime = pc->elapsedTime;
- ret = 0;
+ while(*decode_pid>0 && dc->seek) my_usleep(10000);
+ if(!dc->seekError) {
+ pc->elapsedTime = dc->seekWhere;
+ pc->beginTime = pc->elapsedTime;
+ ret = 0;
+ }
}
}
pc->seek = 0;
@@ -239,7 +244,6 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
doCrossFade = 0; \
nextChunk = -1; \
bbp = 0; \
- seeking = 1; \
} \
} \
if(pc->stop) { \
@@ -265,11 +269,12 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
return;
}
+ dc->seekable = inStream.seekable;
dc->state = DECODE_STATE_START;
dc->start = 0;
while(!inputStreamAtEOF(&inStream) && bufferInputStream(&inStream) < 0
- && !pc->stop);
+ && !dc->stop);
if(dc->stop) {
dc->state = DECODE_STATE_STOP;
@@ -368,7 +373,7 @@ int decoderInit(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
myfprintfCloseAndOpenLogFile();
dc->cycleLogFiles = 0;
}
- else if(dc->start) decodeStart(pc, cb, dc);
+ else if(dc->start || dc->seek) decodeStart(pc, cb, dc);
else if(dc->stop) {
dc->state = DECODE_STATE_STOP;
dc->stop = 0;
@@ -404,7 +409,6 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
int test;
int decodeWaitedOn = 0;
char silence[CHUNK_SIZE];
- int seeking = 0;
memset(silence,0,CHUNK_SIZE);
@@ -426,13 +430,6 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
while(!quit) {
processDecodeInput();
handleDecodeStart();
- if(!dc->seek && seeking) {
- if(dc->seekChunk >= 0) {
- cb->begin = dc->seekChunk;
- cb->wrap = 0;
- }
- seeking = 0;
- }
if(dc->state==DECODE_STATE_STOP &&
pc->queueState==PLAYER_QUEUE_FULL &&
pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
@@ -507,7 +504,7 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
else continue;
}
}
- if(!seeking) pc->elapsedTime = cb->times[cb->begin];
+ pc->elapsedTime = cb->times[cb->begin];
pc->bitRate = cb->bitRate[cb->begin];
pcm_volumeChange(cb->chunks+cb->begin*
CHUNK_SIZE,