From 8efb7c5c7988185eae4efdc5ce3fd150d9aa8afa Mon Sep 17 00:00:00 2001 From: pgScorpio Date: Sat, 26 Mar 2022 20:27:58 +0100 Subject: [PATCH] Connection status issue jamulussoftware#2519 second stage Moved Connect/Disconnect code from CClientdlg to CClient. Now using the proper connected checks in several places. Added bDisconnectAndDisable to CChannel. (For a Client now Channel.Disconnect() will block audio data and auto disable the channel on disconnected) --- src/channel.cpp | 29 +++++++- src/channel.h | 3 +- src/client.cpp | 126 +++++++++++++++++++++++----------- src/client.h | 22 ++---- src/clientdlg.cpp | 141 ++++++++++---------------------------- src/clientdlg.h | 13 ++-- src/clientsettingsdlg.cpp | 21 +++--- src/main.cpp | 36 +++++----- src/util.cpp | 1 + 9 files changed, 196 insertions(+), 196 deletions(-) diff --git a/src/channel.cpp b/src/channel.cpp index a35576a34d..9cd4f57a1e 100644 --- a/src/channel.cpp +++ b/src/channel.cpp @@ -37,6 +37,7 @@ CChannel::CChannel ( const bool bNIsServer ) : bIsEnabled ( false ), bIsServer ( bNIsServer ), bIsIdentified ( false ), + bDisconnectAndDisable ( false ), iAudioFrameSizeSamples ( DOUBLE_SYSTEM_FRAME_SIZE_SAMPLES ), SignalLevelMeter ( false, 0.5 ) // server mode with mono out and faster smoothing { @@ -125,7 +126,8 @@ void CChannel::SetEnable ( const bool bNEnStat ) QMutexLocker locker ( &Mutex ); // set internal parameter - bIsEnabled = bNEnStat; + bIsEnabled = bNEnStat; + bDisconnectAndDisable = false; // The support for the packet sequence number must be reset if the client // disconnects from a server since we do not yet know if the next server we @@ -506,11 +508,20 @@ void CChannel::Disconnect() // we only have to disconnect the channel if it is actually connected if ( IsConnected() ) { + // for a Client we will block further audio data and disable the channel as soon as disconnected; + bDisconnectAndDisable = !bIsServer; + // set time out counter to a small value > 0 so that the next time a // received audio block is queried, the disconnection is performed // (assuming that no audio packet is received in the meantime) iConTimeOut = 1; // a small number > 0 } + else if ( !bIsServer ) + { + bDisconnectAndDisable = false; + bIsEnabled = false; + iConTimeOut = 0; + } } void CChannel::PutProtocolData ( const int iRecCounter, const int iRecID, const CVector& vecbyMesBodyData, const CHostAddress& RecHostAddr ) @@ -534,7 +545,7 @@ EPutDataStat CChannel::PutAudioData ( const CVector& vecbyData, const i // Only process audio data if: // - for client only: the packet comes from the server we want to talk to // - the channel is enabled - if ( ( bIsServer || ( GetAddress() == RecHostAddr ) ) && IsEnabled() ) + if ( ( bIsServer || ( GetAddress() == RecHostAddr ) ) && IsEnabled() && !bDisconnectAndDisable ) { MutexSocketBuf.lock(); { @@ -622,6 +633,12 @@ EGetDataStat CChannel::GetData ( CVector& vecbyData, const int iNumByte eGetStatus = GS_CHAN_NOW_DISCONNECTED; iConTimeOut = 0; // make sure we do not have negative values + if ( bDisconnectAndDisable ) + { + bDisconnectAndDisable = false; + bIsEnabled = false; + } + // reset network transport properties ResetNetworkTransportProperties(); } @@ -643,6 +660,13 @@ EGetDataStat CChannel::GetData ( CVector& vecbyData, const int iNumByte { // channel is disconnected eGetStatus = GS_CHAN_NOT_CONNECTED; + + if ( bDisconnectAndDisable ) + { + bDisconnectAndDisable = false; + bIsEnabled = false; + iConTimeOut = 0; + } } } MutexSocketBuf.unlock(); @@ -652,7 +676,6 @@ EGetDataStat CChannel::GetData ( CVector& vecbyData, const int iNumByte { // reset the protocol Protocol.Reset(); - // emit message emit Disconnected(); } diff --git a/src/channel.h b/src/channel.h index 86791494b3..32463bfe1d 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 = iConTimeOutStartVal; } + void ResetTimeOutCounter() { iConTimeOut = bDisconnectAndDisable ? 1 : iConTimeOutStartVal; } bool IsConnected() const { return iConTimeOut > 0; } void Disconnect(); @@ -216,6 +216,7 @@ void CreateReqChannelLevelListMes() { Protocol.CreateReqChannelLevelListMes(); } bool bIsEnabled; bool bIsServer; bool bIsIdentified; + bool bDisconnectAndDisable; int iNetwFrameSizeFact; int iNetwFrameSize; diff --git a/src/client.cpp b/src/client.cpp index 957f14d456..4eb43ee74e 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -27,7 +27,6 @@ /* Implementation *************************************************************/ CClient::CClient ( const quint16 iPortNumber, const quint16 iQosNumber, - const QString& strConnOnStartupAddress, const QString& strMIDISetup, const bool bNoAutoJackConnect, const QString& strNClientName, @@ -181,13 +180,6 @@ CClient::CClient ( const quint16 iPortNumber, // start the socket (it is important to start the socket after all // initializations and connections) Socket.Start(); - - // do an immediate start if a server address is given - if ( !strConnOnStartupAddress.isEmpty() ) - { - SetServerAddr ( strConnOnStartupAddress ); - StartConnection(); // ---> pgScorpio: Was Start() - } } CClient::~CClient() @@ -298,8 +290,7 @@ void CClient::CreateServerJitterBufferMessage() void CClient::OnCLPingReceived ( CHostAddress InetAddr, int iMs ) { // make sure we are running and the server address is correct - if ( SoundIsStarted() && // ---> pgScorpio: Does NOT mean we are Connected ! - ( InetAddr == Channel.GetAddress() ) ) + if ( Channel.IsEnabled() && ( InetAddr == Channel.GetAddress() ) ) { // take care of wrap arounds (if wrapping, do not use result) const int iCurDiff = EvaluatePingMessage ( iMs ); @@ -436,22 +427,6 @@ void CClient::StartDelayTimer() } } -bool CClient::SetServerAddr ( QString strNAddr ) -{ - CHostAddress HostAddress; - if ( NetworkUtil().ParseNetworkAddress ( strNAddr, HostAddress, bEnableIPv6 ) ) - { - // apply address to the channel - Channel.SetAddress ( HostAddress ); - - return true; - } - else - { - return false; // invalid address - } -} - bool CClient::GetAndResetbJitterBufferOKFlag() { // get the socket buffer put status flag and reset it @@ -587,9 +562,12 @@ QString CClient::SetSndCrdDev ( const QString strNewDev ) // in case of an error inform the GUI about it if ( !strError.isEmpty() ) { - emit SoundDeviceChanged ( strError ); + CMsgBoxes::ShowError ( strError ); + Disconnect(); } + emit SoundDeviceChanged(); + return strError; } @@ -716,8 +694,13 @@ void CClient::OnSndCrdReinitRequest ( int iSndCrdResetType ) } MutexDriverReinit.unlock(); + if ( !strError.isEmpty() ) + { + CMsgBoxes::ShowError ( strError ); + } + // inform GUI about the sound card device change - emit SoundDeviceChanged ( strError ); + emit SoundDeviceChanged(); } void CClient::OnHandledSignal ( int sigNum ) @@ -732,7 +715,7 @@ void CClient::OnHandledSignal ( int sigNum ) case SIGINT: case SIGTERM: // if connected, terminate connection (needed for headless mode) - StopConnection(); + Disconnect(); // this should trigger OnAboutToQuit QCoreApplication::instance()->exit(); @@ -817,23 +800,41 @@ void CClient::OnClientIDReceived ( int iChanID ) emit ClientIDReceived ( iChanID ); } -void CClient::StartConnection() // ---> pgScorpio: Was Start() +bool CClient::Connect ( QString strServerAddress, QString strServerName ) { - // init object - Init(); + if ( !Channel.IsEnabled() ) + { + CHostAddress HostAddress; + + if ( NetworkUtil().ParseNetworkAddress ( strServerAddress, HostAddress, bEnableIPv6 ) ) + { + // init object + Init(); + + // apply address to the channel + Channel.SetAddress ( HostAddress ); - // enable channel - Channel.SetEnable ( true ); + // enable channel + Channel.SetEnable ( true ); + + // start audio interface + Sound.Start(); + + // Notify ClientDlg + emit Connecting ( strServerName ); + + return true; + } + } - // start audio interface - Sound.Start(); // ---> pgScorpio: There is NO Check if Sound.Start() actually is successfull !! - // ---> pgScorpio: If Sound.Start fails here GUI (clientdlg) and Channel are definitely out of sync ! + return false; } -void CClient::StopConnection() +bool CClient::Disconnect() { - if ( SoundIsRunning() || Channel.IsEnabled() ) + if ( Channel.IsEnabled() ) { + /* // stop audio interface Sound.Stop(); @@ -844,6 +845,10 @@ void CClient::StopConnection() // network queue causing the channel to be reconnected right after having // received the disconnect message (seems not to gain much, disconnect is // still not working reliably) + // pgScorpio: I think the disconnect problem should be solved in CChannel. + // CChannel should ignore all audio data while disconnecting + // and disable itself as soon as disconnected. + QTime DieTime = QTime::currentTime().addMSecs ( 100 ); while ( QTime::currentTime() < DieTime ) { @@ -854,6 +859,36 @@ void CClient::StopConnection() QCoreApplication::processEvents ( QEventLoop::ExcludeUserInputEvents, 100 ); } + // disable channel + Channel.SetEnable(false); + */ + + // start disconnection + Channel.Disconnect(); + + // Channel.Disconnect() should now automatically disable Channel as soon as disconnected. + // Note that this only works if Sound is Active ! + + QTime DieTime = QTime::currentTime().addMSecs ( 500 ); + while ( ( QTime::currentTime() < DieTime ) && Channel.IsEnabled() ) + { + // exclude user input events because if we use AllEvents, it happens + // that if the user initiates a connection and disconnection quickly + // (e.g. quickly pressing enter five times), the software can get into + // an unknown state + QCoreApplication::processEvents ( QEventLoop::ExcludeUserInputEvents, 100 ); + } + + // Now stop the audio interface + Sound.Stop(); + + // in case we timed out, log warning and make sure Channel is disabled + if ( Channel.IsEnabled() ) + { + Channel.SetEnable ( false ); + qWarning() << CMsgBoxes::MainFormName() + " Warning: Disconnect failed."; + } + // Send disconnect message to server (Since we disable our protocol // receive mechanism with the next command, we do not evaluate any // respond from the server, therefore we just hope that the message @@ -864,6 +899,19 @@ void CClient::StopConnection() // reset current signal level and LEDs bJitterBufferOK = true; SignalLevelMeter.Reset(); + + emit Disconnected(); + + return true; + } + else + { + // make sure sound is stopped too + Sound.Stop(); + + emit Disconnected(); + + return false; } } diff --git a/src/client.h b/src/client.h index 5a5a2bc788..d2b750c0e6 100644 --- a/src/client.h +++ b/src/client.h @@ -110,7 +110,6 @@ class CClient : public QObject public: CClient ( const quint16 iPortNumber, const quint16 iQosNumber, - const QString& strConnOnStartupAddress, const QString& strMIDISetup, const bool bNoAutoJackConnect, const QString& strNClientName, @@ -119,27 +118,17 @@ class CClient : public QObject virtual ~CClient(); - void StartConnection(); // ---> pgScorpio: Was Start(), but Start what ? ( Should be Connect() ?) - void StopConnection(); // ---> pgScorpio: Was Stop(), but Stop what ? ( Should be Disconnect() ?) - bool SoundIsStarted() // ---> pgScorpio: Was IsRunning(), but what is running ?? - { - return Sound.IsRunning(); // ---> pgScorpio: Even this name is incorrect ! - // ---> pgScorpio: Sound.bRun is set when Sound is started, but this does not guarantee sound is actually running - } + bool Connect ( QString strServerAddress, QString strServerName ); + bool Disconnect(); - bool SoundIsRunning() const - { - return Sound.IsCallbackEntered(); - } // ---> pgScorpio: was IsCallbackEntered() but this is the actuall SoundIsRunning() ! - bool SetServerAddr ( QString strNAddr ); + bool SoundIsRunning() const { return Sound.IsCallbackEntered(); } // For OnTimerCheckAudioDeviceOk only ! + bool IsConnected() { return Channel.IsConnected(); } double GetLevelForMeterdBLeft() { return SignalLevelMeter.GetLevelForMeterdBLeftOrMono(); } double GetLevelForMeterdBRight() { return SignalLevelMeter.GetLevelForMeterdBRight(); } bool GetAndResetbJitterBufferOKFlag(); - bool IsConnected() { return Channel.IsConnected(); } - EGUIDesign GetGUIDesign() const { return eGUIDesign; } void SetGUIDesign ( const EGUIDesign eNGD ) { eGUIDesign = eNGD; } @@ -433,8 +422,9 @@ protected slots: void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector vecLevelList ); + void Connecting ( QString strServerName ); void Disconnected(); - void SoundDeviceChanged ( QString strError ); + void SoundDeviceChanged(); 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 da6ba92ef8..fee662654c 100644 --- a/src/clientdlg.cpp +++ b/src/clientdlg.cpp @@ -27,7 +27,6 @@ /* Implementation *************************************************************/ CClientDlg::CClientDlg ( CClient* pNCliP, CClientSettings* pNSetP, - const QString& strConnOnStartupAddress, const QString& strMIDISetup, const bool bNewShowComplRegConnList, const bool bShowAnalyzerConsole, @@ -272,14 +271,6 @@ CClientDlg::CClientDlg ( CClient* pNCliP, TimerCheckAudioDeviceOk.setSingleShot ( true ); // only check once after connection TimerDetectFeedback.setSingleShot ( true ); - // Connect on startup ------------------------------------------------------ - if ( !strConnOnStartupAddress.isEmpty() ) - { - // initiate connection (always show the address in the mixer board - // (no alias)) - Connect ( strConnOnStartupAddress, strConnOnStartupAddress ); - } - // File menu -------------------------------------------------------------- QMenu* pFileMenu = new QMenu ( tr ( "&File" ), this ); @@ -473,7 +464,9 @@ CClientDlg::CClientDlg ( CClient* pNCliP, // other QObject::connect ( pClient, &CClient::ConClientListMesReceived, this, &CClientDlg::OnConClientListMesReceived ); - QObject::connect ( pClient, &CClient::Disconnected, this, &CClientDlg::OnDisconnected ); + QObject::connect ( pClient, &CClient::Connecting, this, &CClientDlg::OnConnect ); + + QObject::connect ( pClient, &CClient::Disconnected, this, &CClientDlg::OnDisconnect ); QObject::connect ( pClient, &CClient::ChatTextReceived, this, &CClientDlg::OnChatTextReceived ); @@ -609,10 +602,7 @@ void CClientDlg::closeEvent ( QCloseEvent* Event ) AnalyzerConsole.close(); // if connected, terminate connection - if ( pClient->SoundIsStarted() ) // ---> pgScorpio: This does NOT mean the connection is started ! - { - pClient->StopConnection(); // ---> pgScorpio: Was pClient->Stop() - } + pClient->Disconnect(); // make sure all current fader settings are applied to the settings struct MainMixerBoard->StoreAllFaderSettings(); @@ -730,16 +720,12 @@ void CClientDlg::OnConnectDlgAccepted() } } - // first check if we are already connected, if this is the case we have to - // disconnect the old server first - if ( pClient->SoundIsStarted() ) // pgScorpio: Was pClient->IsRunning() Again this is NOT connection started ! + // initiate connection + if ( pClient->Connect ( strSelectedAddress, strMixerBoardLabel ) ) { - Disconnect(); + OnConnect ( strMixerBoardLabel ); } - // initiate connection - Connect ( strSelectedAddress, strMixerBoardLabel ); - // reset flag bConnectDlgWasShown = false; } @@ -748,10 +734,9 @@ void CClientDlg::OnConnectDlgAccepted() void CClientDlg::OnConnectDisconBut() { // the connect/disconnect button implements a toggle functionality - if ( pClient->SoundIsStarted() ) // pgScorpio: Was pClient->IsRunning() Again this is NOT connection started ! + if ( pClient->Disconnect() ) { - Disconnect(); - SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign() ); + // Client was Connected, now disconnected } else { @@ -835,7 +820,7 @@ void CClientDlg::OnChatTextReceived ( QString strChatText ) // always when a new message arrives since this is annoying. ShowChatWindow ( ( strChatText.indexOf ( WELCOME_MESSAGE_PREFIX ) == 0 ) ); - UpdateDisplay(); + UpdateSettingsAndChatButtons(); } void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType ) @@ -853,7 +838,7 @@ void CClientDlg::OnLicenceRequired ( ELicenceType eLicenceType ) // disconnect from that server. if ( !LicenceDlg.exec() ) { - Disconnect(); + pClient->Disconnect(); } // unmute the client output stream if local mute button is not pressed @@ -991,7 +976,7 @@ void CClientDlg::ShowChatWindow ( const bool bForceRaise ) ChatDlg.activateWindow(); } - UpdateDisplay(); + UpdateSettingsAndChatButtons(); } void CClientDlg::ShowAnalyzerConsole() @@ -1151,21 +1136,8 @@ void CClientDlg::OnTimerCheckAudioDeviceOk() void CClientDlg::OnTimerDetectFeedback() { bDetectFeedback = false; } -void CClientDlg::OnSoundDeviceChanged ( QString strError ) +void CClientDlg::OnSoundDeviceChanged() { - if ( !strError - .isEmpty() ) // ---> pgScorpio: This check should already be done in CClient ! but currently the Disconnect code is at the wrong place. - { - // the sound device setup has a problem, disconnect any active connection - if ( pClient->SoundIsStarted() ) // ---> pgScorpio: Was pClient->IsRunning(), Again this is NOT connection started !() ) - { - Disconnect(); - } - - // show the error message of the device setup - CMsgBoxes::ShowError ( strError ); - } - // if the check audio device timer is running, it must be restarted on a device change if ( TimerCheckAudioDeviceOk.isActive() ) { @@ -1188,73 +1160,36 @@ void CClientDlg::OnCLPingTimeWithNumClientsReceived ( CHostAddress InetAddr, int ConnectDlg.SetPingTimeAndNumClientsResult ( InetAddr, iPingTime, iNumClients ); } -void CClientDlg::Connect ( const QString& strSelectedAddress, const QString& strMixerBoardLabel ) +void CClientDlg::OnConnect ( QString strServerName ) { - // ---> pgScorpio: This code does not belong here but in CClient !! - // set address and check if address is valid - if ( pClient->SetServerAddr ( strSelectedAddress ) ) - { - // try to start client, if error occurred, do not go in - // running state but show error message - try - { - if ( !pClient->SoundIsStarted() ) // ---> pgScorpio: Again this is NOT connection started !() ) - { - pClient->StartConnection(); - } - } - - catch ( const CGenErr& generr ) - { - // show error message and return the function - CMsgBoxes::ShowError ( generr.GetErrorText() ); - return; - } + // hide label connect to server + lblConnectToServer->hide(); + lbrInputLevelL->setEnabled ( true ); + lbrInputLevelR->setEnabled ( true ); - // ---> pgScorpio: This code should be a OnConnecting() slot ! + // change connect button text to "disconnect" + butConnect->setText ( tr ( "&Disconnect" ) ); - // hide label connect to server - lblConnectToServer->hide(); - lbrInputLevelL->setEnabled ( true ); - lbrInputLevelR->setEnabled ( true ); + // set server name in audio mixer group box title + MainMixerBoard->SetServerName ( strServerName ); - // change connect button text to "disconnect" - butConnect->setText ( tr ( "&Disconnect" ) ); + // start timer for level meter bar and ping time measurement + TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS ); + TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS ); + TimerPing.start ( PING_UPDATE_TIME_MS ); + TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer - // set server name in audio mixer group box title - MainMixerBoard->SetServerName ( strMixerBoardLabel ); - - // start timer for level meter bar and ping time measurement - TimerSigMet.start ( LEVELMETER_UPDATE_TIME_MS ); - TimerBuffersLED.start ( BUFFER_LED_UPDATE_TIME_MS ); - TimerPing.start ( PING_UPDATE_TIME_MS ); - TimerCheckAudioDeviceOk.start ( CHECK_AUDIO_DEV_OK_TIME_MS ); // is single shot timer - - // audio feedback detection - if ( pSettings->bEnableFeedbackDetection ) - { - TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer - bDetectFeedback = true; - } + // audio feedback detection + if ( pSettings->bEnableFeedbackDetection ) + { + TimerDetectFeedback.start ( DETECT_FEEDBACK_TIME_MS ); // single shot timer + bDetectFeedback = true; } } -void CClientDlg::Disconnect() +void CClientDlg::OnDisconnect() { - // ---> pgScorpio: This code does not belong here but in CClient !! - - // only stop client if currently running, in case we received - // the stopped message, the client is already stopped but the - // connect/disconnect button and other GUI controls must be - // updated - if ( pClient->SoundIsStarted() ) // ---> pgScorpio: Again this is NOT connection started !() ) - { - pClient->StopConnection(); - } - - // ---> pgScorpio: This code should be a OnDisconncted() slot - // change connect button text to "connect" butConnect->setText ( tr ( "C&onnect" ) ); @@ -1278,11 +1213,7 @@ void CClientDlg::Disconnect() TimerDetectFeedback.stop(); bDetectFeedback = false; - // clang-format off -// TODO is this still required??? -// immediately update status bar -OnTimerStatus(); - // clang-format on + UpdateSettingsAndChatButtons(); // reset LEDs ledBuffers->Reset(); @@ -1296,9 +1227,11 @@ OnTimerStatus(); // clear mixer board (remove all faders) MainMixerBoard->HideAll(); + + SetMixerBoardDeco ( RS_UNDEFINED, pClient->GetGUIDesign() ); } -void CClientDlg::UpdateDisplay() +void CClientDlg::UpdateSettingsAndChatButtons() { // update settings/chat buttons (do not fire signals since it is an update) if ( chbSettings->isChecked() && !ClientSettingsDlg.isVisible() ) diff --git a/src/clientdlg.h b/src/clientdlg.h index bbcc604766..79d8190dea 100644 --- a/src/clientdlg.h +++ b/src/clientdlg.h @@ -76,7 +76,6 @@ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase public: CClientDlg ( CClient* pNCliP, CClientSettings* pNSetP, - const QString& strConnOnStartupAddress, const QString& strMIDISetup, const bool bNewShowComplRegConnList, const bool bShowAnalyzerConsole, @@ -94,8 +93,6 @@ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase void ShowAnalyzerConsole(); void UpdateAudioFaderSlider(); void UpdateRevSelection(); - void Connect ( const QString& strSelectedAddress, const QString& strMixerBoardLabel ); - void Disconnect(); void ManageDragNDrop ( QDropEvent* Event, const bool bCheckAccept ); void SetPingTime ( const int iPingTime, const int iOverallDelayMs, const CMultiColorLED::ELightColor eOverallDelayLEDColor ); @@ -119,7 +116,7 @@ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase virtual void closeEvent ( QCloseEvent* Event ); virtual void dragEnterEvent ( QDragEnterEvent* Event ) { ManageDragNDrop ( Event, true ); } virtual void dropEvent ( QDropEvent* Event ) { ManageDragNDrop ( Event, false ); } - void UpdateDisplay(); + void UpdateSettingsAndChatButtons(); CClientSettingsDlg ClientSettingsDlg; CChatDlg ChatDlg; @@ -127,13 +124,16 @@ class CClientDlg : public CBaseDlg, private Ui_CClientDlgBase CAnalyzerConsole AnalyzerConsole; public slots: + void OnConnect ( QString strServerName ); + void OnDisconnect(); + void OnConnectDisconBut(); void OnTimerSigMet(); void OnTimerBuffersLED(); void OnTimerCheckAudioDeviceOk(); void OnTimerDetectFeedback(); - void OnTimerStatus() { UpdateDisplay(); } + void OnTimerStatus() { UpdateSettingsAndChatButtons(); } void OnTimerPing(); void OnPingTimeResult ( int iPingTime ); @@ -191,7 +191,7 @@ public slots: void OnConClientListMesReceived ( CVector vecChanInfo ); void OnChatTextReceived ( QString strChatText ); void OnLicenceRequired ( ELicenceType eLicenceType ); - void OnSoundDeviceChanged ( QString strError ); + void OnSoundDeviceChanged(); void OnChangeChanGain ( int iId, float fGain, bool bIsMyOwnFader ) { pClient->SetRemoteChanGain ( iId, fGain, bIsMyOwnFader ); } @@ -232,7 +232,6 @@ public slots: } void OnConnectDlgAccepted(); - void OnDisconnected() { Disconnect(); } void OnGUIDesignChanged(); void OnMeterStyleChanged(); void OnRecorderStateReceived ( ERecorderState eRecorderState ); diff --git a/src/clientsettingsdlg.cpp b/src/clientsettingsdlg.cpp index ec3dc7f5de..b306b46d78 100644 --- a/src/clientsettingsdlg.cpp +++ b/src/clientsettingsdlg.cpp @@ -1039,8 +1039,16 @@ void CClientSettingsDlg::OnSndCrdBufferDelayButtonGroupClicked ( QAbstractButton void CClientSettingsDlg::UpdateUploadRate() { // update upstream rate information label - lblUpstreamValue->setText ( QString().setNum ( pClient->GetUploadRateKbps() ) ); - lblUpstreamUnit->setText ( "kbps" ); + if ( pClient->IsConnected() ) + { + lblUpstreamValue->setText ( QString().setNum ( pClient->GetUploadRateKbps() ) ); + lblUpstreamUnit->setText ( "kbps" ); + } + else + { + lblUpstreamValue->setText ( "---" ); + lblUpstreamUnit->setText ( "" ); + } } void CClientSettingsDlg::UpdateDisplay() @@ -1048,13 +1056,8 @@ void CClientSettingsDlg::UpdateDisplay() // update slider controls (settings might have been changed) UpdateJitterBufferFrame(); UpdateSoundCardFrame(); - - if ( !pClient->SoundIsStarted() ) // pgScorpio: Was !pClient->IsRunning() Again this is NOT a connection status, Should be pClient->IsConnected() - { - // clear text labels with client parameters - lblUpstreamValue->setText ( "---" ); - lblUpstreamUnit->setText ( "" ); - } + // update upstream rate information label + UpdateUploadRate(); } void CClientSettingsDlg::UpdateDirectoryServerComboBox() diff --git a/src/main.cpp b/src/main.cpp index 772c93458c..ecf019f4b9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -813,14 +813,7 @@ int main ( int argc, char** argv ) { // Client: // actual client object - CClient Client ( iPortNumber, - iQosNumber, - strConnOnStartupAddress, - 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 ); @@ -842,21 +835,21 @@ int main ( int argc, char** argv ) if ( bUseGUI ) { // GUI object - CClientDlg ClientDlg ( &Client, - &Settings, - strConnOnStartupAddress, - strMIDISetup, - bShowComplRegConnList, - bShowAnalyzerConsole, - bMuteStream, - bEnableIPv6, - nullptr ); + CClientDlg + ClientDlg ( &Client, &Settings, strMIDISetup, bShowComplRegConnList, bShowAnalyzerConsole, bMuteStream, bEnableIPv6, nullptr ); // initialise message boxes CMsgBoxes::init ( &ClientDlg, strClientName.isEmpty() ? QString ( APP_NAME ) : QString ( APP_NAME ) + " " + strClientName ); // show dialog ClientDlg.show(); + + // Connect on startup ------------------------------------------------------ + if ( !strConnOnStartupAddress.isEmpty() ) + { + Client.Connect ( strConnOnStartupAddress, strConnOnStartupAddress ); + } + pApp->exec(); } else @@ -865,6 +858,15 @@ int main ( int argc, char** argv ) // only start application without using the GUI qInfo() << qUtf8Printable ( GetVersionAndNameStr ( false ) ); + // initialise message boxes + CMsgBoxes::init ( NULL, strClientName.isEmpty() ? QString ( APP_NAME ) : QString ( APP_NAME ) + " " + strClientName ); + + // Connect on startup ------------------------------------------------------ + if ( !strConnOnStartupAddress.isEmpty() ) + { + Client.Connect ( strConnOnStartupAddress, strConnOnStartupAddress ); + } + pApp->exec(); } } diff --git a/src/util.cpp b/src/util.cpp index abd34512d7..93a878d860 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -493,6 +493,7 @@ CAboutDlg::CAboutDlg ( QWidget* parent ) : CBaseDlg ( parent ) "

RobyDati (RobyDati)

" "

Rob-NY (Rob-NY)

" "

Thai Pangsakulyanont (dtinth)

" + "

Peter Goderie (pgScorpio)

" "
" + tr ( "For details on the contributions check out the %1" ) .arg ( "" + tr ( "Github Contributors list" ) + "." ) );