]> git.tdb.fi Git - libs/al.git/blob - source/sounddecoder.cpp
Add dedicated exception classes for decoding sounds
[libs/al.git] / source / sounddecoder.cpp
1 #include <msp/core/refptr.h>
2 #include <msp/io/file.h>
3 #include "oggdecoder.h"
4 #include "sounddecoder.h"
5
6 using namespace std;
7
8 namespace Msp {
9 namespace AL {
10
11 unsupported_sound::unsupported_sound(const string &w):
12         runtime_error(w)
13 { }
14
15
16 SoundDecoder::SoundDecoder():
17         source(0),
18         freq(0),
19         size(0),
20         format(MONO8),
21         eof_flag(false)
22 { }
23
24 SoundDecoder::~SoundDecoder()
25 {
26         delete source;
27 }
28
29 SoundDecoder *SoundDecoder::open_file(const string &fn)
30 {
31         RefPtr<IO::BufferedFile> file = new IO::BufferedFile(fn);
32         SoundDecoder *decoder = new OggDecoder(*file);
33         decoder->source = file.release();
34         return decoder;
35 }
36
37 SoundDecoder *SoundDecoder::open_io(IO::Seekable &io)
38 {
39         return new OggDecoder(io);
40 }
41
42 } // namespace AL
43 } // namespace Msp