From 00b11ee06a515d6fd3889aaa2e916fabdddc7ae4 Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Mon, 20 Apr 2020 19:57:21 +0200 Subject: [PATCH] try to fix Misconfigured ASIO4ALL config can't be corrected #117 --- mac/sound.cpp | 2 +- mac/sound.h | 2 +- src/soundbase.cpp | 27 ++++++++++++++++++++------- src/soundbase.h | 4 ++-- windows/sound.cpp | 16 ++++++++++++---- windows/sound.h | 3 ++- 6 files changed, 38 insertions(+), 16 deletions(-) diff --git a/mac/sound.cpp b/mac/sound.cpp index 7585788a..d3cdf322 100755 --- a/mac/sound.cpp +++ b/mac/sound.cpp @@ -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 ); diff --git a/mac/sound.h b/mac/sound.h index 86cd882a..67ae10da 100755 --- a/mac/sound.h +++ b/mac/sound.h @@ -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, diff --git a/src/soundbase.cpp b/src/soundbase.cpp index 611836d2..56ae94b2 100755 --- a/src/soundbase.cpp +++ b/src/soundbase.cpp @@ -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 vsErrorList = - LoadAndInitializeFirstValidDriver(); + QVector vsErrorList = LoadAndInitializeFirstValidDriver(); if ( !vsErrorList.isEmpty() ) { @@ -201,6 +200,20 @@ QString CSoundBase::SetDev ( const int iNewDev ) } sErrorMessage += ""; +#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 ( "
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 CSoundBase::LoadAndInitializeFirstValidDriver() +QVector CSoundBase::LoadAndInitializeFirstValidDriver ( const bool bOpenDriverSetup ) { QVector vsErrorList; @@ -221,7 +234,7 @@ QVector 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 ); diff --git a/src/soundbase.h b/src/soundbase.h index e7fc73da..2a3bb6d2 100755 --- a/src/soundbase.h +++ b/src/soundbase.h @@ -94,9 +94,9 @@ public: protected: // driver handling - virtual QString LoadAndInitializeDriver ( int ) { return ""; } + virtual QString LoadAndInitializeDriver ( int, bool ) { return ""; } virtual void UnloadCurrentDriver() {} - QVector LoadAndInitializeFirstValidDriver(); + QVector LoadAndInitializeFirstValidDriver ( const bool bOpenDriverSetup = false ); // function pointer to callback function void (*fpProcessCallback) ( CVector& psData, void* arg ); diff --git a/windows/sound.cpp b/windows/sound.cpp index b6db2ae9..9c5046fe 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -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& 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; diff --git a/windows/sound.h b/windows/sound.h index 302d8435..21881bb9 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -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();