X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fsounddecoder.cpp;h=ed9de800ffef84345faf133260080a9aa9eb6b96;hb=8e12e7c9f65632342a8f370ea2de6b029cb564ec;hp=a2cd51af4624154cca52312157cfb18f31a9b21e;hpb=d035e638b940f25cb5d46a049a00b34dc60dc5e0;p=libs%2Fal.git diff --git a/source/sounddecoder.cpp b/source/sounddecoder.cpp index a2cd51a..ed9de80 100644 --- a/source/sounddecoder.cpp +++ b/source/sounddecoder.cpp @@ -1,7 +1,12 @@ #include #include #include -#include "oggdecoder.h" +#ifdef WITH_LIBMAD +#include "mad/mp3decoder.h" +#endif +#ifdef WITH_LIBVORBIS +#include "vorbis/oggdecoder.h" +#endif #include "sounddecoder.h" using namespace std; @@ -39,20 +44,27 @@ SoundDecoder *SoundDecoder::open_io(IO::Seekable &io) { char sig_buf[8]; io.read(sig_buf, sizeof(sig_buf)); + io.seek(0, IO::S_BEG); string signature(sig_buf, sizeof(sig_buf)); + +#ifdef WITH_LIBVORBIS if(OggDecoder::detect(signature)) return new OggDecoder(io); - else +#endif + +#ifdef WITH_LIBMAD + if(Mp3Decoder::detect(signature)) + return new Mp3Decoder(io); +#endif + + string sig_hex; + for(unsigned i=0; i(sig_buf[i])); - } - throw unsupported_sound(sig_hex); + if(i) + sig_hex += ' '; + sig_hex += Msp::format("%02X", static_cast(sig_buf[i])); } + throw unsupported_sound(sig_hex); } } // namespace AL