alsa/0008-seq-Clear-UMP-event-flag-for-legacy-apps.patch
Takashi Iwai b6a2495802 Accepting request 1124030 from home:tiwai:branches:multimedia:libs
- Backport upstream fixes for sequencer and mixer:
  0006-seq-Fix-invalid-sanity-check-in-snd_seq_set_input_bu.patch 
  0007-mixer-simple-Support-dB-TLVs-for-CTL_SINGLE-controls.patch 
  0008-seq-Clear-UMP-event-flag-for-legacy-apps.patch 
  0009-seq-Simplify-snd_seq_extract_output.patch 
  0010-seq-Check-protocol-compatibility-with-the-current-ve.patch 
- Clean up spec file

OBS-URL: https://build.opensuse.org/request/show/1124030
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=325
2023-11-07 15:01:46 +00:00

67 lines
2.2 KiB
Diff

From 2fca03e792ef1b740e8a7370fdd360d0b627c84c Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Mon, 6 Nov 2023 16:27:11 +0100
Subject: [PATCH] seq: Clear UMP event flag for legacy apps
It seems that some applications (at least Chrome WebMIDI) set random
bits to the flags of event packet, and this confuses as if they were
UMP-events, which are eventually filtered out.
Although it's a bug of applications, it's better to avoid the
regressions. So this patch forcibly clears the UMP flag of the
incoming and outgoing events when the application is running in the
legacy mode (i.e. midi_version = 0).
Fixes: 2aefb5c41cc0 ("seq: Add UMP support")
Closes: https://github.com/alsa-project/alsa-lib/issues/360
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/seq/seq.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/seq/seq.c b/src/seq/seq.c
index 5ec737a7004f..643cf159f3ef 100644
--- a/src/seq/seq.c
+++ b/src/seq/seq.c
@@ -4161,6 +4161,13 @@ int snd_seq_event_output(snd_seq_t *seq, snd_seq_event_t *ev)
return result;
}
+/* workaround for broken legacy apps that set UMP event bit unexpectedly */
+static void clear_ump_for_legacy_apps(snd_seq_t *seq, snd_seq_event_t *ev)
+{
+ if (!seq->midi_version && snd_seq_ev_is_ump(ev))
+ ev->flags &= ~SNDRV_SEQ_EVENT_UMP;
+}
+
/**
* \brief output an event onto the lib buffer without draining buffer
* \param seq sequencer handle
@@ -4178,6 +4185,7 @@ int snd_seq_event_output_buffer(snd_seq_t *seq, snd_seq_event_t *ev)
{
int len;
assert(seq && ev);
+ clear_ump_for_legacy_apps(seq, ev);
len = snd_seq_event_length(ev);
if (len < 0)
return -EINVAL;
@@ -4238,6 +4246,7 @@ int snd_seq_event_output_direct(snd_seq_t *seq, snd_seq_event_t *ev)
ssize_t len;
void *buf;
+ clear_ump_for_legacy_apps(seq, ev);
len = snd_seq_event_length(ev);
if (len < 0)
return len;
@@ -4374,6 +4383,7 @@ static int snd_seq_event_retrieve_buffer(snd_seq_t *seq, snd_seq_event_t **retp)
snd_seq_event_t *ev;
*retp = ev = (snd_seq_event_t *)(seq->ibuf + seq->ibufptr * packet_size);
+ clear_ump_for_legacy_apps(seq, ev);
seq->ibufptr++;
seq->ibuflen--;
if (! snd_seq_ev_is_variable(ev))
--
2.35.3