moved a check from the sound class in the sound base class
This commit is contained in:
parent
914e41fac3
commit
8bbc9adaa3
2 changed files with 36 additions and 33 deletions
|
@ -132,11 +132,18 @@ void CSoundBase::run()
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
QString CSoundBase::SetDev ( const int iNewDev )
|
QString CSoundBase::SetDev ( const int iNewDev )
|
||||||
{
|
{
|
||||||
QString strReturn = ""; // init with no error
|
// init return parameter with "no error"
|
||||||
bool bTryLoadAnyDriver = false;
|
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
|
// 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
|
// a device was already been initialized and is used, first clean up
|
||||||
// driver
|
// driver
|
||||||
|
@ -175,6 +182,9 @@ QString CSoundBase::SetDev ( const int iNewDev )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// init flag for "load any driver"
|
||||||
|
bool bTryLoadAnyDriver = false;
|
||||||
|
|
||||||
if ( iNewDev != INVALID_SNC_CARD_DEVICE )
|
if ( iNewDev != INVALID_SNC_CARD_DEVICE )
|
||||||
{
|
{
|
||||||
// This is the first time a driver is to be initialized, we first
|
// This is the first time a driver is to be initialized, we first
|
||||||
|
@ -195,31 +205,31 @@ QString CSoundBase::SetDev ( const int iNewDev )
|
||||||
// try to find one usable driver (select the first valid driver)
|
// try to find one usable driver (select the first valid driver)
|
||||||
bTryLoadAnyDriver = true;
|
bTryLoadAnyDriver = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( bTryLoadAnyDriver )
|
if ( bTryLoadAnyDriver )
|
||||||
{
|
|
||||||
// try to load and initialize any valid driver
|
|
||||||
QVector<QString> vsErrorList =
|
|
||||||
LoadAndInitializeFirstValidDriver();
|
|
||||||
|
|
||||||
if ( !vsErrorList.isEmpty() )
|
|
||||||
{
|
{
|
||||||
// create error message with all details
|
// try to load and initialize any valid driver
|
||||||
QString sErrorMessage = tr ( "<b>No usable " ) +
|
QVector<QString> vsErrorList =
|
||||||
strSystemDriverTechniqueName + tr ( " audio device "
|
LoadAndInitializeFirstValidDriver();
|
||||||
"(driver) found.</b><br><br>"
|
|
||||||
"In the following there is a list of all available drivers "
|
|
||||||
"with the associated error message:<ul>" );
|
|
||||||
|
|
||||||
for ( int i = 0; i < lNumDevs; i++ )
|
if ( !vsErrorList.isEmpty() )
|
||||||
{
|
{
|
||||||
sErrorMessage += "<li><b>" + GetDeviceName ( i ) + "</b>: " +
|
// create error message with all details
|
||||||
vsErrorList[i] + "</li>";
|
QString sErrorMessage = tr ( "<b>No usable " ) +
|
||||||
}
|
strSystemDriverTechniqueName + tr ( " audio device "
|
||||||
sErrorMessage += "</ul>";
|
"(driver) found.</b><br><br>"
|
||||||
|
"In the following there is a list of all available drivers "
|
||||||
|
"with the associated error message:<ul>" );
|
||||||
|
|
||||||
throw CGenErr ( sErrorMessage );
|
for ( int i = 0; i < lNumDevs; i++ )
|
||||||
|
{
|
||||||
|
sErrorMessage += "<li><b>" + GetDeviceName ( i ) + "</b>: " +
|
||||||
|
vsErrorList[i] + "</li>";
|
||||||
|
}
|
||||||
|
sErrorMessage += "</ul>";
|
||||||
|
|
||||||
|
throw CGenErr ( sErrorMessage );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,6 @@ CSound* pSound;
|
||||||
\******************************************************************************/
|
\******************************************************************************/
|
||||||
QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
|
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
|
// load driver
|
||||||
loadAsioDriver ( cDriverNames[iDriverIdx] );
|
loadAsioDriver ( cDriverNames[iDriverIdx] );
|
||||||
if ( ASIOInit ( &driverInfo ) != ASE_OK )
|
if ( ASIOInit ( &driverInfo ) != ASE_OK )
|
||||||
|
@ -82,7 +75,7 @@ QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
|
||||||
|
|
||||||
void CSound::UnloadCurrentDriver()
|
void CSound::UnloadCurrentDriver()
|
||||||
{
|
{
|
||||||
// cleanup ASIO stuff
|
// clean up ASIO stuff
|
||||||
ASIOStop();
|
ASIOStop();
|
||||||
ASIODisposeBuffers();
|
ASIODisposeBuffers();
|
||||||
ASIOExit();
|
ASIOExit();
|
||||||
|
@ -439,8 +432,8 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ),
|
||||||
strDriverNames[i] = cDriverNames[i];
|
strDriverNames[i] = cDriverNames[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// init device index with illegal value to show that driver is not initialized
|
// init device index as not initialized (invalid)
|
||||||
lCurDev = -1;
|
lCurDev = INVALID_SNC_CARD_DEVICE;
|
||||||
|
|
||||||
// init channel mapping
|
// init channel mapping
|
||||||
ResetChannelMapping();
|
ResetChannelMapping();
|
||||||
|
|
Loading…
Reference in a new issue