+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-variable"
#include <vorbis/vorbisfile.h>
+#pragma GCC diagnostic pop
#include <msp/strings/format.h>
#include "oggdecoder.h"
vorbis_info *info = ov_info(&priv->ovfile, -1);
freq = info->rate;
+ format = create_format(2, info->channels);
- size = ov_pcm_total(&priv->ovfile, 0)*info->channels*2;
-
- switch(info->channels)
- {
- case 1: format = MONO16; break;
- case 2: format = STEREO16; break;
- default: throw unsupported_sound(Msp::format("%d channels", info->channels));
- }
+ size = ov_pcm_total(&priv->ovfile, 0)*get_unit_size(format);
}
OggDecoder::~OggDecoder()
delete priv;
}
+bool OggDecoder::detect(const std::string &sig)
+{
+ static const char ogg_sig[] = { 'O', 'g', 'g', 'S' };
+ if(sig.size()<sizeof(ogg_sig))
+ return false;
+ return !sig.compare(0, sizeof(ogg_sig), ogg_sig);
+}
+
void OggDecoder::rewind()
{
ov_pcm_seek(&priv->ovfile, 0);