X-Git-Url: http://git.tdb.fi/?p=libs%2Fal.git;a=blobdiff_plain;f=source%2Fsounddecoder.h;fp=source%2Fsounddecoder.h;h=20b9d0fb7f4e3d6afa4bd2d9a3dc8806e5477c5e;hp=37fddac2ee34c8881163c30a875d451c7429d473;hb=d71db75062556dc2aea073a33e0e102894b6dfa5;hpb=d365c5394308740f478fbdfbb23e2c5d972f19f0 diff --git a/source/sounddecoder.h b/source/sounddecoder.h index 37fddac..20b9d0f 100644 --- a/source/sounddecoder.h +++ b/source/sounddecoder.h @@ -17,8 +17,7 @@ public: /** -This class facilitates loading sound files. Currently only Ogg Vorbis is -supported. +Base class for sound decoders. */ class SoundDecoder { @@ -34,16 +33,29 @@ protected: public: virtual ~SoundDecoder(); + /** Opens a file and creates a decoder of an appropriate type for it. */ static SoundDecoder *open_file(const std::string &); + + /** Creates a decoder for an already-opened audio file. */ static SoundDecoder *open_io(IO::Seekable &); + /** Restarts decoding from the beginning of the file. */ virtual void rewind() { seek(0); } + + /** Sets decoding position expressed in PCM bytes. This may involve seeking + to the beginning and skipping until the desired position is reached.*/ virtual void seek(unsigned) = 0; + + /** Reads decoded sound data. Length is specified in bytes. */ virtual unsigned read(char *, unsigned) = 0; + bool eof() const { return eof_flag; } Format get_format() const { return format; } unsigned get_frequency() const { return freq; } + + /** Returns the total length of the sound data in bytes. Some decoders may + not be able to provide this information. */ unsigned get_size() const { return size; } };