At Wed, 2 Aug 2006 23:54:36 +0400, Dmitry Baikov wrote: > > On 8/2/06, Takashi Iwai <tiwai@xxxxxxx> wrote: > > Does you device have really mulptile midi ports? > > Take a look at /proc/asound/card1/midi0, and how many ports exist > > there. > > If I do not open ctl, I can open all ports - there are 4 ports > actually, it's ESI M4U Thanks. This problem is a bit deeper than I thought. The pcm and rawmidi opens check the control handles assigned to that file and retrieve the preferred subdevice number. There are two bugs around there: 1. The control handle doesn't initialize prefer_*_subdevice to -1, which is the default value. 2. When multiple controls are opened from the same process, only the first one is taken regardless of which value. The patch below should fix the problems. Give it a try. Takashi diff -r a61a00a91fac core/control.c --- a/core/control.c Wed Aug 02 21:12:09 2006 +0200 +++ b/core/control.c Thu Aug 03 13:13:39 2006 +0200 @@ -75,6 +75,8 @@ static int snd_ctl_open(struct inode *in init_waitqueue_head(&ctl->change_sleep); spin_lock_init(&ctl->read_lock); ctl->card = card; + ctl->prefer_pcm_subdevice = -1; + ctl->prefer_rawmidi_subdevice = -1; ctl->pid = current->pid; file->private_data = ctl; write_lock_irqsave(&card->ctl_files_rwlock, flags); diff -r a61a00a91fac core/pcm.c --- a/core/pcm.c Wed Aug 02 21:12:09 2006 +0200 +++ b/core/pcm.c Thu Aug 03 13:12:55 2006 +0200 @@ -792,7 +792,8 @@ int snd_pcm_attach_substream(struct snd_ kctl = snd_ctl_file(list); if (kctl->pid == current->pid) { prefer_subdevice = kctl->prefer_pcm_subdevice; - break; + if (prefer_subdevice != -1) + break; } } up_read(&card->controls_rwsem); diff -r a61a00a91fac core/rawmidi.c --- a/core/rawmidi.c Wed Aug 02 21:12:09 2006 +0200 +++ b/core/rawmidi.c Thu Aug 03 13:12:40 2006 +0200 @@ -430,7 +430,8 @@ static int snd_rawmidi_open(struct inode kctl = snd_ctl_file(list); if (kctl->pid == current->pid) { subdevice = kctl->prefer_rawmidi_subdevice; - break; + if (subdevice != -1) + break; } } up_read(&card->controls_rwsem); ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-devel