Handle the wav -> mp3 extension conversion in the sound output backend

This commit is contained in:
Chris Robinson 2012-03-21 22:49:40 -07:00
parent f11e3e39a1
commit 15317796bf
3 changed files with 13 additions and 23 deletions

View file

@ -238,17 +238,7 @@ size_t FFmpeg_Decoder::MyStream::readAVAudioData(void *data, size_t length)
void FFmpeg_Decoder::open(const std::string &fname)
{
close();
try
{
mDataStream = mResourceMgr.openResource(fname);
}
catch(Ogre::Exception &e)
{
std::string::size_type pos = fname.rfind('.');
if(pos == std::string::npos)
throw;
mDataStream = mResourceMgr.openResource(fname.substr(0, pos)+".mp3");
}
if((mFormatCtx=avformat_alloc_context()) == NULL)
fail("Failed to allocate context");

View file

@ -81,17 +81,7 @@ off_t MpgSnd_Decoder::ogrempg_lseek(void *user_data, off_t offset, int whence)
void MpgSnd_Decoder::open(const std::string &fname)
{
close();
try
{
mDataStream = mResourceMgr.openResource(fname);
}
catch(Ogre::Exception &e)
{
std::string::size_type pos = fname.rfind('.');
if(pos == std::string::npos)
throw;
mDataStream = mResourceMgr.openResource(fname.substr(0, pos)+".mp3");
}
SF_VIRTUAL_IO streamIO = {
ogresf_get_filelen, ogresf_seek,

View file

@ -465,7 +465,17 @@ ALuint OpenAL_Output::getBuffer(const std::string &fname)
int srate;
DecoderPtr decoder = mManager.getDecoder();
try
{
decoder->open(fname);
}
catch(Ogre::FileNotFoundException &e)
{
std::string::size_type pos = fname.rfind('.');
if(pos == std::string::npos)
throw;
decoder->open(fname.substr(0, pos)+".mp3");
}
decoder->getInfo(&srate, &chans, &type);
format = getALFormat(chans, type);