X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsounddecoder.h;h=ee5b07d5f33abea2410dc95076f026c0586a1ffc;hb=35b092aaa718dcb12933effd33324bda5d3b5cce;hp=ad56646b30dc149c9bfe48ef3fb243f3d811121f;hpb=6cc0f1735a00e8f9eb80ff0c9468fb67205f6d20;p=libs%2Fal.git diff --git a/source/sounddecoder.h b/source/sounddecoder.h index ad56646..ee5b07d 100644 --- a/source/sounddecoder.h +++ b/source/sounddecoder.h @@ -1,13 +1,21 @@ -#ifndef MSP_AL_SOUND_H_ -#define MSP_AL_SOUND_H_ +#ifndef MSP_AL_SOUNDDECODER_H_ +#define MSP_AL_SOUNDDECODER_H_ #include -#include +#include #include "format.h" namespace Msp { namespace AL { +class unsupported_sound: public std::runtime_error +{ +public: + unsupported_sound(const std::string &); + virtual ~unsupported_sound() throw() { } +}; + + /** This class facilitates loading sound files. Currently only Ogg Vorbis is supported. @@ -15,24 +23,22 @@ supported. class SoundDecoder { private: - OggVorbis_File ovfile; + IO::Seekable *source; +protected: unsigned freq; unsigned size; Format format; bool eof_flag; -public: SoundDecoder(); - ~SoundDecoder(); - - void open_file(const std::string &); - void open_memory(const void *, unsigned); -private: - void open_common(); public: - void close(); - void rewind(); - unsigned read(char *, unsigned); + virtual ~SoundDecoder(); + + static SoundDecoder *open_file(const std::string &); + static SoundDecoder *open_io(IO::Seekable &); + + virtual void rewind() = 0; + virtual unsigned read(char *, unsigned) = 0; bool eof() const { return eof_flag; } Format get_format() const { return format; }