jack: use a new JackPortIsMIDI2 flag

The JACK2 maintainer would prefer to use a new port flag to mark the
MIDI2 capability of the port and keep the port type as MIDI. Add the
proposed flags to the API.

If we register a MIDI port with the MIDI2 flag, promote it to UMP.
Expose v1 MIDI ports with the MIDI DSP property again.

If we see an UMP port, set the MIDI2 flag on the port.

This is functionaly equivalent to what we have. Old jack midi ports will
now however not have the UMP DSP format but the old MIDI format so that
we can, in the JACK API, make a distinction between MIDI1 and MIDI2 ports.
This commit is contained in:
Wim Taymans 2025-01-27 13:05:21 +01:00
parent 23ae55015d
commit 1a737a9fed
3 changed files with 32 additions and 3 deletions

View file

@ -3438,8 +3438,8 @@ static const char* type_to_format_dsp(jack_port_type_id_t type_id)
case TYPE_ID_OSC:
return JACK_DEFAULT_OSC_TYPE;
case TYPE_ID_MIDI:
return JACK_DEFAULT_MIDI_TYPE;
case TYPE_ID_UMP:
/* all exposed to PipeWire as UMP */
return JACK_DEFAULT_UMP_TYPE;
default:
return NULL;
@ -3818,6 +3818,9 @@ static void registry_event_global(void *data, uint32_t id,
if ((str = spa_dict_lookup(props, PW_KEY_PORT_NAME)) == NULL)
goto exit;
if (type_id == TYPE_ID_UMP)
flags |= JackPortIsMIDI2;
spa_dict_for_each(item, props) {
if (spa_streq(item->key, PW_KEY_PORT_DIRECTION)) {
if (spa_streq(item->value, "in"))
@ -5437,6 +5440,9 @@ jack_port_t * jack_port_register (jack_client_t *client,
pw_log_warn("unknown port type %s", port_type);
return NULL;
}
if (type_id == TYPE_ID_MIDI && (flags & JackPortIsMIDI2))
type_id = TYPE_ID_UMP;
len = snprintf(name, sizeof(name), "%s:%s", c->name, port_name);
if (len < 0 || (size_t)len >= sizeof(name)) {
pw_log_warn("%p: name \"%s:%s\" too long", c,