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()
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);
+ return !sig.compare(0, sizeof(ogg_sig), ogg_sig, sizeof(ogg_sig));
}
-void OggDecoder::rewind()
+void OggDecoder::seek(unsigned pos)
{
- ov_pcm_seek(&priv->ovfile, 0);
+ pos /= get_unit_size(format);
+ ov_pcm_seek(&priv->ovfile, pos);
}
unsigned OggDecoder::read(char *buf, unsigned len)