Skip to contentSkip to conversation

rawmidi: substream 0 is always selected, ignoring parameter

DISCUSSION GitHub issues - opened 1 participant 1 message Nov 16, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

alsa-project/alsa-gobject issue #53 was opened from takaswie:

This issue is confirmed in v0.1.0 release.

ALSARawmidi.StreamPair.open() has subdevice_id to select one of substreams supported by the Rawmidi device. However, this parameter is ignored and the first substream is always selected.

Currently, the procedure in ALSARawmidi.StreamPair.open() to open Rawmidi character device is:

1. open control character device
2. ioctl call with SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE
3. close control character device
4. open rawmidi character device

The cause to ignore is step 3. After closing control character device, private structure assigned to file descriptor of control character device is dropped in kernel land. At step 4, the selection information is already lost and the first substream is assigned to file descriptor of rawmidi character device.

The solution is to keep file descriptor of control character device when opening rawmidi character device, thus the procedure should be:

1. open control character device
2. ioctl call with SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE
3. open rawmidi character device
4. close control character device

Issue URL : https://github.com/alsa-project/alsa-gobject/issues/53
Repository URL: https://github.com/alsa-project/alsa-gobject