diff --git a/0006-seq-Fix-invalid-sanity-check-in-snd_seq_set_input_bu.patch b/0006-seq-Fix-invalid-sanity-check-in-snd_seq_set_input_bu.patch new file mode 100644 index 0000000..3b9ce8f --- /dev/null +++ b/0006-seq-Fix-invalid-sanity-check-in-snd_seq_set_input_bu.patch @@ -0,0 +1,34 @@ +From 915a71a2cdf6361f0fc77fa367a67910dc0288db Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Sat, 4 Nov 2023 10:05:39 +0100 +Subject: [PATCH] seq: Fix invalid sanity-check in + snd_seq_set_input_buffer_size() + +snd_seq_set_input_buffer_size() has an assert() call with packet_size, +but it's still uninitialized at that point. Fix it with the real +packet size. + +Fixes: 2aefb5c41cc0 ("seq: Add UMP support") +Signed-off-by: Takashi Iwai +--- + src/seq/seq.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/seq/seq.c b/src/seq/seq.c +index fd8ca30e2472..5ec737a7004f 100644 +--- a/src/seq/seq.c ++++ b/src/seq/seq.c +@@ -1269,9 +1269,9 @@ int snd_seq_set_input_buffer_size(snd_seq_t *seq, size_t size) + size_t packet_size; + + assert(seq && seq->ibuf); ++ packet_size = get_packet_size(seq); + assert(size >= packet_size); + snd_seq_drop_input(seq); +- packet_size = get_packet_size(seq); + size = (size + packet_size - 1) / packet_size; + if (size != seq->ibufsize) { + char *newbuf; +-- +2.35.3 + diff --git a/0007-mixer-simple-Support-dB-TLVs-for-CTL_SINGLE-controls.patch b/0007-mixer-simple-Support-dB-TLVs-for-CTL_SINGLE-controls.patch new file mode 100644 index 0000000..67d367a --- /dev/null +++ b/0007-mixer-simple-Support-dB-TLVs-for-CTL_SINGLE-controls.patch @@ -0,0 +1,42 @@ +From f202ec3c23abf16a2382acc0de35900173e32160 Mon Sep 17 00:00:00 2001 +From: Hector Martin +Date: Sat, 28 Oct 2023 21:33:29 +0900 +Subject: [PATCH] mixer: simple: Support dB TLVs for CTL_SINGLE controls + +dB mappings do not work for controls not named "* Volume", since we do not +fall back to CTL_SINGLE in get_selem_ctl. Add that branch to make it +work. + +Fixes dB ranges for e.g. controls named "* Gain". + +Closes: https://github.com/alsa-project/alsa-lib/pull/358 +Signed-off-by: Hector Martin +Signed-off-by: Jaroslav Kysela +--- + src/mixer/simple_none.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c +index 846b0ca92467..dd03fcf13d01 100644 +--- a/src/mixer/simple_none.c ++++ b/src/mixer/simple_none.c +@@ -1155,11 +1155,12 @@ static selem_ctl_t *get_selem_ctl(selem_none_t *s, int dir) + c = &s->ctls[CTL_CAPTURE_VOLUME]; + else + return NULL; +- if (! c->elem) { ++ if (! c->elem) + c = &s->ctls[CTL_GLOBAL_VOLUME]; +- if (! c->elem) +- return NULL; +- } ++ if (! c->elem) ++ c = &s->ctls[CTL_SINGLE]; ++ if (! c->elem) ++ return NULL; + if (c->type != SND_CTL_ELEM_TYPE_INTEGER) + return NULL; + return c; +-- +2.35.3 + diff --git a/0008-seq-Clear-UMP-event-flag-for-legacy-apps.patch b/0008-seq-Clear-UMP-event-flag-for-legacy-apps.patch new file mode 100644 index 0000000..cb7be38 --- /dev/null +++ b/0008-seq-Clear-UMP-event-flag-for-legacy-apps.patch @@ -0,0 +1,66 @@ +From 2fca03e792ef1b740e8a7370fdd360d0b627c84c Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +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 +--- + 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 + diff --git a/0009-seq-Simplify-snd_seq_extract_output.patch b/0009-seq-Simplify-snd_seq_extract_output.patch new file mode 100644 index 0000000..e8c2212 --- /dev/null +++ b/0009-seq-Simplify-snd_seq_extract_output.patch @@ -0,0 +1,99 @@ +From 94a5ddff9d5d85104755ee17b301c289a060cebf Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Mon, 6 Nov 2023 16:33:59 +0100 +Subject: [PATCH] seq: Simplify snd_seq_extract_output() + +Now that we never put UMP events on the output buffer in the legacy +mode, the check and skip of UMP events are no longer necessary. +It means that ump_allowed argument is meaningless in extract_output(), +too. + +Let's drop the unnecessary check and move the code extract_output() +into snd_seq_extract_output() again, and call this directly from +snd_seq_ump_extract_output() for simplification. + +Signed-off-by: Takashi Iwai +--- + src/seq/seq.c | 52 ++++++++++++++++++++------------------------------- + 1 file changed, 20 insertions(+), 32 deletions(-) + +diff --git a/src/seq/seq.c b/src/seq/seq.c +index 643cf159f3ef..5eac4848b9c7 100644 +--- a/src/seq/seq.c ++++ b/src/seq/seq.c +@@ -4308,36 +4308,6 @@ int snd_seq_drain_output(snd_seq_t *seq) + return 0; + } + +-static int extract_output(snd_seq_t *seq, snd_seq_event_t **ev_res, int ump_allowed) +-{ +- size_t len, olen; +- assert(seq); +- if (ev_res) +- *ev_res = NULL; +- repeat: +- if ((olen = seq->obufused) < sizeof(snd_seq_event_t)) +- return -ENOENT; +- len = snd_seq_event_length((snd_seq_event_t *)seq->obuf); +- if (olen < len) +- return -ENOENT; +- /* skip invalid UMP events */ +- if (snd_seq_ev_is_ump((snd_seq_event_t *)seq->obuf) && !ump_allowed) { +- seq->obufused -= len; +- memmove(seq->obuf, seq->obuf + len, seq->obufused); +- goto repeat; +- } +- if (ev_res) { +- /* extract the event */ +- if (alloc_tmpbuf(seq, len) < 0) +- return -ENOMEM; +- memcpy(seq->tmpbuf, seq->obuf, len); +- *ev_res = (snd_seq_event_t *)seq->tmpbuf; +- } +- seq->obufused = olen - len; +- memmove(seq->obuf, seq->obuf + len, seq->obufused); +- return 0; +-} +- + /** + * \brief extract the first event in output buffer + * \param seq sequencer handle +@@ -4351,7 +4321,25 @@ static int extract_output(snd_seq_t *seq, snd_seq_event_t **ev_res, int ump_allo + */ + int snd_seq_extract_output(snd_seq_t *seq, snd_seq_event_t **ev_res) + { +- return extract_output(seq, ev_res, 0); ++ size_t len, olen; ++ assert(seq); ++ if (ev_res) ++ *ev_res = NULL; ++ if ((olen = seq->obufused) < sizeof(snd_seq_event_t)) ++ return -ENOENT; ++ len = snd_seq_event_length((snd_seq_event_t *)seq->obuf); ++ if (olen < len) ++ return -ENOENT; ++ if (ev_res) { ++ /* extract the event */ ++ if (alloc_tmpbuf(seq, len) < 0) ++ return -ENOMEM; ++ memcpy(seq->tmpbuf, seq->obuf, len); ++ *ev_res = (snd_seq_event_t *)seq->tmpbuf; ++ } ++ seq->obufused = olen - len; ++ memmove(seq->obuf, seq->obuf + len, seq->obufused); ++ return 0; + } + + /*----------------------------------------------------------------*/ +@@ -4547,7 +4535,7 @@ int snd_seq_ump_extract_output(snd_seq_t *seq, snd_seq_ump_event_t **ev_res) + { + if (!seq->midi_version) + return -EBADFD; +- return extract_output(seq, (snd_seq_event_t **)ev_res, 1); ++ return snd_seq_extract_output(seq, (snd_seq_event_t **)ev_res); + } + + /** +-- +2.35.3 + diff --git a/0010-seq-Check-protocol-compatibility-with-the-current-ve.patch b/0010-seq-Check-protocol-compatibility-with-the-current-ve.patch new file mode 100644 index 0000000..08667f0 --- /dev/null +++ b/0010-seq-Check-protocol-compatibility-with-the-current-ve.patch @@ -0,0 +1,37 @@ +From ed6b07084bfea4155bbc98bcf38508ab81bdd008 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Mon, 6 Nov 2023 16:36:55 +0100 +Subject: [PATCH] seq: Check protocol compatibility with the current version + +There is no need for checking the protocol compatibility with another +version, but we just need to check for the current version. + +Signed-off-by: Takashi Iwai +--- + src/seq/seq_hw.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/src/seq/seq_hw.c b/src/seq/seq_hw.c +index b74948c81c9e..eeaf26e16d1c 100644 +--- a/src/seq/seq_hw.c ++++ b/src/seq/seq_hw.c +@@ -32,7 +32,6 @@ const char *_snd_module_seq_hw = ""; + #ifndef DOC_HIDDEN + #define SNDRV_FILE_SEQ ALSA_DEVICE_DIRECTORY "seq" + #define SNDRV_FILE_ALOADSEQ ALOAD_DEVICE_DIRECTORY "aloadSEQ" +-#define SNDRV_SEQ_VERSION_MAX SNDRV_PROTOCOL_VERSION(1, 0, 2) + + typedef struct { + int fd; +@@ -535,7 +534,7 @@ int snd_seq_hw_open(snd_seq_t **handle, const char *name, int streams, int mode) + close(fd); + return ret; + } +- if (SNDRV_PROTOCOL_INCOMPATIBLE(ver, SNDRV_SEQ_VERSION_MAX)) { ++ if (SNDRV_PROTOCOL_INCOMPATIBLE(ver, SNDRV_SEQ_VERSION)) { + close(fd); + return -SND_ERROR_INCOMPATIBLE_VERSION; + } +-- +2.35.3 + diff --git a/alsa.changes b/alsa.changes index 51c9fca..de3519c 100644 --- a/alsa.changes +++ b/alsa.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Tue Nov 7 14:51:05 UTC 2023 - Takashi Iwai + +- 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 + ------------------------------------------------------------------- Tue Oct 10 06:38:35 UTC 2023 - Takashi Iwai diff --git a/alsa.spec b/alsa.spec index 68fb03f..4b0eef5 100644 --- a/alsa.spec +++ b/alsa.spec @@ -61,6 +61,11 @@ Patch2: 0002-global.h-move-__STRING-macro-outside-PIC-ifdef-block.patch Patch3: 0003-pcm-Fix-segfault-with-32bit-libs.patch Patch4: 0004-reshuffle-included-files-to-include-config.h-as-firs.patch Patch5: 0005-seq-Fix-typos-in-symbol-version-definitions.patch +Patch6: 0006-seq-Fix-invalid-sanity-check-in-snd_seq_set_input_bu.patch +Patch7: 0007-mixer-simple-Support-dB-TLVs-for-CTL_SINGLE-controls.patch +Patch8: 0008-seq-Clear-UMP-event-flag-for-legacy-apps.patch +Patch9: 0009-seq-Simplify-snd_seq_extract_output.patch +Patch10: 0010-seq-Check-protocol-compatibility-with-the-current-ve.patch # rest suse fixes Patch101: alsa-lib-ignore-non-accessible-ALSA_CONFIG_PATH.patch BuildRequires: doxygen @@ -148,13 +153,7 @@ This package contains the library for ALSA topology support. %endif %prep -%setup -q -n alsa-lib-%{version} -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch101 -p1 +%autosetup -p1 -n alsa-lib-%{version} %build # disable LTO; otherwise some apps confused with versioned symbols (boo#1149461)