]> git.tdb.fi Git - libs/al.git/blob - source/mp3decoder.h
Refactor Mp3Decoder a bit
[libs/al.git] / source / mp3decoder.h
1 #ifndef MSP_AL_MP3DECODER_H_
2 #define MSP_AL_MP3DECODER_H_
3
4 #include <stdexcept>
5 #include "sounddecoder.h"
6
7 namespace Msp {
8 namespace AL {
9
10 class mp3_error: public std::runtime_error
11 {
12 public:
13         mp3_error(const std::string &, int);
14         virtual ~mp3_error() throw() { }
15
16 private:
17         static std::string get_message(int);
18 };
19
20
21 class Mp3Decoder: public SoundDecoder
22 {
23 private:
24         struct Private;
25
26         Private *priv;
27         IO::Seekable &in;
28         unsigned in_buf_size;
29         char *in_buffer;
30         unsigned read_pos;
31
32 public:
33         Mp3Decoder(IO::Seekable &);
34         virtual ~Mp3Decoder();
35
36         static bool detect(const std::string &);
37
38         virtual void rewind();
39         virtual unsigned read(char *, unsigned);
40
41 private:
42         bool fill_input();
43         bool try_decode(bool);
44         bool decode(bool);
45 };
46
47 } // namespace AL
48 } // namespace Msp
49
50 #endif