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

@ -247,7 +247,6 @@ static void midi_to_jack(struct impl *impl, float *dst, float *src, uint32_t n_s
struct spa_pod_sequence *seq;
struct spa_pod_control *c;
int res;
bool in_sysex = false;
uint8_t tmp[n_samples * 4];
size_t tmp_size = 0;
@ -267,23 +266,23 @@ static void midi_to_jack(struct impl *impl, float *dst, float *src, uint32_t n_s
if (c->type != SPA_CONTROL_UMP)
continue;
switch (c->type) {
case SPA_CONTROL_UMP:
size = spa_ump_to_midi(SPA_POD_BODY(&c->value),
SPA_POD_BODY_SIZE(&c->value), &tmp[tmp_size], sizeof(tmp) - tmp_size);
if (size <= 0)
continue;
tmp_size += size;
break;
case SPA_CONTROL_Midi:
tmp_size = SPA_POD_BODY_SIZE(&c->value);
memcpy(tmp, SPA_POD_BODY(&c->value), SPA_MIN(sizeof(tmp), tmp_size));
break;
}
size = spa_ump_to_midi(SPA_POD_BODY(&c->value),
SPA_POD_BODY_SIZE(&c->value), &tmp[tmp_size], sizeof(tmp) - tmp_size);
if (size <= 0)
continue;
if (impl->fix_midi)
fix_midi_event(&tmp[tmp_size], size);
if (!in_sysex && tmp[tmp_size] == 0xf0)
in_sysex = true;
tmp_size += size;
if (in_sysex && tmp[tmp_size-1] == 0xf7)
in_sysex = false;
if (!in_sysex) {
if (tmp[0] != 0xf0 || tmp[tmp_size-1] == 0xf7) {
if (impl->fix_midi)
fix_midi_event(tmp, tmp_size);
if ((res = jack.midi_event_write(dst, c->offset, tmp, tmp_size)) < 0)
pw_log_warn("midi %p: can't write event: %s", dst,
spa_strerror(res));