summaryrefslogtreecommitdiff
path: root/src/decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-19 23:48:34 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-19 23:48:34 +0000
commita81573ef059ac9f006ea438574b1b7ff751ba55d (patch)
tree84736ed5ad3c296ff9502c407c2ab176023cd90e /src/decode.c
parentc1fbcd03f04cfb11401174e40f7d451ee3abfff5 (diff)
non-blocking seeking, needs some testing! (this is not just for streams
but new code for files seeking as well) git-svn-id: https://svn.musicpd.org/mpd/trunk@1099 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/decode.c')
-rw-r--r--src/decode.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/decode.c b/src/decode.c
index 45ffd8d97..af5ca2c21 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -128,7 +128,7 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
pc->channels = dc->audioFormat.channels; \
} \
else if(decodeWaitedOn) { \
- my_usleep(10); \
+ my_usleep(10000); \
continue; \
}
@@ -161,7 +161,7 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
{
int ret = -1;
- if(decode_pid && *decode_pid>0) {
+ if(decode_pid && *decode_pid>0 && !dc->seek) {
cb->next = -1;
if(dc->state==DECODE_STATE_STOP || dc->error ||
strcmp(dc->file,pc->file)!=0)
@@ -180,13 +180,14 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
pc->seekWhere;
dc->seekWhere = 0 > dc->seekWhere ? 0 : dc->seekWhere;
dc->seekError = 0;
+ dc->seekChunk = -1;
dc->seek = 1;
- pc->bitRate = 0;
- while(*decode_pid>0 && dc->seek) my_usleep(1000);
- if(!dc->seekError) {
+ /*pc->bitRate = 0;*/
+ /*while(*decode_pid>0 && dc->seek) my_usleep(1000);*/
+ /*if(!dc->seekError) {*/
ret = 0;
pc->elapsedTime = dc->seekWhere;
- }
+ /*}*/
}
}
pc->seek = 0;
@@ -231,6 +232,7 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
doCrossFade = 0; \
nextChunk = -1; \
bbp = 0; \
+ seeking = 1; \
} \
} \
if(pc->stop) { \
@@ -254,7 +256,6 @@ void decodeStart(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
return;
}
- dc->seekable = inStream.seekable;
dc->state = DECODE_STATE_START;
dc->start = 0;
@@ -386,6 +387,7 @@ 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);
@@ -407,6 +409,10 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
while(!quit) {
processDecodeInput();
handleDecodeStart();
+ if(!dc->seek && seeking) {
+ if(dc->seekChunk >= 0) cb->begin = dc->seekChunk;
+ seeking = 0;
+ }
if(dc->state==DECODE_STATE_STOP &&
pc->queueState==PLAYER_QUEUE_FULL &&
pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
@@ -481,7 +487,7 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
else continue;
}
}
- pc->elapsedTime = cb->times[cb->begin];
+ if(!seeking) pc->elapsedTime = cb->times[cb->begin];
pc->bitRate = cb->bitRate[cb->begin];
pcm_volumeChange(cb->chunks+cb->begin*
CHUNK_SIZE,