try to fix Misconfigured ASIO4ALL config can't be corrected #117

This commit is contained in:
Volker Fischer 2020-04-20 19:57:21 +02:00
parent ee014bbd83
commit 00b11ee06a
6 changed files with 38 additions and 16 deletions

View File

@ -300,7 +300,7 @@ int CSound::CountChannels ( AudioDeviceID devID,
return result;
}
QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
QString CSound::LoadAndInitializeDriver ( int iDriverIdx, bool )
{
// check device capabilities if it fullfills our requirements
const QString strStat = CheckDeviceCapabilities ( iDriverIdx );

View File

@ -75,7 +75,7 @@ public:
int iSelOutputRightChannel;
protected:
virtual QString LoadAndInitializeDriver ( int iIdx );
virtual QString LoadAndInitializeDriver ( int iIdx, bool );
QString CheckDeviceCapabilities ( const int iDriverIdx );
int CountChannels ( AudioDeviceID devID,

View File

@ -124,7 +124,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
// driver
UnloadCurrentDriver();
const QString strErrorMessage = LoadAndInitializeDriver ( iNewDev );
const QString strErrorMessage = LoadAndInitializeDriver ( iNewDev, false );
if ( !strErrorMessage.isEmpty() )
{
@ -132,7 +132,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
{
// loading and initializing the new driver failed, go back to
// original driver and display error message
LoadAndInitializeDriver ( lCurDev );
LoadAndInitializeDriver ( lCurDev, false );
}
else
{
@ -167,7 +167,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
// the first available driver in the system. If this fails, too, we
// throw an error that no driver is available -> it does not make
// sense to start the software if no audio hardware is available.
if ( !LoadAndInitializeDriver ( iNewDev ).isEmpty() )
if ( !LoadAndInitializeDriver ( iNewDev, false ).isEmpty() )
{
// loading and initializing the new driver failed, try to find
// at least one usable driver
@ -183,8 +183,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
if ( bTryLoadAnyDriver )
{
// try to load and initialize any valid driver
QVector<QString> vsErrorList =
LoadAndInitializeFirstValidDriver();
QVector<QString> vsErrorList = LoadAndInitializeFirstValidDriver();
if ( !vsErrorList.isEmpty() )
{
@ -201,6 +200,20 @@ QString CSoundBase::SetDev ( const int iNewDev )
}
sErrorMessage += "</ul>";
#ifdef _WIN32
// to be able to access the ASIO driver setup for changing, e.g., the sample rate, we
// offer the user under Windows that we open the driver setups of all registered
// ASIO drivers
sErrorMessage = sErrorMessage + tr ( "<br/>Do you want to open the ASIO driver setups?" );
if ( QMessageBox::Yes == QMessageBox::information ( nullptr, APP_NAME, sErrorMessage, QMessageBox::Yes|QMessageBox::No ) )
{
LoadAndInitializeFirstValidDriver ( true );
}
sErrorMessage = APP_NAME + tr ( " could not be started because of audio interface issues." );
#endif
throw CGenErr ( sErrorMessage );
}
}
@ -209,7 +222,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
return strReturn;
}
QVector<QString> CSoundBase::LoadAndInitializeFirstValidDriver()
QVector<QString> CSoundBase::LoadAndInitializeFirstValidDriver ( const bool bOpenDriverSetup )
{
QVector<QString> vsErrorList;
@ -221,7 +234,7 @@ QVector<QString> CSoundBase::LoadAndInitializeFirstValidDriver()
while ( !bValidDriverDetected && ( iCurDriverIdx < lNumDevs ) )
{
// try to load and initialize current driver, store error message
const QString strCurError = LoadAndInitializeDriver ( iCurDriverIdx );
const QString strCurError = LoadAndInitializeDriver ( iCurDriverIdx, bOpenDriverSetup );
vsErrorList.append ( strCurError );

View File

@ -94,9 +94,9 @@ public:
protected:
// driver handling
virtual QString LoadAndInitializeDriver ( int ) { return ""; }
virtual QString LoadAndInitializeDriver ( int, bool ) { return ""; }
virtual void UnloadCurrentDriver() {}
QVector<QString> LoadAndInitializeFirstValidDriver();
QVector<QString> LoadAndInitializeFirstValidDriver ( const bool bOpenDriverSetup = false );
// function pointer to callback function
void (*fpProcessCallback) ( CVector<int16_t>& psData, void* arg );

View File

@ -40,7 +40,8 @@ CSound* pSound;
/******************************************************************************\
* Common *
\******************************************************************************/
QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
QString CSound::LoadAndInitializeDriver ( int iDriverIdx,
bool bOpenDriverSetup )
{
// load driver
loadAsioDriver ( cDriverNames[iDriverIdx] );
@ -67,6 +68,13 @@ QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
}
else
{
// if requested, open ASIO driver setup in case of an error
if ( bOpenDriverSetup )
{
OpenDriverSetup();
QMessageBox::question ( nullptr, APP_NAME, "Are you done with your ASIO driver settings of device " + GetDeviceName ( iDriverIdx ) + "?", QMessageBox::Yes );
}
// driver cannot be used, clean up
asioDrivers->removeCurrentDriver();
}
@ -480,12 +488,12 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* a
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect) :
CSoundBase ( "ASIO", true, fpNewCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ),
vSelectedInputChannels ( NUM_IN_OUT_CHANNELS ),
vSelectedOutputChannels ( NUM_IN_OUT_CHANNELS ),
lNumInChan ( 0 ),
lNumInChanPlusAddChan ( 0 ),
lNumOutChan ( 0 ),
dInOutLatencyMs ( 0.0 ) // "0.0" means that no latency value is available
dInOutLatencyMs ( 0.0 ), // "0.0" means that no latency value is available
vSelectedInputChannels ( NUM_IN_OUT_CHANNELS ),
vSelectedOutputChannels ( NUM_IN_OUT_CHANNELS )
{
int i;

View File

@ -76,7 +76,8 @@ public:
virtual double GetInOutLatencyMs() { return dInOutLatencyMs; }
protected:
virtual QString LoadAndInitializeDriver ( int iIdx );
virtual QString LoadAndInitializeDriver ( int iIdx,
bool bOpenDriverSetup );
virtual void UnloadCurrentDriver();
int GetActualBufferSize ( const int iDesiredBufferSizeMono );
QString CheckDeviceCapabilities();