-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix connection status issue (#2519) #3364
base: main
Are you sure you want to change the base?
Fix connection status issue (#2519) #3364
Conversation
b12ce7e
to
2b9d985
Compare
This is a manual port of jamulussoftware#2550 by @pgScorpio Co-authored-by: ann0see <[email protected]>
d6e5a6c
to
38fb414
Compare
Coding style check also fails on main. Seems to be an unrelated issue? |
Pasting from previous PR here:
|
db402b9
to
10a4d61
Compare
10a4d61
to
a5af8cc
Compare
f7f0515
to
1614b81
Compare
1614b81
to
535f781
Compare
@@ -121,8 +120,11 @@ class CClient : public QObject | |||
|
|||
void Start(); | |||
void Stop(); | |||
bool Connect ( QString strServerAddress, QString strServerName ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does make sense to introduce an easy to call Connect() and Disconnect() method IMO, so this is good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having these in client.cpp
rather than clientdlg.cpp
is important. It's important enough to be done in a single PR on its own. I think we should start with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. That's issue #3367
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factored out into #3372
bool IsRunning() { return Sound.IsRunning(); } | ||
bool IsCallbackEntered() const { return Sound.IsCallbackEntered(); } | ||
bool IsCallbackEntered() const { return Sound.IsCallbackEntered(); } // For OnTimerCheckAudioDeviceOk only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted naming. May need some in depth review and discussion.
@@ -427,8 +429,9 @@ protected slots: | |||
|
|||
void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector<uint16_t> vecLevelList ); | |||
|
|||
void Connecting ( QString strServerName ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a missing slot.
src/client.h
Outdated
void Disconnected(); | ||
void SoundDeviceChanged ( QString strError ); | ||
void SoundDeviceChanged(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly about removing the error message handling. Could be reverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above:
- split this out to a separate PR
- have two slots, one for GUI, one for headless, and pass the error to each
|
||
// initiate connection | ||
Connect ( strSelectedAddress, strMixerBoardLabel ); | ||
// TODO: investigate and add error handling on failed Connect() call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO as commented in code.
I think it should only do changes on the client side. |
So we need to try understanding what gets changed. |
src/channel.h
Outdated
@@ -76,7 +76,7 @@ class CChannel : public QObject | |||
|
|||
void PrepAndSendPacket ( CHighPrioSocket* pSocket, const CVector<uint8_t>& vecbyNPacket, const int iNPacketLen ); | |||
|
|||
void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; } | |||
void ResetTimeOutCounter() { iConTimeOut = bDisconnectAndDisable ? 1 : iConTimeOutStartVal; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this. Should probably be expanded into an assignment and boolean comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I not enthused by the whole bDisconnectAndDisable
-- I can't see the problem it's trying to fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think they wanted to introduce an intermediate state somehow to fix the button being able to get out of sync.
From #2550 (comment)
Added bDisconnectAndDisable to CChannel. (For a Client now
Channel.Disconnect() will block audio data and auto disable the channel on disconnected)
Maybe we can reconstruct something from pgScorpio@648880c |
src/clientdlg.cpp
Outdated
@@ -1193,65 +1167,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 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pljones Potentially we only need this (see signal connection above) for the JSON-RPC PR.
I looked quickly through the changes the other day and didn't notice anything of concern, but I haven't yet had time to study in detail. |
I believe there's a need to check if the changed conditions in the if statements are really correct or if the bug lays elsewhere |
} | ||
else | ||
{ | ||
// For disconnected clients set defaults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this done when the disconnect actually happens, rather than here? Like in line 645? Is this just duplicated? Or is there a reason for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a reason for it.
It's probably trying to ensure that bDisconnectAndDisable is representing the client being in process of disconnecting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see what job it's doing that setting iConTimeOut
to 1 doesn't already do. It still needs iConTimeOut
set to 1, too, so it just adds complexity rather than removing it, without improving readability either.
|
||
if ( bDisconnectAndDisable && !bIsServer ) | ||
{ | ||
bDisconnectAndDisable = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??! So these get set to the same values whether eGetStatus
is GS_CHAN_NOW_DISCONNECTED
or GS_CHAN_NOT_CONNECTED
? Now I'm really confused.
src/channel.h
Outdated
@@ -76,7 +76,7 @@ class CChannel : public QObject | |||
|
|||
void PrepAndSendPacket ( CHighPrioSocket* pSocket, const CVector<uint8_t>& vecbyNPacket, const int iNPacketLen ); | |||
|
|||
void ResetTimeOutCounter() { iConTimeOut = iConTimeOutStartVal; } | |||
void ResetTimeOutCounter() { iConTimeOut = (bDisconnectAndDisable && !bIsServer) ? 1 : iConTimeOutStartVal; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this what CChannel::Disconnect()
is doing? Why is this change here?
The lifecycle of iConTimeOut
should be pretty clear:
- On client start, it should get initialised to 0, really.
- On connect, and each time an audio packet is processed whilst connected, it should get set to
iConTimeOutStartVal
, which should be a multiple ofiAudioFrameSizeSamples
. - Each time no audio packet is received
iAudioFrameSizeSamples
will get deducted without a reset until such time time runs out and the client disconnects. - On manual disconnect, it should get set to 1, which is less than
iAudioFrameSizeSamples
, which means on the next time around, the client will disconnect as above. - Once disconnected, it will get set back to 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On manual disconnect, it should get set to 1, which is less than iAudioFrameSizeSamples, which means on the next time around, the client will disconnect as above.
Which I believe may not happen? Probably the fix is not here though.
@@ -337,7 +329,7 @@ void CClient::CreateServerJitterBufferMessage() | |||
void CClient::OnCLPingReceived ( CHostAddress InetAddr, int iMs ) | |||
{ | |||
// make sure we are running and the server address is correct | |||
if ( IsRunning() && ( InetAddr == Channel.GetAddress() ) ) | |||
if ( Channel.IsEnabled() && ( InetAddr == Channel.GetAddress() ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't about the channel being enabled. It's about whether the client is running. It's a different intent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the initial PR confused active channel and active client: #2550 (comment)
This difference needs documentation. IMO: Add (like for JSON-RPC) respective technical documentation before the respective methods. As end goal: Write them for every function, for now: Write docs while changing.
Sound.Stop(); | ||
// start disconnection | ||
// Channel.Disconnect() should automatically disable Channel as soon as disconnected. | ||
// Note that this only works if sound is active! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why make the changes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's mainly moving around the Channel.Disconnect() and Sound.Stop() code around.
This may be the actual bug fix?
} | ||
} | ||
|
||
void CClientDlg::Disconnect() | ||
void CClientDlg::OnDisconnect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tidying up the mixer board should go in here, I guess.
Thanks for the review! I'll go through what I can answer later. |
@@ -963,6 +961,12 @@ int main ( int argc, char** argv ) | |||
// show dialog | |||
ClientDlg.show(); | |||
|
|||
// Connect on startup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These shouldn't be in main.cpp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's up to discussion. I do understand that one could put this functionality here. How it's handled currently also seems somewhat messy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is messy. But that's a bigger issue with how start up works.
2633d3c
to
66edab5
Compare
Factored out into jamulussoftware#3369
// disconnect the old server first | ||
if ( pClient->IsRunning() ) | ||
// initiate connection | ||
if ( pClient->Connect ( strSelectedAddress, strMixerBoardLabel ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be refactored imo. Feels very clumsy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI should simply pass any captured details to Client and await feedback. There shouldn't be any testing of the response. (Any input validation should be factored out of Client if it needs sharing between Client and ClientDlg.)
This is a manual port of #2550 by @pgScorpio
Short description of changes
First step to get to know the codebase of #2550
CHANGELOG: DO NOT MERGE
Context: Fixes an issue?
Fixes: #2519
Supersedes: #2550
Does this change need documentation? What needs to be documented and how?
No
Status of this Pull Request
Ready for first review and decision on how to move forward.
What is missing until this pull request can be merged?
Review.
It compiles but not every part of the code is fully understood and commented.
Checklist