aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-20 04:00:17 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-20 04:00:17 +0000
commit52d4200cb1f841932dc097127258c522dd018a13 (patch)
tree6368fd975d8be14d608286db2c3efcd791df3682
parent4db5224b4773c48d9699f21f8bb4629b176fe43b (diff)
downloadmpd-52d4200cb1f841932dc097127258c522dd018a13.tar.gz
mpd-52d4200cb1f841932dc097127258c522dd018a13.tar.xz
mpd-52d4200cb1f841932dc097127258c522dd018a13.zip
fix some seeking stuff for mp3's
git-svn-id: https://svn.musicpd.org/mpd/trunk@1106 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--TODO8
-rw-r--r--src/mp3_decode.c32
2 files changed, 22 insertions, 18 deletions
diff --git a/TODO b/TODO
index d80ad91ae..e36397e79 100644
--- a/TODO
+++ b/TODO
@@ -2,8 +2,7 @@
a) make seekings non-blocking:
1) player:
a) first check that seekWhere isn't already buffered
- 2) check that stream is seekable before seeking forward!
- 3) deal with seeking forward better by calling seek function
+ 2) 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
@@ -15,12 +14,11 @@
3) if not seekable, reset buffer, and elapsedTime when
unpaused
d) put some sort of error reporting for streaming/inputStream!
- e) ogg streams
- f) fetch metadata and store in DecoderControl and pass to
+ e) fetch metadata and store in DecoderControl and pass to
PlayerControl
1) eventually deal with icy-metadata
2) parse metadata on the fly in decoders
- g) command for dealing with the changing metadata, currentsonginfo
+ f) command for dealing with the changing metadata, currentsonginfo
or something
2) how to deal with streams and the db
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index 3836af8e2..c2dd1f8f4 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -55,6 +55,9 @@
#define DECODE_CONT -1
#define DECODE_OK 0
+#define MUTEFRAME_SKIP 1
+#define MUTEFRAME_SEEK 2
+
/* this is stolen from mpg321! */
struct audio_dither {
mad_fixed_t error[3];
@@ -356,7 +359,7 @@ int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc) {
if(xing.flags & XING_FRAMES) {
mad_timer_t duration = data->frame.header.duration;
mad_timer_multiply(&duration,xing.frames);
- data->muteFrame = 1;
+ data->muteFrame = MUTEFRAME_SKIP;
data->totalTime = ((float)mad_timer_count(duration,
MAD_UNITS_MILLISECONDS))/1000;
data->maxFrames = xing.frames;
@@ -429,10 +432,10 @@ int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data,
}
int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
- static int i;
- static int ret;
- static struct audio_dither dither;
- static int skip;
+ int i;
+ int ret;
+ struct audio_dither dither;
+ int skip;
if(data->currentFrame>=data->highestFrame) {
mad_timer_add(&data->timer,(data->frame).header.duration);
@@ -457,18 +460,19 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
data->currentFrame++;
data->elapsedTime = ((float)mad_timer_count(data->timer,MAD_UNITS_MILLISECONDS))/1000;
- if(data->muteFrame) {
- if(!dc->seek) data->muteFrame = 0;
- else if(dc->seekWhere<=data->elapsedTime) {
+ switch(data->muteFrame) {
+ case MUTEFRAME_SKIP:
+ data->muteFrame = 0;
+ break;
+ case MUTEFRAME_SEEK:
+ if(dc->seekWhere<=data->elapsedTime) {
clearOutputBuffer(cb);
dc->seekChunk = cb->end;
data->muteFrame = 0;
dc->seek = 0;
}
- }
- else {
- long ret;
-
+ break;
+ default:
mad_synth_frame(&data->synth,&data->frame);
for(i=0;i<(data->synth).pcm.length;i++) {
@@ -489,6 +493,7 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
}
if(data->outputPtr==data->outputBufferEnd) {
+ long ret;
ret = sendDataToOutputBuffer(cb,dc,
data->outputBuffer,
MP3_DATA_OUTPUT_BUFFER_SIZE,
@@ -506,7 +511,7 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
if(dc->seek) {
long i = 0;
- data->muteFrame = 1;
+ data->muteFrame = MUTEFRAME_SEEK;
while(i<data->highestFrame && dc->seekWhere >
((float)mad_timer_count(data->times[i],
MAD_UNITS_MILLISECONDS))/1000)
@@ -524,6 +529,7 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
}
dc->seek = 0;
}
+ else if(!data->inStream->seekable) dc->seek = 0;
}
}