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; return result;
} }
QString CSound::LoadAndInitializeDriver ( int iDriverIdx ) QString CSound::LoadAndInitializeDriver ( int iDriverIdx, bool )
{ {
// check device capabilities if it fullfills our requirements // check device capabilities if it fullfills our requirements
const QString strStat = CheckDeviceCapabilities ( iDriverIdx ); const QString strStat = CheckDeviceCapabilities ( iDriverIdx );

View file

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

View file

@ -124,7 +124,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
// driver // driver
UnloadCurrentDriver(); UnloadCurrentDriver();
const QString strErrorMessage = LoadAndInitializeDriver ( iNewDev ); const QString strErrorMessage = LoadAndInitializeDriver ( iNewDev, false );
if ( !strErrorMessage.isEmpty() ) if ( !strErrorMessage.isEmpty() )
{ {
@ -132,7 +132,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
{ {
// loading and initializing the new driver failed, go back to // loading and initializing the new driver failed, go back to
// original driver and display error message // original driver and display error message
LoadAndInitializeDriver ( lCurDev ); LoadAndInitializeDriver ( lCurDev, false );
} }
else else
{ {
@ -167,7 +167,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
// the first available driver in the system. If this fails, too, we // the first available driver in the system. If this fails, too, we
// throw an error that no driver is available -> it does not make // throw an error that no driver is available -> it does not make
// sense to start the software if no audio hardware is available. // 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 // loading and initializing the new driver failed, try to find
// at least one usable driver // at least one usable driver
@ -183,8 +183,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
if ( bTryLoadAnyDriver ) if ( bTryLoadAnyDriver )
{ {
// try to load and initialize any valid driver // try to load and initialize any valid driver
QVector<QString> vsErrorList = QVector<QString> vsErrorList = LoadAndInitializeFirstValidDriver();
LoadAndInitializeFirstValidDriver();
if ( !vsErrorList.isEmpty() ) if ( !vsErrorList.isEmpty() )
{ {
@ -201,6 +200,20 @@ QString CSoundBase::SetDev ( const int iNewDev )
} }
sErrorMessage += "</ul>"; 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 ); throw CGenErr ( sErrorMessage );
} }
} }
@ -209,7 +222,7 @@ QString CSoundBase::SetDev ( const int iNewDev )
return strReturn; return strReturn;
} }
QVector<QString> CSoundBase::LoadAndInitializeFirstValidDriver() QVector<QString> CSoundBase::LoadAndInitializeFirstValidDriver ( const bool bOpenDriverSetup )
{ {
QVector<QString> vsErrorList; QVector<QString> vsErrorList;
@ -221,7 +234,7 @@ QVector<QString> CSoundBase::LoadAndInitializeFirstValidDriver()
while ( !bValidDriverDetected && ( iCurDriverIdx < lNumDevs ) ) while ( !bValidDriverDetected && ( iCurDriverIdx < lNumDevs ) )
{ {
// try to load and initialize current driver, store error message // try to load and initialize current driver, store error message
const QString strCurError = LoadAndInitializeDriver ( iCurDriverIdx ); const QString strCurError = LoadAndInitializeDriver ( iCurDriverIdx, bOpenDriverSetup );
vsErrorList.append ( strCurError ); vsErrorList.append ( strCurError );

View file

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

View file

@ -40,7 +40,8 @@ CSound* pSound;
/******************************************************************************\ /******************************************************************************\
* Common * * Common *
\******************************************************************************/ \******************************************************************************/
QString CSound::LoadAndInitializeDriver ( int iDriverIdx ) QString CSound::LoadAndInitializeDriver ( int iDriverIdx,
bool bOpenDriverSetup )
{ {
// load driver // load driver
loadAsioDriver ( cDriverNames[iDriverIdx] ); loadAsioDriver ( cDriverNames[iDriverIdx] );
@ -67,6 +68,13 @@ QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
} }
else 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 // driver cannot be used, clean up
asioDrivers->removeCurrentDriver(); asioDrivers->removeCurrentDriver();
} }
@ -480,12 +488,12 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* a
const int iCtrlMIDIChannel, const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect) : const bool bNoAutoJackConnect) :
CSoundBase ( "ASIO", true, fpNewCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ), CSoundBase ( "ASIO", true, fpNewCallback, arg, iCtrlMIDIChannel, bNoAutoJackConnect ),
vSelectedInputChannels ( NUM_IN_OUT_CHANNELS ),
vSelectedOutputChannels ( NUM_IN_OUT_CHANNELS ),
lNumInChan ( 0 ), lNumInChan ( 0 ),
lNumInChanPlusAddChan ( 0 ), lNumInChanPlusAddChan ( 0 ),
lNumOutChan ( 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; int i;

View file

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