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
This commit is contained in:
22
src/decode.c
22
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,
|
||||
|
||||
Reference in New Issue
Block a user