add RageDriver to merge duplicate boilerplate code
This commit is contained in:
@@ -4,14 +4,11 @@
|
||||
#include "RageUtil.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
map<istring, CreateSoundDriverFn> *RegisterSoundDriver::g_pRegistrees;
|
||||
RegisterSoundDriver::RegisterSoundDriver( const istring &sName, CreateSoundDriverFn pfn )
|
||||
static DriverList g_pRegistrees;
|
||||
|
||||
RegisterSoundDriver::RegisterSoundDriver( const istring &sName, CreateRageDriverFn pfn )
|
||||
{
|
||||
if( g_pRegistrees == NULL )
|
||||
g_pRegistrees = new map<istring, CreateSoundDriverFn>;
|
||||
|
||||
ASSERT( g_pRegistrees->find(sName) == g_pRegistrees->end() );
|
||||
(*g_pRegistrees)[sName] = pfn;
|
||||
g_pRegistrees.Add( sName, pfn );
|
||||
}
|
||||
|
||||
RageSoundDriver *MakeRageSoundDriver( const RString &drivers )
|
||||
@@ -21,18 +18,17 @@ RageSoundDriver *MakeRageSoundDriver( const RString &drivers )
|
||||
|
||||
FOREACH_CONST( RString, DriversToTry, Driver )
|
||||
{
|
||||
map<istring, CreateSoundDriverFn>::const_iterator iter = RegisterSoundDriver::g_pRegistrees->find( istring(*Driver) );
|
||||
|
||||
if( iter == RegisterSoundDriver::g_pRegistrees->end() )
|
||||
RageDriver *pDriver = g_pRegistrees.Create( *Driver );
|
||||
if( pDriver == NULL )
|
||||
{
|
||||
LOG->Trace( "Unknown sound driver: %s", Driver->c_str() );
|
||||
continue;
|
||||
}
|
||||
|
||||
RageSoundDriver *pRet = (iter->second)();
|
||||
DEBUG_ASSERT( pRet );
|
||||
|
||||
RageSoundDriver *pRet = dynamic_cast<RageSoundDriver *>( pDriver );
|
||||
ASSERT( pRet != NULL );
|
||||
|
||||
const RString sError = pRet->Init();
|
||||
|
||||
if( sError.empty() )
|
||||
{
|
||||
LOG->Info( "Sound driver: %s", Driver->c_str() );
|
||||
|
||||
Reference in New Issue
Block a user