]> err.no Git - linux-2.6/commitdiff
[ALSA] Fix substream selection in PCM and rawmidi
authorTakashi Iwai <tiwai@suse.de>
Fri, 4 Aug 2006 10:57:19 +0000 (12:57 +0200)
committerJaroslav Kysela <perex@suse.cz>
Sat, 23 Sep 2006 08:39:59 +0000 (10:39 +0200)
The PCM and rawmidi substreams can be selected explicitly by opening
control handle and set via *_PREFER_SUBDEVICE ioctl.  But, when
multiple controls are opened, the driver gets confused.
The patch fixes the initialization of prefer_*_subdevice and the
check of multiple controls.  The first set subdevice is picked up
as the valid one.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
sound/core/control.c
sound/core/pcm.c
sound/core/rawmidi.c

index 31ad58154c06c8959ed19079237543a2d4f55b0c..ac1442682eace2e8bb77f9389fc023511d8ec46f 100644 (file)
@@ -75,6 +75,8 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
        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);
index f52178abf1209cbd141bad0c1f55838ca22ea2ee..ed3b09469560be86a7ddaa10183b845dfbf8bd3e 100644 (file)
@@ -792,7 +792,8 @@ int snd_pcm_attach_substream(struct snd_pcm *pcm, int stream,
                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);
index 8a2bdfae63e39968fde086198f0e84243e2aaf62..269c467ca9bb2ba76f3c001f1d824414ccb5bd07 100644 (file)
@@ -430,7 +430,8 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
                        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);