All of lore.kernel.org
 help / color / mirror / Atom feed
* Ask snd_seq_set_client_midi_version
@ 2024-12-18 23:24 Correo Alternativo
  2024-12-30 11:34 ` Takashi Iwai
  2025-02-01 23:11 ` Possible bug with snd_seq_event_input_pending Carlos
  0 siblings, 2 replies; 4+ messages in thread
From: Correo Alternativo @ 2024-12-18 23:24 UTC (permalink / raw)
  To: alsa-devel

Hi, I'm trying out MIDI 2.0 and found a problem, when using 
snd_seq_set_client_midi_version

With SND_SEQ_CLIENT_LEGACY_MIDI I get the following sequence of events 
when connecting a midi device (using the method snd_seq_event_input or 
snd_seq_ump_event_input) (timidity command:timidity --interface=A 
--buffer-fragments=2,8 --output-mode=s1l --sampling-freq=44100):

SND_SEQ_EVENT_CLIENT_START
SND_SEQ_EVENT_PORT_START
SND_SEQ_EVENT_PORT_START
SND_SEQ_EVENT_PORT_START
SND_SEQ_EVENT_PORT_START

But with SND_SEQ_CLIENT_UMP_MIDI_1_0 and SND_SEQ_CLIENT_UMP_MIDI_2_0 I 
don't get the SND_SEQ_EVENT_PORT_START events, I only get the following:

SND_SEQ_EVENT_CLIENT_START
SND_SEQ_EVENT_SYSTEM
SND_SEQ_EVENT_SYSTEM
SND_SEQ_EVENT_SYSTEM

I don't know if I'm asking this in the right place, what mistake am I 
making? Just by modifying that it stops working.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Ask snd_seq_set_client_midi_version
  2024-12-18 23:24 Ask snd_seq_set_client_midi_version Correo Alternativo
@ 2024-12-30 11:34 ` Takashi Iwai
  2025-02-01 23:11 ` Possible bug with snd_seq_event_input_pending Carlos
  1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2024-12-30 11:34 UTC (permalink / raw)
  To: Correo Alternativo; +Cc: alsa-devel

On Thu, 19 Dec 2024 00:24:11 +0100,
Correo Alternativo wrote:
> 
> Hi, I'm trying out MIDI 2.0 and found a problem, when using
> snd_seq_set_client_midi_version
> 
> With SND_SEQ_CLIENT_LEGACY_MIDI I get the following sequence of events
> when connecting a midi device (using the method snd_seq_event_input or
> snd_seq_ump_event_input) (timidity command:timidity --interface=A
> --buffer-fragments=2,8 --output-mode=s1l --sampling-freq=44100):
> 
> SND_SEQ_EVENT_CLIENT_START
> SND_SEQ_EVENT_PORT_START
> SND_SEQ_EVENT_PORT_START
> SND_SEQ_EVENT_PORT_START
> SND_SEQ_EVENT_PORT_START
> 
> But with SND_SEQ_CLIENT_UMP_MIDI_1_0 and SND_SEQ_CLIENT_UMP_MIDI_2_0 I
> don't get the SND_SEQ_EVENT_PORT_START events, I only get the
> following:
> 
> SND_SEQ_EVENT_CLIENT_START
> SND_SEQ_EVENT_SYSTEM
> SND_SEQ_EVENT_SYSTEM
> SND_SEQ_EVENT_SYSTEM
> 
> I don't know if I'm asking this in the right place, what mistake am I
> making? Just by modifying that it stops working.

Hmm, there should be no difference in this regard between the legacy
and UMP clients.

Do you mean that the destination client (i.e. timidity) doesn't
receive *_PORT_START events when you send from a UMP client?
Or how is the actual setup and the connection?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Possible bug with snd_seq_event_input_pending
  2024-12-18 23:24 Ask snd_seq_set_client_midi_version Correo Alternativo
  2024-12-30 11:34 ` Takashi Iwai
@ 2025-02-01 23:11 ` Carlos
  2025-02-17 11:04   ` Takashi Iwai
  1 sibling, 1 reply; 4+ messages in thread
From: Carlos @ 2025-02-01 23:11 UTC (permalink / raw)
  To: alsa-devel

Hi, I don't know if this is a bug or not, but I'll report it in case it is.

If I configure my client as follows:

snd_seq_set_client_midi_version(seq, SND_SEQ_CLIENT_LEGACY_MIDI);

snd_seq_set_client_ump_conversion(seq, 0);//I disable ump conversion

And then I send a midi event from a MIDI 2.0 device, the 
snd_seq_event_input_pending(seq, 1) function will not respond until it 
receives any other legacy event.

Now I know that with SND_SEQ_CLIENT_LEGACY_MIDI I shouldn't disable ump 
conversion, but I expected it to return 0.

Thank you

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible bug with snd_seq_event_input_pending
  2025-02-01 23:11 ` Possible bug with snd_seq_event_input_pending Carlos
@ 2025-02-17 11:04   ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2025-02-17 11:04 UTC (permalink / raw)
  To: Carlos; +Cc: alsa-devel

On Sun, 02 Feb 2025 00:11:51 +0100,
Carlos wrote:
> 
> Hi, I don't know if this is a bug or not, but I'll report it in case it is.
> 
> If I configure my client as follows:
> 
> snd_seq_set_client_midi_version(seq, SND_SEQ_CLIENT_LEGACY_MIDI);
> 
> snd_seq_set_client_ump_conversion(seq, 0);//I disable ump conversion
> 
> And then I send a midi event from a MIDI 2.0 device, the
> snd_seq_event_input_pending(seq, 1) function will not respond until it
> receives any other legacy event.
> 
> Now I know that with SND_SEQ_CLIENT_LEGACY_MIDI I shouldn't disable
> ump conversion, but I expected it to return 0.

This can be indeed a problem in the kernel side.  It shouldn't deliver
the UMP events if the destination can't handle it.

Could you try the patch below?


thanks,

Takashi

-- 8< --
From: Takashi Iwai <tiwai@suse.de>
Subject: [PATCH] ALSA: seq: Drop UMP events when no UMP-conversion is set

When a destination client is a user client in the legacy MIDI mode and
it sets the no-UMP-conversion flag, currently the all UMP events are
still passed as-is.  But this may confuse the user-space, because the
event packet size is different from the legacy mode.

Since we cannot handle UMP events in user clients unless it's running
in the UMP client mode, we should filter out those events instead of
accepting blindly.  This patch addresses it by slightly adjusting the
conditions for UMP event handling at the event delivery time.

Fixes: 329ffe11a014 ("ALSA: seq: Allow suppressing UMP conversions")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/seq/seq_clientmgr.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 073b56dc2225..cb66ec42a3f8 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -678,12 +678,18 @@ static int snd_seq_deliver_single_event(struct snd_seq_client *client,
 					  dest_port->time_real);
 
 #if IS_ENABLED(CONFIG_SND_SEQ_UMP)
-	if (!(dest->filter & SNDRV_SEQ_FILTER_NO_CONVERT)) {
-		if (snd_seq_ev_is_ump(event)) {
+	if (snd_seq_ev_is_ump(event)) {
+		if (!(dest->filter & SNDRV_SEQ_FILTER_NO_CONVERT)) {
 			result = snd_seq_deliver_from_ump(client, dest, dest_port,
 							  event, atomic, hop);
 			goto __skip;
-		} else if (snd_seq_client_is_ump(dest)) {
+		} else if (dest->type == USER_CLIENT &&
+			   !snd_seq_client_is_ump(dest)) {
+			result = 0; // drop the event
+			goto __skip;
+		}
+	} else if (snd_seq_client_is_ump(dest)) {
+		if (!(dest->filter & SNDRV_SEQ_FILTER_NO_CONVERT)) {
 			result = snd_seq_deliver_to_ump(client, dest, dest_port,
 							event, atomic, hop);
 			goto __skip;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-17 11:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-18 23:24 Ask snd_seq_set_client_midi_version Correo Alternativo
2024-12-30 11:34 ` Takashi Iwai
2025-02-01 23:11 ` Possible bug with snd_seq_event_input_pending Carlos
2025-02-17 11:04   ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.