Repository navigation
seq: snd_seq_parse_address() accepts port name - #528
Open
thanks4opensource wants to merge 1 commit into
Open
thanks4opensource wants to merge 1 commit into
thanks4opensource wants to merge 1 commit into
Conversation
|
…r-or-name Previously only client-number-or-name:port-number. Accepts prefix for client-name, substring for port-name. Exact name match overrides in both cases. Includes new test/address.c to validate old and new functionality. Signed-off-by: thanks4opensource <31165662+thanks4opensource@users.noreply.github.com>
thanks4opensource
force-pushed
the
thanks4opensource_parse_address
branch
from
October 3, 2026 18:32
dc6f862 to
e97154f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull requests allows
snd_seq_parse_address()to accept port names as well as port id numbers. This improves the usability ofaconnect, particularly within shell scripts where port names are more readable/self-documenting than port numbers, and are also more robust as client updates are more likely to reorder/renumber ports than to change their names.The functionality could be added within
aconnectitself, but doing so inside alsa-lib makes it available for all programs, e.g. ones that usesnd_seq_subscribe_port(),etc to connect themselves to other clients.The new code is almost completely compatible with existing use-cases, with one exception: If passed a non-numeric port, a bug in the current
snd_seq_parse_address()sets 0 for the port id/number without returning an error. This causesaconnectto silently make an incorrect connection or fail with a confusing error message.Consider the following example:
Until I looked at the source code, I never understood:
If the error message had been "Invalid argument" instead of "Operation not permitted" (why can't I connect an output to an input?) it would have been less of a mystery.
Equally confusing, and potentially dangerous:
That's a somewhat contrived example, but imagine it's 3 AM and you want to practice some loud heavy metal keyboard riffs. Suddenly you're in big trouble with your neighbors. ;)
This pull request "does the right thing" in all cases. My general policy is to never change existing behavior, but in this case the "silently convert to port 0" is at best an undocumented feature, and at worst an undeniable bug. Anything relying on it really should be fixed.
The code maintains current feature of accepting a prefix of a client name ("FLU" instead of "FLUID Synth"). If accepts any substring for port names because several common ALSA clients have long port names which differ only at their ends ("alt" for "Synth input alternate"). In both cases an exact name match overrides a prefix/substring.
The branch includes test/address.c which extensively validates
snd_seq_parse_address()(4349 tests at latest count), including checking returned errors in cases of nonexistent client or port names, out of range client/port id numbers, etc. As necessitated by the sequencer API, and as per the current code, it requires a non-NULLsnd_seq_t*argument to handle names but will parse purely numeric ids without. It currently does not check whether there are existing clients/ports matching the requested client/port numbers.I apologize for completely rewriting
snd_seq_parse_address(), but the existing version parsed the port string before the client, including multiple early returns from the function. The client is required for searching port names, and the code would have been a mess if the order of operations had been retained. Of course I also believe the new version, particularly the parsing of the input string into client and port, is simpler and more readable.Please consider merging this pull request. Thank you.