Cleanup creating decoders

This commit is contained in:
Chris Robinson 2014-06-19 22:46:46 -07:00
parent 9f493fca5f
commit e2708c8b3e

View file

@ -543,22 +543,19 @@ SoundDecoder *SoundRenderer::CreateDecoder(const BYTE *sfxdata, int length)
SoundDecoder *decoder = NULL; SoundDecoder *decoder = NULL;
#ifdef HAVE_MPG123 #ifdef HAVE_MPG123
decoder = new MPG123Decoder; decoder = new MPG123Decoder;
if(!decoder->open((const char*)sfxdata, length)) if(decoder->open((const char*)sfxdata, length))
{ return decoder;
delete decoder; delete decoder;
decoder = NULL; decoder = NULL;
}
#endif #endif
#ifdef HAVE_SNDFILE #ifdef HAVE_SNDFILE
if(!decoder)
{
decoder = new SndFileDecoder; decoder = new SndFileDecoder;
if(!decoder->open((const char*)sfxdata, length)) if(decoder->open((const char*)sfxdata, length))
{ return decoder;
delete decoder; delete decoder;
decoder = NULL; decoder = NULL;
}
}
#endif #endif
return decoder; return decoder;
} }
@ -568,19 +565,19 @@ SoundDecoder* SoundRenderer::CreateDecoder(const char *fname, int offset, int le
SoundDecoder *decoder = NULL; SoundDecoder *decoder = NULL;
#ifdef HAVE_MPG123 #ifdef HAVE_MPG123
decoder = new MPG123Decoder; decoder = new MPG123Decoder;
if(!decoder->open(fname, offset, length)) if(decoder->open(fname, offset, length))
{ return decoder;
delete decoder; delete decoder;
decoder = NULL; decoder = NULL;
}
#endif #endif
#ifdef HAVE_SNDFILE #ifdef HAVE_SNDFILE
decoder = new SndFileDecoder; decoder = new SndFileDecoder;
if(!decoder->open(fname, offset, length)) if(decoder->open(fname, offset, length))
{ return decoder;
delete decoder; delete decoder;
decoder = NULL; decoder = NULL;
}
#endif #endif
return decoder; return decoder;
} }