Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Direct MIDI event delivery to ALSA sequencer's hardware port without any connections/subscriptions fails with -ENODEV.
@ 2024-10-31  7:49 giedrius
  2024-10-31  9:03 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: giedrius @ 2024-10-31  7:49 UTC (permalink / raw)
  To: alsa-devel

Hello,

I had written an `aseqsend` utility to send MIDI events from hex strings to ALSA sequencer ports, similar to the -S arg of `amidi`, but I just noticed that while sending events directly to application ALSA Sequencer ports works just fine, trying to send to a hardware MIDI port fails with -19 (-ENODEV).

Here's the aseqsend utility code, the highlighted line is the one returning -ENODEV:

https://github.com/BlokasLabs/aseqsend/blob/main/aseqsend.c#L173

Here's some sample commands showcasing the problem (I've added a printf with drain result just after the indicated line above locally):

https://paste.debian.net/hidden/9690d660/

It shows that in case there's no active subscriptions to the port, the event delivery fails, with no data ever reaching the hardware device. As long as there's at least one subscription to the port, it works ok. I've reproduced this on 5.15.36-rt41-v7+ and 6.6.58-v8-16k (running on Raspberry Pi, based on https://github.com/raspberrypi/linux)

I've traced the -ENODEV to be returned at this location: https://elixir.bootlin.com/linux/v6.6.58/source/sound/core/seq/seq_midi.c#L134

Whenever there's a subscription, the 'substream' is not NULL.

But what I would naturally expect is for the events to get delivered to the hardware port when using direct addressing, regardless of its subscription status, the same way how it's possible to send events to application aseq ports:

-- Terminal 1 --
patch@patchbox:~ $ aseqdump
Waiting for data at port 128:0. Press Ctrl+C to end.
Source  Event                  Ch  Data
129:0   Note on                 0, note 64, velocity 48

-- Terminal 2 --
patch@patchbox:~/work/aseqsend $ ./aseqsend 128:0 90 40 30
drain: 0


Is this a bug in ALSA Sequencer, or is my expectation of being able to write directly to a hardware ALSA sequencer port incorrect?

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

end of thread, other threads:[~2024-10-31  9:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31  7:49 Direct MIDI event delivery to ALSA sequencer's hardware port without any connections/subscriptions fails with -ENODEV giedrius
2024-10-31  9:03 ` Takashi Iwai
2024-10-31  9:52   ` Giedrius Trainavičius
2024-10-31  9:59     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox