Files
itgmania212121/stepmania/src/RageSoundReader.cpp
T
Glenn Maynard 5701a25f16 Add RageSoundReader_Vorbisfile.
Remove RageSoundReader_SDL_Sound.
Fix error reporting.
2003-09-13 05:09:35 +00:00

51 lines
1.2 KiB
C++

#include "global.h"
#include "RageSoundReader.h"
#include "RageUtil.h"
#include "RageLog.h"
#ifndef NO_WAV_SUPPORT
#include "RageSoundReader_WAV.h"
#endif
#ifndef NO_MP3_SUPPORT
#include "RageSoundReader_MP3.h"
#endif
#ifndef NO_VORBIS_SUPPORT
#include "RageSoundReader_Vorbisfile.h"
#endif
SoundReader *SoundReader::OpenFile( CString filename, CString &error )
{
SoundReader_FileReader *NewSample = NULL;
/* XXX: First try based on extension. If that fails, try all other decoders.
* Optimally, we should have separate error returns indicating "this isn't
* an XXX file" vs. "this is an XXX file, but we don't support something in
* it", for better error string returns. */
#ifndef NO_WAV_SUPPORT
if( !GetExtension(filename).CompareNoCase("wav") )
NewSample = new RageSoundReader_WAV;
#endif
#ifndef NO_MP3_SUPPORT
if( !GetExtension(filename).CompareNoCase("mp3") )
NewSample = new RageSoundReader_MP3;
#endif
#ifndef NO_VORBIS_SUPPORT
if( !GetExtension(filename).CompareNoCase("ogg") )
NewSample = new RageSoundReader_Vorbisfile;
#endif
ASSERT( NewSample );
if( !NewSample->Open(filename) )
{
error = NewSample->GetError();
return NULL;
}
return NewSample;
}