All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Loc Ho <loc@pacificconsultants.com>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: ALSA Memory Allocation Bug
Date: Thu, 13 May 2004 20:06:45 +0200	[thread overview]
Message-ID: <s5had0cnqve.wl@alsa2.suse.de> (raw)
In-Reply-To: <D22B281CC561444AA27F7F6C6C9E3E6102F549@mtvs4.pcllc.net>

[-- Attachment #1: Type: text/plain, Size: 540 bytes --]

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

[-- Attachment #2: Type: text/plain, Size: 1185 bytes --]

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	other threads:[~2004-05-13 18:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <D22B281CC561444AA27F7F6C6C9E3E6102F549@mtvs4.pcllc.net>
2004-05-13 18:06 ` Takashi Iwai [this message]
2004-05-13 18:18   ` ALSA Memory Allocation Bug Takashi Iwai
     [not found] <D22B281CC561444AA27F7F6C6C9E3E6102F548@mtvs4.pcllc.net>
2004-05-13 17:54 ` Takashi Iwai
2004-05-13  1:40 Loc Ho
2004-05-13  9:24 ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5had0cnqve.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=loc@pacificconsultants.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.