diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-03-24 02:23:40 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-03-24 02:23:40 +0000 |
commit | 7479bfacbb5743357bf02a64034093c81d806e13 (patch) | |
tree | 7cde3138d6efa3bc82bfbbb9660a85421d3059e8 | |
parent | 9b38a1e63e7efc40a85b5a0e1648a58eb3524ce5 (diff) | |
download | mpd-7479bfacbb5743357bf02a64034093c81d806e13.tar.gz mpd-7479bfacbb5743357bf02a64034093c81d806e13.tar.xz mpd-7479bfacbb5743357bf02a64034093c81d806e13.zip |
bitRate support for audiofile
git-svn-id: https://svn.musicpd.org/mpd/trunk@443 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/audiofile_decode.c | 17 | ||||
-rw-r--r-- | src/mp3_decode.c | 4 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/audiofile_decode.c b/src/audiofile_decode.c index 9889fbf2f..595c9cea2 100644 --- a/src/audiofile_decode.c +++ b/src/audiofile_decode.c @@ -32,6 +32,9 @@ #include <unistd.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <audiofile.h> int getAudiofileTotalTime(char * file) @@ -53,10 +56,17 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) int fs, frame_count; AFfilehandle af_fp; int bits; - + mpd_uint16 bitRate; + struct stat st; + + if(stat(dc->file,&st) < 0) { + ERROR("failed to stat: %s\n",dc->file); + return -1; + } + af_fp = afOpenFile(dc->file,"r", NULL); if(af_fp == AF_NULL_FILEHANDLE) { - ERROR("failed to open %s\n",dc->file); + ERROR("failed to open: %s\n",dc->file); return -1; } @@ -68,6 +78,8 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) frame_count = afGetFrameCount(af_fp,AF_DEFAULT_TRACK); cb->totalTime = ((float)frame_count/(float)af->sampleRate); + + bitRate = st.st_size*8.0/cb->totalTime/1024.0+0.5; if (af->bits != 8 && af->bits != 16) { ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n", @@ -110,6 +122,7 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc) current += ret; cb->times[cb->end] = (float)current/(float)af->sampleRate; + cb->bitRate[cb->end] = bitRate; ++cb->end; diff --git a/src/mp3_decode.c b/src/mp3_decode.c index ed108c37b..d31db2e86 100644 --- a/src/mp3_decode.c +++ b/src/mp3_decode.c @@ -190,7 +190,9 @@ int decodeNextFrameHeader(mp3DecodeData * data) { } if(mad_header_decode(&data->frame.header,&data->stream)) { #ifdef HAVE_ID3TAG - if((data->stream).error==MAD_ERROR_LOSTSYNC) { + if((data->stream).error==MAD_ERROR_LOSTSYNC && + (data->stream).this_frame) + { signed long tagsize = id3_tag_query( (data->stream).this_frame, (data->stream).bufend- |