alsa: remove UMP flag from control format

Don't set the UMP type flag on the format. Use the negotiated types flag
to decide what format to output. Add support for output to old style
midi.

Set the UMP type flag only on the new mixer and JACK when UMP is
enabled.

This ensures that only new (or explicitly requesting) apps get UMP and
old apps receive old midi.

This makes JACK running on 1.2 in flatpaks work with midi again.
This commit is contained in:
Wim Taymans 2025-05-23 16:53:42 +02:00
parent 76db05a0f8
commit 06941f7315
6 changed files with 157 additions and 77 deletions

View file

@ -529,8 +529,7 @@ impl_node_port_enum_params(void *object, int seq,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_application),
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_control),
SPA_FORMAT_CONTROL_types, SPA_POD_CHOICE_FLAGS_Int(1u<<SPA_CONTROL_UMP));
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_control));
break;
case SPA_PARAM_Format:
@ -541,8 +540,7 @@ impl_node_port_enum_params(void *object, int seq,
param = spa_pod_builder_add_object(&b,
SPA_TYPE_OBJECT_Format, SPA_PARAM_Format,
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_application),
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_control),
SPA_FORMAT_CONTROL_types, SPA_POD_Int(1u<<SPA_CONTROL_UMP));
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_control));
break;
case SPA_PARAM_Buffers:
@ -635,7 +633,7 @@ static int port_set_format(void *object, struct seq_port *port,
port->have_format = false;
} else {
struct spa_audio_info info = { 0 };
uint32_t types;
uint32_t types = 0;
if ((err = spa_format_parse(format, &info.media_type, &info.media_subtype)) < 0)
return err;
@ -646,13 +644,12 @@ static int port_set_format(void *object, struct seq_port *port,
if ((err = spa_pod_parse_object(format,
SPA_TYPE_OBJECT_Format, NULL,
SPA_FORMAT_CONTROL_types, SPA_POD_Int(&types))) < 0)
SPA_FORMAT_CONTROL_types, SPA_POD_OPT_Int(&types))) < 0)
return err;
if (types != 1u << SPA_CONTROL_UMP)
return -EINVAL;
port->current_format = info;
port->have_format = true;
port->control_types = types;
}
port->info.change_mask |= SPA_PORT_CHANGE_MASK_RATE;