add SoundReader::OpenFile

This commit is contained in:
Glenn Maynard
2003-09-10 21:34:01 +00:00
parent 984c6d4b7c
commit b9efc67d02
2 changed files with 42 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
#include "global.h"
#include "RageSoundReader.h"
#include "RageUtil.h"
#ifndef NO_WAV_SUPPORT
#include "RageSoundReader_WAV.h"
#endif
#if defined(OGG_ONLY)
#include "RageSoundReader_Vorbisfile.h"
#define RageSoundReader_LowLevel RageSoundReader_Vorbisfile
#else
#include "RageSoundReader_SDL_Sound.h"
#define RageSoundReader_LowLevel SoundReader_SDL_Sound
#endif
SoundReader *SoundReader::OpenFile( CString filename, CString error )
{
SoundReader_FileReader *NewSample = NULL;
/* 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
if( NewSample == NULL )
NewSample = new RageSoundReader_LowLevel;
if( !NewSample->Open(filename) )
{
error = NewSample->GetError();
return NULL;
}
return NewSample;
}
+1
View File
@@ -21,6 +21,7 @@ public:
bool Error() const { return !error.empty(); }
string GetError() const { return error; }
static SoundReader *OpenFile( CString filename, CString error );
};
#endif