diff --git a/src/channel.cpp b/src/channel.cpp index d927213f45..04febb9e49 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -513,7 +513,7 @@ void CChannel::Disconnect() // (assuming that no audio packet is received in the meantime) iConTimeOut = 1; // a small number > 0 } - + if ( !bIsServer ) { if ( IsConnected() ) diff --git a/src/channel.h b/src/channel.h index 2d3a9fda5f..90bd95f244 100644 --- a/src/channel.h +++ b/src/channel.h @@ -76,7 +76,7 @@ class CChannel : public QObject void PrepAndSendPacket ( CHighPrioSocket* pSocket, const CVector& vecbyNPacket, const int iNPacketLen ); - void ResetTimeOutCounter() { iConTimeOut = (bDisconnectAndDisable && !bIsServer) ? 1 : iConTimeOutStartVal; } + void ResetTimeOutCounter() { iConTimeOut = ( bDisconnectAndDisable && !bIsServer ) ? 1 : iConTimeOutStartVal; } bool IsConnected() const { return iConTimeOut > 0; } void Disconnect(); diff --git a/src/client.cpp b/src/client.cpp index cdbb6ec105..6addfe5cbd 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -618,16 +618,12 @@ QString CClient::SetSndCrdDev ( const QString strNewDev ) Sound.Start(); } + // in case of an error inform the GUI about it if ( !strError.isEmpty() ) { - // due to error, disconnect - Disconnect(); + emit SoundDeviceChanged ( strError ); } - // in case of an error, this will inform the GUI about it - - emit SoundDeviceChanged(); - return strError; } @@ -754,18 +750,8 @@ void CClient::OnSndCrdReinitRequest ( int iSndCrdResetType ) } MutexDriverReinit.unlock(); - if ( !strError.isEmpty() ) - { -#ifndef HEADLESS - QMessageBox::critical ( 0, APP_NAME, strError, tr ( "Ok" ) ); -#else - qCritical() << qUtf8Printable ( strError ); - exit ( 1 ); -#endif - } - // inform GUI about the sound card device change - emit SoundDeviceChanged(); + emit SoundDeviceChanged ( strError ); } void CClient::OnHandledSignal ( int sigNum ) @@ -924,7 +910,8 @@ bool CClient::Connect ( QString strServerAddress, QString strServerName ) if ( !Channel.IsEnabled() ) { // Set server address and connect if valid address was supplied - if ( SetServerAddr ( strServerAddress ) ) { + if ( SetServerAddr ( strServerAddress ) ) + { Start(); diff --git a/src/client.h b/src/client.h index 7c1fd81b7f..38626cf2e7 100644 --- a/src/client.h +++ b/src/client.h @@ -431,7 +431,7 @@ protected slots: void Connecting ( QString strServerName ); void Disconnected(); - void SoundDeviceChanged(); + void SoundDeviceChanged ( QString strError ); void ControllerInFaderLevel ( int iChannelIdx, int iValue ); void ControllerInPanValue ( int iChannelIdx, int iValue ); void ControllerInFaderIsSolo ( int iChannelIdx, bool bIsSolo ); diff --git a/src/clientdlg.cpp b/src/clientdlg.cpp index abb5152514..d09984e478 100644 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -1143,8 +1143,20 @@ void CClientDlg::OnTimerCheckAudioDeviceOk() void CClientDlg::OnTimerDetectFeedback() { bDetectFeedback = false; } -void CClientDlg::OnSoundDeviceChanged() +void CClientDlg::OnSoundDeviceChanged ( QString strError ) { + if ( !strError.isEmpty() ) + { + // the sound device setup has a problem, disconnect any active connection + if ( pClient->IsRunning() ) + { + pClient->Disconnect(); + } + + // show the error message of the device setup + QMessageBox::critical ( this, APP_NAME, strError, tr ( "Ok" ), nullptr ); + } + // if the check audio device timer is running, it must be restarted on a device change if ( TimerCheckAudioDeviceOk.isActive() ) { diff --git a/src/clientdlg.h b/src/clientdlg.h index 0e1166331c..593038eeb3 100644 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -190,7 +190,7 @@ public slots: void OnConClientListMesReceived ( CVector vecChanInfo ); void OnChatTextReceived ( QString strChatText ); void OnLicenceRequired ( ELicenceType eLicenceType ); - void OnSoundDeviceChanged(); + void OnSoundDeviceChanged ( QString strError ); void OnChangeChanGain ( int iId, float fGain, bool bIsMyOwnFader ) { pClient->SetRemoteChanGain ( iId, fGain, bIsMyOwnFader ); } diff --git a/src/main.cpp b/src/main.cpp index d8386e6b55..5dc16ed57e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -919,13 +919,7 @@ int main ( int argc, char** argv ) { // Client: // actual client object - CClient Client ( iPortNumber, - iQosNumber, - strMIDISetup, - bNoAutoJackConnect, - strClientName, - bEnableIPv6, - bMuteMeInPersonalMix ); + CClient Client ( iPortNumber, iQosNumber, strMIDISetup, bNoAutoJackConnect, strClientName, bEnableIPv6, bMuteMeInPersonalMix ); // load settings from init-file (command line options override) CClientSettings Settings ( &Client, strIniFileName ); @@ -949,14 +943,8 @@ int main ( int argc, char** argv ) } // GUI object - CClientDlg ClientDlg ( &Client, - &Settings, - strMIDISetup, - bShowComplRegConnList, - bShowAnalyzerConsole, - bMuteStream, - bEnableIPv6, - nullptr ); + CClientDlg + ClientDlg ( &Client, &Settings, strMIDISetup, bShowComplRegConnList, bShowAnalyzerConsole, bMuteStream, bEnableIPv6, nullptr ); // show dialog ClientDlg.show();