Skip to content

Commit

Permalink
try to fix Misconfigured ASIO4ALL config can't be corrected #117
Browse files Browse the repository at this point in the history
  • Loading branch information
corrados committed Apr 20, 2020
1 parent ee014bb commit 00b11ee
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion mac/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion mac/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class CSound : public CSoundBase
int iSelOutputRightChannel;

protected:
virtual QString LoadAndInitializeDriver ( int iIdx );
virtual QString LoadAndInitializeDriver ( int iIdx, bool );

QString CheckDeviceCapabilities ( const int iDriverIdx );
int CountChannels ( AudioDeviceID devID,
Expand Down
27 changes: 20 additions & 7 deletions src/soundbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ QString CSoundBase::SetDev ( const int iNewDev )
// driver
UnloadCurrentDriver();

const QString strErrorMessage = LoadAndInitializeDriver ( iNewDev );
const QString strErrorMessage = LoadAndInitializeDriver ( iNewDev, false );

if ( !strErrorMessage.isEmpty() )
{
if ( iNewDev != lCurDev )
{
// loading and initializing the new driver failed, go back to
// original driver and display error message
LoadAndInitializeDriver ( lCurDev );
LoadAndInitializeDriver ( lCurDev, false );
}
else
{
Expand Down Expand Up @@ -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
Expand All @@ -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() )
{
Expand All @@ -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 );

This comment has been minimized.

Copy link
@ann0see

ann0see Dec 16, 2021

Member

@pljones concerning this commit, I am a bit worried about the functionality. Even if we fix ASIO4ALL errors, Jamulus exits after...

This comment has been minimized.

Copy link
@pljones

pljones Dec 16, 2021

Collaborator

See my comments on #2168

}
}
Expand All @@ -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;

Expand All @@ -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 );

Expand Down
4 changes: 2 additions & 2 deletions src/soundbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class CSoundBase : public QThread

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 );
Expand Down
16 changes: 12 additions & 4 deletions windows/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ CSound* pSound;
/******************************************************************************\
* Common *
\******************************************************************************/
QString CSound::LoadAndInitializeDriver ( int iDriverIdx )
QString CSound::LoadAndInitializeDriver ( int iDriverIdx,
bool bOpenDriverSetup )
{
// load driver
loadAsioDriver ( cDriverNames[iDriverIdx] );
Expand All @@ -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 );

This comment has been minimized.

Copy link
@ann0see

ann0see Dec 16, 2021

Member

... this message was confirmed.

Shouldn't we reload the driver somehow and not quit Jamulus?

}

// driver cannot be used, clean up
asioDrivers->removeCurrentDriver();

This comment has been minimized.

Copy link
@ann0see

ann0see Dec 16, 2021

Member

I mean, why do we execute this if the driver might be fixed?

}
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion windows/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class CSound : public CSoundBase
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();
Expand Down

0 comments on commit 00b11ee

Please sign in to comment.