X-Git-Url: http://git.tdb.fi/?p=libs%2Fal.git;a=blobdiff_plain;f=source%2Fmad%2Fmp3decoder.h;fp=source%2Fmad%2Fmp3decoder.h;h=ce0c4681f5c7fb2df67dda9c0c6d09e7600144c8;hp=0000000000000000000000000000000000000000;hb=8e12e7c9f65632342a8f370ea2de6b029cb564ec;hpb=1e7141871d33e3e184456ba063fcf3448a8cc12a diff --git a/source/mad/mp3decoder.h b/source/mad/mp3decoder.h new file mode 100644 index 0000000..ce0c468 --- /dev/null +++ b/source/mad/mp3decoder.h @@ -0,0 +1,54 @@ +#ifndef MSP_AL_MP3DECODER_H_ +#define MSP_AL_MP3DECODER_H_ + +#include +#include + +namespace Msp { +namespace AL { + +class mp3_error: public std::runtime_error +{ +public: + mp3_error(const std::string &, int); + virtual ~mp3_error() throw() { } + +private: + static std::string get_message(int); +}; + + +/** +Decoder for MPEG-2 audio files, a.k.a. MP2 and MP3 files. Normally you should +use one of the SoundDecoder::open_* functions to create a decoder. +*/ +class Mp3Decoder: public SoundDecoder +{ +private: + struct Private; + + Private *priv; + IO::Seekable ∈ + unsigned in_buf_size; + char *in_buffer; + unsigned read_pos; + +public: + Mp3Decoder(IO::Seekable &); + virtual ~Mp3Decoder(); + + static bool detect(const std::string &); + + virtual void seek(unsigned); + virtual unsigned read(char *, unsigned); + +private: + bool fill_input(); + bool try_decode(bool); + bool decode(bool); +}; + +} // namespace AL +} // namespace Msp + +#endif