1 #include <msp/core/refptr.h>
2 #include <msp/io/file.h>
3 #include <msp/strings/format.h>
4 #include "oggdecoder.h"
5 #include "sounddecoder.h"
12 unsupported_sound::unsupported_sound(const string &w):
17 SoundDecoder::SoundDecoder():
25 SoundDecoder::~SoundDecoder()
30 SoundDecoder *SoundDecoder::open_file(const string &fn)
32 RefPtr<IO::BufferedFile> file = new IO::BufferedFile(fn);
33 SoundDecoder *decoder = open_io(*file);
34 decoder->source = file.release();
38 SoundDecoder *SoundDecoder::open_io(IO::Seekable &io)
41 io.read(sig_buf, sizeof(sig_buf));
42 string signature(sig_buf, sizeof(sig_buf));
43 if(OggDecoder::detect(signature))
44 return new OggDecoder(io);
48 for(unsigned i=0; i<sizeof(sig_buf); ++i)
52 sig_hex += Msp::format("%02X", static_cast<unsigned char>(sig_buf[i]));
54 throw unsupported_sound(sig_hex);