]> git.tdb.fi Git - libs/al.git/blobdiff - source/mp3decoder.h
Add support for MP3 files using libmad
[libs/al.git] / source / mp3decoder.h
diff --git a/source/mp3decoder.h b/source/mp3decoder.h
new file mode 100644 (file)
index 0000000..06060de
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef MSP_AL_MP3DECODER_H_
+#define MSP_AL_MP3DECODER_H_
+
+#include <stdexcept>
+#include "sounddecoder.h"
+
+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);
+};
+
+
+class Mp3Decoder: public SoundDecoder
+{
+private:
+       struct Private;
+
+       Private *priv;
+       IO::Seekable &in;
+       unsigned in_buf_size;
+       char *in_buffer;
+       unsigned read_pos;
+
+public:
+       Mp3Decoder(IO::Seekable &);
+       virtual ~Mp3Decoder();
+
+       static bool detect(const std::string &);
+
+       virtual void rewind();
+       virtual unsigned read(char *, unsigned);
+
+private:
+       bool fill_input();
+       bool decode_frame();
+};
+
+} // namespace AL
+} // namespace Msp
+
+#endif