aboutsummaryrefslogtreecommitdiffstats
path: root/src/mp3_decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-03-24 02:26:57 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-03-24 02:26:57 +0000
commit0977ab5b4e57111a0258f33075069aa834628af0 (patch)
tree2faed1e117dd571e5e9c2726e1d089b2615a893f /src/mp3_decode.c
parent7479bfacbb5743357bf02a64034093c81d806e13 (diff)
downloadmpd-0977ab5b4e57111a0258f33075069aa834628af0.tar.gz
mpd-0977ab5b4e57111a0258f33075069aa834628af0.tar.xz
mpd-0977ab5b4e57111a0258f33075069aa834628af0.zip
calculate song length more accurately
git-svn-id: https://svn.musicpd.org/mpd/trunk@444 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/mp3_decode.c')
-rw-r--r--src/mp3_decode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index d31db2e86..e2bf2f6bf 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -343,11 +343,18 @@ int decodeFirstFrame(mp3DecodeData * data) {
}
}
else {
+ size_t offset = data->currentOffset;
mad_timer_t duration = data->frame.header.duration;
float frameTime = ((float)mad_timer_count(duration,
MAD_UNITS_MILLISECONDS))/1000;
fstat(fileno(data->fp),&filestat);
- data->totalTime = (filestat.st_size*8.0)/
+ if(data->stream.this_frame!=NULL) {
+ offset-= data->stream.bufend-data->stream.this_frame;
+ }
+ else {
+ offset-= data->stream.bufend-data->stream.buffer;
+ }
+ data->totalTime = ((filestat.st_size-offset)*8.0)/
(data->frame).header.bitrate;
data->maxFrames = data->totalTime/frameTime+FRAMES_CUSHION;
}