]> git.tdb.fi Git - libs/al.git/blob - source/sounddecoder.h
7a08644117317623d629b88559788036b5f16e8b
[libs/al.git] / source / sounddecoder.h
1 #ifndef MSP_AL_SOUNDDECODER_H_
2 #define MSP_AL_SOUNDDECODER_H_
3
4 #include <string>
5 #include <msp/io/seekable.h>
6 #include "format.h"
7
8 namespace Msp {
9 namespace AL {
10
11 /**
12 This class facilitates loading sound files.  Currently only Ogg Vorbis is
13 supported.
14 */
15 class SoundDecoder
16 {
17 private:
18         IO::Seekable *source;
19 protected:
20         unsigned freq;
21         unsigned size;
22         Format format;
23         bool eof_flag;
24
25         SoundDecoder();
26 public:
27         virtual ~SoundDecoder();
28
29         static SoundDecoder *open_file(const std::string &);
30         static SoundDecoder *open_io(IO::Seekable &);
31
32         virtual void rewind() = 0;
33         virtual unsigned read(char *, unsigned) = 0;
34         bool eof() const { return eof_flag; }
35
36         Format get_format() const { return format; }
37         unsigned get_frequency() const { return freq; }
38         unsigned get_size() const { return size; }
39 };
40
41 } // namespace AL
42 } // namespace Msp
43
44 #endif