]> git.tdb.fi Git - libs/al.git/blob - source/mp3decoder.h
Fix sound file signature comparisons
[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 /**
22 Decoder for MPEG-2 audio files, a.k.a. MP2 and MP3 files.  Normally you should
23 use one of the SoundDecoder::open_* functions to create a decoder.
24 */
25 class Mp3Decoder: public SoundDecoder
26 {
27 private:
28         struct Private;
29
30         Private *priv;
31         IO::Seekable &in;
32         unsigned in_buf_size;
33         char *in_buffer;
34         unsigned read_pos;
35
36 public:
37         Mp3Decoder(IO::Seekable &);
38         virtual ~Mp3Decoder();
39
40         static bool detect(const std::string &);
41
42         virtual void seek(unsigned);
43         virtual unsigned read(char *, unsigned);
44
45 private:
46         bool fill_input();
47         bool try_decode(bool);
48         bool decode(bool);
49 };
50
51 } // namespace AL
52 } // namespace Msp
53
54 #endif