X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmp3decoder.cpp;h=cc3235683db098cc5782ef11ba2b7094678f9bb1;hb=1e7141871d33e3e184456ba063fcf3448a8cc12a;hp=ec08be7f9a5969bfe2ee67ad81f4a1eb5adf6bbd;hpb=85914b1843bd89ca94a722cc26e572089dbd0774;p=libs%2Fal.git diff --git a/source/mp3decoder.cpp b/source/mp3decoder.cpp index ec08be7..cc32356 100644 --- a/source/mp3decoder.cpp +++ b/source/mp3decoder.cpp @@ -84,12 +84,35 @@ bool Mp3Decoder::detect(const string &sig) static const char id3_sig[] = { 'I', 'D', '3' }; if(sig.size()stream, 0, 0); + fill_input(); + if(!pos) + { + priv->synth.pcm.length = 0; + return; + } + + while(decode(false)) + { + unsigned frame_len = 32*MAD_NSBSAMPLES(&priv->frame.header); + if(frame_len>pos) + { + decode(true); + read_pos = pos; + break; + } + + pos -= frame_len; + } } unsigned Mp3Decoder::read(char *buf, unsigned len)