Skip to content
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

Manage client-side channels locally, own channel always 0 #3426

Merged
merged 18 commits into from
Nov 26, 2024

Conversation

softins
Copy link
Member

@softins softins commented Nov 20, 2024

Short description of changes

Manages the allocation of client-side channels independently of server-side channels, and maps between
the two at the boundary between CClient and the lower-level CChannel and CProtocol.

All layers above (e.g. CClientDlg and the audio mixer board) will use client-side channels transparently.

When talking to a server version 3.5.5 or newer, the client is told its own server channel, and will always map
this to client channel 0. This allows the user of a MIDI device or JSON-RPC client to know that channel 0 will always control
the user's own audio channel.

In addition, when connecting to a server that only has a small number of high-numbered channels remaining
after many users have left, those channels will automatically be mapped to lower client channel numbers and
so will be controllable using local MIDI faders.

CHANGELOG: Client: allocate channel numbers locally and always give user own channel of 0

Context: Fixes an issue?

Resolves #3423 and supersedes both #3419 and #3394

Does this change need documentation? What needs to be documented and how?

Most operation is unchanged from before, but it is worth mentioning that the user's own channel will always be
number 0 unless connected to a server older than 3.5.5

Status of this Pull Request

Tested and working, ready for review.

What is missing until this pull request can be merged?

Testing on multiple platforms.

Checklist

  • I've verified that this Pull Request follows the general code principles
  • I tested my code and it does what I want
  • My code follows the style guide
  • I waited some time after this Pull Request was opened and all GitHub checks completed without errors.
  • I've filled all the content above

@softins
Copy link
Member Author

softins commented Nov 20, 2024

I have left the chain of commits separate, so that reviewers can see the sequence of development if interested.

@softins softins self-assigned this Nov 20, 2024
@softins softins requested review from pljones and ann0see November 20, 2024 17:34
src/client.cpp Outdated Show resolved Hide resolved
@softins softins requested a review from ann0see November 23, 2024 20:57
@pljones pljones added this to the Release 3.12.0 milestone Nov 24, 2024
@pljones pljones added refactoring Non-behavioural changes, Code cleanup feature request Feature request labels Nov 24, 2024
@pljones
Copy link
Collaborator

pljones commented Nov 24, 2024

NOTE: I'm happy with the scope of this PR. The following outlines my thoughts - I'll raise a feature request shortly after this gets merged.

OK, just thinking about the wider implications...

When talking to a server version 3.5.5 or newer, the client is told its own server channel, and will always map
this to client channel 0. This allows the user of a MIDI device or JSON-RPC client to know that channel 0 will always control
the user's own audio channel.

So we will have inconsistent client behaviour based on server version, with nothing explanatory for the user to understand why.

I don't like that. I'd rather we made the default act as if we had not received the "own server channel" message and only enable remapping based on receipt of the message if:

  • GUI option "Own Fader First" is selected
  • NEW command line client-only option --channelsort has own as an argument (see below for more)

This way we can make the GUI option disabled when the server does not supply "own server channel" and document the effect of the new CLI option as being server-dependent.

The new CLI option should additionally support one of none, name, instrument, group, city and channel. Where none of these appears (or none appears), behaviour must be as for GUI "No user sorting" (assuming no preference - e.g. headless client). Otherwise, the channel list should be sorted accordingly.

--ctrlmidich would be used with --channelsort "own;channel" to get the proposed effect -- whilst making it clear this depended on the server supplying the relevant information.

Of course, this pulls the channel sorting logic into the client itself, so that the GUI simply displays the channels in the order held by the client, which further reduces logic in the GUI code.

(Yes, there should also be a JSON-RPC interface to set the sort order.)

@softins
Copy link
Member Author

softins commented Nov 24, 2024

When talking to a server version 3.5.5 or newer, the client is told its own server channel, and will always map
this to client channel 0. This allows the user of a MIDI device or JSON-RPC client to know that channel 0 will always control
the user's own audio channel.

So we will have inconsistent client behaviour based on server version, with nothing explanatory for the user to understand why.

I don't think that's a problem. There are already differences in client behaviour depending whether it receives the CLIENT_ID message. When talking to a server < 3.5.5, I think the following features will work differently or not at all:

  • Mute myself
  • "Own fader first" setting

I don't like that. I'd rather we made the default act as if we had not received the "own server channel" message

I don't see what problem that is trying to solve, beyond the notion of consistency with archaic server versions, and I don't think it gives any advantage to the user. Version 3.5.5 was released on 26 May 2020.

Looking in explorer at the moment, under Any Genre 1, 7 out of 108 servers are older than 3.5.5, and only 12 are older than 3.6.2. The oldest on Any Genre 2 is 3.6.1, of which there are 2 out of 51; the rest are 3.6.2 or newer. All the other directories only accept 3.6.2 or newer servers anyway.

Anyone running a private server but using a recent version of client is extremely unlikely to be using a really old version of server.

So changing the default as suggested would just be degrading the operation of the client for consistency with a minuscule set of situations. The user doesn't get to choose the channels assigned by the server, so they also don't need to choose whether their own channel gets client channel 0 or not. It's no disadvantage to the user to consistently get channel 0 for themselves by default in the overwhelming majority of cases.

I would much rather it became a non-issue by having all the public directories only accept registrations from servers of 3.6.2 or newer.

Also, if we incorporate #3416, then the user would see the server versions in the Connect dialog, and could decide not to connect to an archaic version of server.

@softins
Copy link
Member Author

softins commented Nov 24, 2024

Of course, this pulls the channel sorting logic into the client itself, so that the GUI simply displays the channels in the order held by the client, which further reduces logic in the GUI code.

I think the client layer is the wrong place to do any sorting. We don't want to be changing channel assignments on the fly.

Sorting is a presentational function, and so the mixer board is the right place to do it, as at present.

(Yes, there should also be a JSON-RPC interface to set the sort order.)

The JSON-RPC interface will/should receive all the same channel info that the mixer board does. A user interface that gets its info via JSON-RPC can therefore do its own sorting for presentation to the user, based on that information and the user's settings (which don't need to be sent to the Jamulus client).

@ann0see
Copy link
Member

ann0see commented Nov 24, 2024

Sorting is a presentational function, and so the mixer board is the right place to do it, as at present.

Yes, but it's not an UI only feature either.

A user interface that gets its info via JSON-RPC can therefore do its own sorting for presentation to the user, based on that information and the user's settings

I think it is confusing if JSON-RPC and GUI show different ordering.

@ann0see
Copy link
Member

ann0see commented Nov 24, 2024

I don't think that's a problem. There are already differences in client behaviour depending whether it receives the CLIENT_ID message.

I agree - this time. It's not a huge problem.

clientChannelIDs[i] = INVALID_INDEX;
}

// qInfo() << "> Client channel list cleared";
Copy link
Member

@ann0see ann0see Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth getting rid of this debug output (this doesn't add anything and can be easily re-added during debugging if necessary)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would be useful to retain the qInfo() messages I used while debugging, just commented out, then someone wanting to re-enable them only needs to uncomment, not compose afresh or search earlier commits for them.

src/client.cpp Outdated Show resolved Hide resolved
// any unexpected temporary mismatch in size due to potential out-of-order message delivery.
//
// This function returns true if the list has been processed and should be passed on,
// or false if it was the wrong size and should be discarded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of this PR, but I'd like to have a standard format like in the recorder of JSON-RPC server for documentation like this

Copy link
Member

@ann0see ann0see left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise seems ok (test on Debian 12)

@ann0see ann0see modified the milestones: Release 3.12.0, Release 4.0.0 Nov 24, 2024
Co-authored-by: ann0see <[email protected]>
@softins
Copy link
Member Author

softins commented Nov 24, 2024

Sorting is a presentational function, and so the mixer board is the right place to do it, as at present.

Yes, but it's not an UI only feature either.

A user interface that gets its info via JSON-RPC can therefore do its own sorting for presentation to the user, based on that information and the user's settings

I think it is confusing if JSON-RPC and GUI show different ordering.

Well let's have this conversation in any follow-up issue, as it's not relevant to this PR.

@softins
Copy link
Member Author

softins commented Nov 24, 2024

I don't think there is any reason to delay this PR until 4.0.0. It can very usefully be merged now.

@softins softins requested a review from ann0see November 24, 2024 23:27
@softins softins merged commit bedd7b0 into jamulussoftware:main Nov 26, 2024
11 checks passed
@softins softins deleted the client-side-channels branch November 26, 2024 09:49
@pljones pljones modified the milestones: Release 4.0.0, Release 3.12.0 Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Non-behavioural changes, Code cleanup
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Make client-side channels independent of server-side channels
3 participants