Skip to content

Commit

Permalink
Revert strError handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ann0see committed Sep 13, 2024
1 parent d7b4b8b commit 2633d3c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down
2 changes: 1 addition & 1 deletion src/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CChannel : public QObject

void PrepAndSendPacket ( CHighPrioSocket* pSocket, const CVector<uint8_t>& 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();

Expand Down
23 changes: 5 additions & 18 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
14 changes: 13 additions & 1 deletion src/clientdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
{
Expand Down
2 changes: 1 addition & 1 deletion src/clientdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public slots:
void OnConClientListMesReceived ( CVector<CChannelInfo> 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 ); }

Expand Down
18 changes: 3 additions & 15 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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();
Expand Down

0 comments on commit 2633d3c

Please sign in to comment.