At Thu, 13 May 2004 10:53:48 -0700,
Loc Ho wrote:
> 
> Hi,
> 
> Also, after looking at the snd memory allocation routines, the
> unique tag are type, id, and flag. The type is "continous". The id is
> formated by the device ID, stream number, and substream number. The
> flag is the kernel memory flag. I already discussed the ID in my
> previous email (see below). Therefore, it will NOT be unique across
> multiple card!!!  

hmm, you're right.

obviously it's a bug of snd-usb-audio.
the attached patch should fix the problem.


Takashi
Index: alsa-kernel/usb/usbaudio.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/usb/usbaudio.c,v
retrieving revision 1.100
diff -u -r1.100 usbaudio.c
--- alsa-kernel/usb/usbaudio.c  7 May 2004 10:08:49 -0000       1.100
+++ alsa-kernel/usb/usbaudio.c  13 May 2004 18:05:45 -0000
@@ -2036,6 +2036,7 @@
 static void init_substream(snd_usb_stream_t *as, int stream, struct audioformat *fp)
 {
        snd_usb_substream_t *subs = &as->substream[stream];
+       snd_pcm_substream_t *pcms;
 
        INIT_LIST_HEAD(&subs->fmt_list);
        spin_lock_init(&subs->lock);
@@ -2047,7 +2048,12 @@
                subs->ops = audio_urb_ops[stream];
        else
                subs->ops = audio_urb_ops_high_speed[stream];
-       snd_pcm_lib_preallocate_pages(as->pcm->streams[stream].substream,
+       /* set up the unique device id with the card index number */
+       pcms = as->pcm->streams[stream].substream;
+       pcms->dma_device.id = (as->pcm->device << 16) |
+               (pcms->stream << 8) | (pcms->number + 1) |
+               (as->chip->card->number + 1) << 24;
+       snd_pcm_lib_preallocate_pages(pcms,
                                      SNDRV_DMA_TYPE_CONTINUOUS,
                                      snd_dma_continuous_data(GFP_KERNEL),
                                      64 * 1024, 128 * 1024);

Reply via email to