aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/aac_decode.c10
-rw-r--r--src/audiofile_decode.c6
-rw-r--r--src/decode.c33
-rw-r--r--src/decode.h3
-rw-r--r--src/flac_decode.c9
-rw-r--r--src/mp3_decode.c33
-rw-r--r--src/mp4_decode.c7
-rw-r--r--src/ogg_decode.c9
-rw-r--r--src/outputBuffer.c9
9 files changed, 71 insertions, 48 deletions
diff --git a/src/aac_decode.c b/src/aac_decode.c
index 25af3f345..6dbaea1bc 100644
--- a/src/aac_decode.c
+++ b/src/aac_decode.c
@@ -364,7 +364,10 @@ int aac_decode(OutputBuffer * cb, DecoderControl * dc) {
sendDataToOutputBuffer(cb, NULL, dc, 0, sampleBuffer,
sampleBufferLen, time, bitRate);
- if(dc->seek) dc->seek = 0;
+ if(dc->seek) {
+ dc->seekError = 1;
+ dc->seek = 0;
+ }
else if(dc->stop) {
eof = 1;
break;
@@ -379,7 +382,10 @@ int aac_decode(OutputBuffer * cb, DecoderControl * dc) {
if(dc->state != DECODE_STATE_DECODE) return -1;
- if(dc->seek) dc->seek = 0;
+ if(dc->seek) {
+ dc->seekError = 1;
+ dc->seek = 0;
+ }
if(dc->stop) {
dc->state = DECODE_STATE_STOP;
diff --git a/src/audiofile_decode.c b/src/audiofile_decode.c
index 855f628f0..8e6c779b9 100644
--- a/src/audiofile_decode.c
+++ b/src/audiofile_decode.c
@@ -101,7 +101,6 @@ 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;
}
@@ -124,7 +123,10 @@ int audiofile_decode(OutputBuffer * cb, DecoderControl * dc) {
flushOutputBuffer(cb);
- if(dc->seek) dc->seek = 0;
+ /*if(dc->seek) {
+ dc->seekError = 1;
+ dc->seek = 0;
+ }*/
if(dc->stop) {
dc->state = DECODE_STATE_STOP;
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,
diff --git a/src/decode.h b/src/decode.h
index 33303dd26..ee453b0c8 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -51,7 +51,8 @@ typedef struct _DecoderControl {
volatile mpd_sint8 start;
volatile mpd_uint16 error;
volatile mpd_sint8 seek;
- volatile mpd_sint16 seekChunk;
+ volatile mpd_sint8 seekError;
+ volatile mpd_sint8 seekable;
volatile mpd_sint8 cycleLogFiles;
volatile double seekWhere;
char file[MAXPATHLEN+1];
diff --git a/src/flac_decode.c b/src/flac_decode.c
index 7c5b5238b..a5af3e132 100644
--- a/src/flac_decode.c
+++ b/src/flac_decode.c
@@ -146,15 +146,15 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc) {
if(dc->seek) {
FLAC__uint64 sampleToSeek = dc->seekWhere*
dc->audioFormat.sampleRate+0.5;
- clearOutputBuffer(cb);
if(FLAC__seekable_stream_decoder_seek_absolute(flacDec,
sampleToSeek))
{
+ clearOutputBuffer(cb);
data.time = ((float)sampleToSeek)/
dc->audioFormat.sampleRate;
data.position = 0;
}
- dc->seekChunk = cb->end;
+ else dc->seekError = 1;
dc->seek = 0;
}
}
@@ -173,7 +173,10 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc) {
flushOutputBuffer(data.cb);
}
- if(dc->seek) dc->seek = 0;
+ /*if(dc->seek) {
+ dc->seekError = 1;
+ dc->seek = 0;
+ } */
if(dc->stop) {
dc->state = DECODE_STATE_STOP;
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index 1e309bd79..467a656df 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -468,7 +468,6 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
if(dc->seekWhere<=data->elapsedTime) {
data->outputPtr = data->outputBuffer;
clearOutputBuffer(cb);
- dc->seekChunk = cb->end;
data->muteFrame = 0;
dc->seek = 0;
}
@@ -528,26 +527,29 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
{
data->outputPtr = data->outputBuffer;
clearOutputBuffer(cb);
- dc->seekChunk = cb->end;
data->currentFrame = i;
}
+ else dc->seekError = 1;
data->muteFrame = 0;
dc->seek = 0;
}
}
- else if(dc->seek && !data->inStream->seekable) dc->seek = 0;
+ else if(dc->seek && !data->inStream->seekable) {
+ dc->seek = 0;
+ dc->seekError = 1;
+ }
}
while(1) {
skip = 0;
while((ret = decodeNextFrameHeader(data))==DECODE_CONT &&
- !dc->stop);
- if(ret==DECODE_SKIP) skip = 1;
- else if(ret==DECODE_BREAK || dc->stop) break;
+ !dc->stop && !dc->seek);
+ if(ret==DECODE_BREAK || dc->stop || dc->seek) break;
+ else if(ret==DECODE_SKIP) skip = 1;
if(!data->muteFrame) {
while((ret = decodeNextFrame(data))==DECODE_CONT &&
- !dc->stop);
- if(ret==DECODE_BREAK || dc->stop) break;
+ !dc->stop && !dc->seek);
+ if(ret==DECODE_BREAK || dc->stop || dc->seek) break;
}
if(!skip && ret==DECODE_OK) break;
}
@@ -590,17 +592,20 @@ int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream,
while(mp3Read(&data,cb,dc)!=DECODE_BREAK);
/* send last little bit if not dc->stop */
if(data.outputPtr!=data.outputBuffer && data.flush) {
- if(sendDataToOutputBuffer(cb,NULL,dc,0,data.outputBuffer,
+ sendDataToOutputBuffer(cb, NULL, dc,
+ data.inStream->seekable,
+ data.outputBuffer,
data.outputPtr-data.outputBuffer,
- data.elapsedTime,data.bitRate/1000) == 0)
- {
- flushOutputBuffer(cb);
- }
+ data.elapsedTime,data.bitRate/1000);
}
+ flushOutputBuffer(cb);
mp3DecodeDataFinalize(&data);
- if(dc->seek) dc->seek = 0;
+ /*if(dc->seek) {
+ dc->seekError = 1;
+ dc->seek = 0;
+ }*/
if(dc->stop) {
dc->state = DECODE_STATE_STOP;
diff --git a/src/mp4_decode.c b/src/mp4_decode.c
index e83200451..219053538 100644
--- a/src/mp4_decode.c
+++ b/src/mp4_decode.c
@@ -27,6 +27,7 @@
#include "pcm_utils.h"
#include "inputStream.h"
#include "outputBuffer.h"
+#include "decode.h"
#include "mp4ff/mp4ff.h"
@@ -220,7 +221,6 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc) {
if(dc->seek && seekPositionFound) {
seekPositionFound = 0;
clearOutputBuffer(cb);
- dc->seekChunk = cb->end;
dc->seek = 0;
}
@@ -298,7 +298,10 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc) {
if(dc->state != DECODE_STATE_DECODE) return -1;
- if(dc->seek) dc->seek = 0;
+ /*if(dc->seek) {
+ dc->seekError = 1;
+ dc->seek = 0;
+ }*/
if(dc->stop) {
dc->state = DECODE_STATE_STOP;
diff --git a/src/ogg_decode.c b/src/ogg_decode.c
index 60f310fba..22ae07727 100644
--- a/src/ogg_decode.c
+++ b/src/ogg_decode.c
@@ -219,8 +219,8 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
if(0 == ov_time_seek_page(&vf,dc->seekWhere)) {
clearOutputBuffer(cb);
chunkpos = 0;
- dc->seekChunk = cb->end;
}
+ else dc->seekError = 1;
dc->seek = 0;
}
ret = ov_read(&vf, chunk+chunkpos,
@@ -251,7 +251,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
}
if(!dc->stop && chunkpos > 0) {
- sendDataToOutputBuffer(cb, NULL, dc, 0, chunk, chunkpos,
+ sendDataToOutputBuffer(cb, NULL, dc, inStream->seekable, chunk, chunkpos,
ov_time_tell(&vf), bitRate);
}
@@ -259,7 +259,10 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
flushOutputBuffer(cb);
- if(dc->seek) dc->seek = 0;
+ /*if(dc->seek) {
+ dc->seekError = 1;
+ dc->seek = 0;
+ }*/
if(dc->stop) {
dc->state = DECODE_STATE_STOP;
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index fb6bfe899..41932faa5 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -28,8 +28,8 @@ static mpd_sint16 currentChunk = -1;
void clearOutputBuffer(OutputBuffer * cb) {
currentChunk = -1;
- /*cb->end = cb->begin;
- cb->wrap = 0;*/
+ cb->end = cb->begin;
+ cb->wrap = 0;
}
void flushOutputBuffer(OutputBuffer * cb) {
@@ -80,7 +80,10 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
if(seekable) {
return OUTPUT_BUFFER_DC_SEEK;
}
- else dc->seek = 0;
+ else {
+ dc->seekError = 1;
+ dc->seek = 0;
+ }
}
if(!inStream ||
bufferInputStream(inStream) <= 0)