aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--TODO14
-rw-r--r--src/aac_decode.c2
-rw-r--r--src/audiofile_decode.c3
-rw-r--r--src/decode.c22
-rw-r--r--src/decode.h2
-rw-r--r--src/flac_decode.c1
-rw-r--r--src/mp3_decode.c10
-rw-r--r--src/mp4_decode.c1
-rw-r--r--src/ogg_decode.c1
-rw-r--r--src/outputBuffer.c4
10 files changed, 30 insertions, 30 deletions
diff --git a/TODO b/TODO
index 62814c3d8..d80ad91ae 100644
--- a/TODO
+++ b/TODO
@@ -2,17 +2,9 @@
a) make seekings non-blocking:
1) player:
a) first check that seekWhere isn't already buffered
- b) if not current song, stop it and play the song to
- seek
- c) set dc->seek and dc->seekWhere if not already set
- and set elapsed time to seekWhere and
- then set pc->seek = 0
- d) while seeking just continue to play buffer
- until seek is done
- 2) decoder:
- a) seek no longer blocks so don't worry about checking
- seek in blocking portions, only check stop!
- b) yay, less code mess!
+ 2) check that stream is seekable before seeking forward!
+ 3) deal with seeking forward better by calling seek function
+ (for mp3 and mp4)!
b) bufferInput in outputBuffer waiting!
1) implement some sort of callback mechanism for this
for abstraction sake
diff --git a/src/aac_decode.c b/src/aac_decode.c
index cc3b8ee69..70ec21dd6 100644
--- a/src/aac_decode.c
+++ b/src/aac_decode.c
@@ -383,7 +383,7 @@ int aac_decode(OutputBuffer * cb, DecoderControl * dc) {
if(dc->state != DECODE_STATE_DECODE) return -1;
- if(!dc->stop && !dc->seek && chunkLen>0) {
+ if(!dc->stop && chunkLen>0) {
cb->chunkSize[cb->end] = chunkLen;
++cb->end;
diff --git a/src/audiofile_decode.c b/src/audiofile_decode.c
index 38ca591dc..b4a224d19 100644
--- a/src/audiofile_decode.c
+++ b/src/audiofile_decode.c
@@ -101,7 +101,7 @@ int audiofile_decode(OutputBuffer * cb, DecoderControl * dc) {
current = dc->seekWhere *
dc->audioFormat.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK,current);
-
+ dc->seekChunk = cb->end;
dc->seek = 0;
}
@@ -114,7 +114,6 @@ int audiofile_decode(OutputBuffer * cb, DecoderControl * dc) {
(float)dc->audioFormat.sampleRate,
bitRate);
if(dc->stop) break;
- else if(dc->seek) continue;
}
}
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,
diff --git a/src/decode.h b/src/decode.h
index d73cb587c..ef6ddeb46 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -46,12 +46,12 @@
#define DECODE_SUFFIX_WAVE 6
typedef struct _DecoderControl {
- volatile mpd_sint8 seekable;
volatile mpd_sint8 state;
volatile mpd_sint8 stop;
volatile mpd_sint8 start;
volatile mpd_uint16 error;
volatile mpd_sint8 seek;
+ volatile mpd_sint16 seekChunk;
volatile mpd_sint8 seekError;
volatile mpd_sint8 cycleLogFiles;
volatile double seekWhere;
diff --git a/src/flac_decode.c b/src/flac_decode.c
index 7a966bbb8..a721c0a62 100644
--- a/src/flac_decode.c
+++ b/src/flac_decode.c
@@ -154,6 +154,7 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc) {
dc->audioFormat.sampleRate;
data.position = 0;
}
+ dc->seekChunk = cb->end;
dc->seek = 0;
}
}
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index 33c309e7b..2b9fb9748 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -461,6 +461,7 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
if(!dc->seek) data->muteFrame = 0;
else if(dc->seekWhere<=data->elapsedTime) {
clearOutputBuffer(cb);
+ dc->seekChunk = cb->end;
data->muteFrame = 0;
dc->seek = 0;
}
@@ -517,6 +518,7 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
data->frameOffset[i]) == 0)
{
clearOutputBuffer(cb);
+ dc->seekChunk = cb->end;
data->currentFrame = i;
data->muteFrame = 0;
}
@@ -529,13 +531,13 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
while(1) {
skip = 0;
while((ret = decodeNextFrameHeader(data))==DECODE_CONT &&
- !dc->seek && !dc->stop);
+ !dc->stop);
if(ret==DECODE_SKIP) skip = 1;
- else if(ret==DECODE_BREAK || dc->stop || dc->seek) break;
+ else if(ret==DECODE_BREAK || dc->stop) break;
if(!data->muteFrame) {
while((ret = decodeNextFrame(data))==DECODE_CONT &&
- !dc->seek && !dc->stop);
- if(ret==DECODE_BREAK || dc->seek || dc->stop) break;
+ !dc->stop);
+ if(ret==DECODE_BREAK || dc->stop) break;
}
if(!skip && ret==DECODE_OK) break;
}
diff --git a/src/mp4_decode.c b/src/mp4_decode.c
index 010e0524f..b94023df8 100644
--- a/src/mp4_decode.c
+++ b/src/mp4_decode.c
@@ -221,6 +221,7 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc) {
seekPositionFound = 0;
chunkLen = 0;
clearOutputBuffer(cb);
+ dc->seekChunk = cb->end;
dc->seek = 0;
}
diff --git a/src/ogg_decode.c b/src/ogg_decode.c
index 672785af2..6f8ffe535 100644
--- a/src/ogg_decode.c
+++ b/src/ogg_decode.c
@@ -192,6 +192,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc)
if(dc->seek) {
clearOutputBuffer(cb);
chunkpos = 0;
+ dc->seekChunk = cb->end;
ov_time_seek_page(&vf,dc->seekWhere);
dc->seek = 0;
}
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 590b9a433..ddf6395a6 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -73,13 +73,11 @@ int sendDataToOutputBuffer(OutputBuffer * cb, DecoderControl * dc,
while(datalen) {
if(currentChunk != cb->end) {
- while(cb->begin==cb->end && cb->wrap && !dc->stop &&
- !dc->seek)
+ while(cb->begin==cb->end && cb->wrap && !dc->stop)
{
my_usleep(10000);
}
if(dc->stop) return OUTPUT_BUFFER_DC_STOP;
- if(dc->seek) return OUTPUT_BUFFER_DC_SEEK;
currentChunk = cb->end;
cb->chunkSize[currentChunk] = 0;