jackaudio / jack2

jack2 codebase
GNU General Public License v2.0
2.21k stars 376 forks source link

Driver client (system) missing initial meta-data #443

Open falkTX opened 5 years ago

falkTX commented 5 years ago

jack1 gives some nice initial meta-data to the system client, regarding port-ordering and pretty-name. jack2 has nothing.

SpotlightKid commented 5 years ago

AFAICS, adding pretty-names for ALSA rawmidi ports has been implemented in c2ec4b37d4e2d6cba97a58444ebe89ec99fc8586. But it doesn't seem to work yet.

From #jack on freenode:

[20:38:51] <strogon14> I'm trying to test this recent jack 2 commit: https://github.com/jackaudio/jack2/commit/c2ec4b37d4e2d6cba97a58444ebe89ec99fc8586
[20:39:53] <strogon14> My interpretation is that if I start jack with -d alsa and -Xraw, the MIDI ports should get pretty-name meta-data. However 'jack_property -l' shows nothing.
[20:41:06] <strogon14> I don't see JackEngine::PortSetDeviceMetadata(), where the meta-data is set, get called at all.
lucianoiam commented 5 years ago

Maybe the issue is that -Xraw != -Xalsarawmidi ? . I think they are different drivers and the patch only affects alsarawmidi (and winmme and coremidi)

SpotlightKid commented 5 years ago

So this new code isn't used on Linux at all? Only the seq and raw drivers are available there, if I'm not mistaken.

lucianoiam commented 5 years ago

As far as I know there are three MIDI drivers available for Linux: seq, raw and alsarawmidi. I cannot seem to find a conclusive piece of documentation to link here, but a quick look at code reveals that the last two are implemented in separate source files, linux/alsa/alsa_rawmidi.c and linux/alsarawmidi/JackALSARawMidiDriver.cpp. The patch was only applied to the latter, therefore do not expect pretty-names when using -Xraw

SpotlightKid commented 5 years ago

Where does the JackALSARawMidiDriver driver get registered & instantiated? If I start jackd with -d alsa -Xalsarawmidi I get no MIDI ports at all.

I admit, I don't know much about the jack server internal structure, so any pointers appreciated.

Was there a special reason you implemented your patch only for the alsarawmidi driver?

lucianoiam commented 5 years ago

I found that if the -Xalsarawmidi switch is placed after -dalsa, then I get no ports. Try swapping order like this:

jackd -Xalsarawmidi -dalsa ...

Not sure why this happens. I guess I copied the command line from Ardour so it always worked for me.

I am new to JACK development, so also not familiar with the server internal structure nor with the various MIDI drivers. I think I picked alsarawmidi because that is what Ardour chooses if you let it start JACK on its own and I have a high regard for Ardour. I would like to know what are the differences between the MIDI implementations and why there is not just a single one for Linux like on the other platforms.

(To be 100% accurate, Ardour duplicates the -X switch like this when starting JACK):

jackd ... -X alsarawmidi -d alsa ... -X alsarawmidi ...

I found that leaving a single -X alsarawmidi is enough, providing it comes before -d alsa

SpotlightKid commented 5 years ago

The order makes a difference, because everything before the -d option is a general server option, and everything afterwards a driver backend option. The confusion comes from the fact that there is an -X general option and a different -X option for the alsa driver. The former is checked for valid values, the latter is not. So when you have jackd ... -X alsarawmidi -d alsa ... -X alsarawmidi ... the second (driver) -X option is ignored.

The (general) -X option specifies, AFAICS, a "slave driver" (or backend). So it seems the alsarawmidi driver gets loaded in a totally different way than the raw and seq drivers. The (general) -X option is very poorly documented, the man page doesn't mention it all. jackd --help just lists it with "--slave-backend OR -X slave-backend-name". The available slave backends don't seem to be listed anywhere at all.

This is rather a mess.

lucianoiam commented 5 years ago

Great explanation, thanks. MIDI code is there and works but feels like development went through a sinuous path. Maybe it is time for some refactoring and better docs.

lucianoiam commented 5 years ago

@SpotlightKid check https://github.com/jackaudio/jack2/pull/505

falkTX commented 5 years ago

Most of this is done, but can be extended for audio ports. I will move that to do on next release.