moved a check from the sound class in the sound base class

This commit is contained in:
Volker Fischer 2011-12-07 20:18:56 +00:00
parent 914e41fac3
commit 8bbc9adaa3
2 changed files with 36 additions and 33 deletions

View file

@ -132,11 +132,18 @@ void CSoundBase::run()
\******************************************************************************/
QString CSoundBase::SetDev ( const int iNewDev )
{
QString strReturn = ""; // init with no error
bool bTryLoadAnyDriver = false;
// init return parameter with "no error"
QString strReturn = "";
// first check if valid input parameter
if ( iNewDev >= lNumDevs )
{
// we should actually never get here...
return tr ( "Invalid device selection." );
}
// check if an ASIO driver was already initialized
if ( lCurDev >= 0 )
if ( lCurDev != INVALID_SNC_CARD_DEVICE )
{
// a device was already been initialized and is used, first clean up
// driver
@ -175,6 +182,9 @@ QString CSoundBase::SetDev ( const int iNewDev )
}
else
{
// init flag for "load any driver"
bool bTryLoadAnyDriver = false;
if ( iNewDev != INVALID_SNC_CARD_DEVICE )
{
// This is the first time a driver is to be initialized, we first
@ -195,7 +205,6 @@ QString CSoundBase::SetDev ( const int iNewDev )
// try to find one usable driver (select the first valid driver)
bTryLoadAnyDriver = true;
}
}
if ( bTryLoadAnyDriver )
{
@ -222,6 +231,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
throw CGenErr ( sErrorMessage );
}
}
}
return strReturn;
}

View file

@ -42,13 +42,6 @@ CSound* pSound;
\******************************************************************************/
QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
{
// first check and correct input parameter
if ( iDriverIdx >= lNumDevs )
{
// we assume here that at least one driver is in the system
iDriverIdx = 0;
}
// load driver
loadAsioDriver ( cDriverNames[iDriverIdx] );
if ( ASIOInit ( &driverInfo ) != ASE_OK )
@ -439,8 +432,8 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ),
strDriverNames[i] = cDriverNames[i];
}
// init device index with illegal value to show that driver is not initialized
lCurDev = -1;
// init device index as not initialized (invalid)
lCurDev = INVALID_SNC_CARD_DEVICE;
// init channel mapping
ResetChannelMapping();