From 4176caca30d10417004c55b744d71083857f3e77 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Thu, 20 Mar 2025 20:35:46 +0200 Subject: [PATCH] alsa: seq: double-check midi client version Check midi client version after setting it, to see if it was really successfully set. Old kernels without UMP don't know about the midi version fields, so snd_seq_set_client_midi_version() appears to fail silently there. --- spa/plugins/alsa/alsa-seq.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spa/plugins/alsa/alsa-seq.c b/spa/plugins/alsa/alsa-seq.c index 4f64ee5ba..eb12bde29 100644 --- a/spa/plugins/alsa/alsa-seq.c +++ b/spa/plugins/alsa/alsa-seq.c @@ -44,9 +44,27 @@ static int seq_open(struct seq_state *state, struct seq_conn *conn, bool with_qu #ifdef HAVE_ALSA_UMP res = snd_seq_set_client_midi_version(conn->hndl, SND_SEQ_CLIENT_UMP_MIDI_2_0); + if (!res) { + snd_seq_client_info_t *info = NULL; + + /* Double check client version */ + res = snd_seq_client_info_malloc(&info); + if (!res) + res = snd_seq_get_client_info(conn->hndl, info); + if (!res) { + res = snd_seq_client_info_get_midi_version(info); + if (res == SND_SEQ_CLIENT_UMP_MIDI_2_0) + res = 0; + else + res = -EIO; + } + if (info) + snd_seq_client_info_free(info); + } #else res = -EOPNOTSUPP; #endif + if (res < 0) { spa_log_lev(state->log, (probe_ump ? SPA_LOG_LEVEL_INFO : SPA_LOG_LEVEL_ERROR), "%p: ALSA failed to enable UMP MIDI: %s", state, snd_strerror(res));