All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Marco Santamaria <marco.santamaria@gmail.com>
Cc: alsa-devel@alsa-project.org, Daniel Mack <daniel@caiaq.de>,
	Mysth-R <mysthr21@gmail.com>
Subject: Re: snd_usb_caiaq bug?
Date: Thu, 08 Jan 2009 12:20:52 +0100	[thread overview]
Message-ID: <s5h4p0at563.wl%tiwai@suse.de> (raw)
In-Reply-To: <31e66c9e0901071734t70c980a8t87f668f973b54635@mail.gmail.com>

At Thu, 8 Jan 2009 02:34:46 +0100,
Marco Santamaria wrote:
> 
> Unfortunately I have to correct my previous message.
> 
> After a load test with jack + qsynth + rosegarden (sample rate=88200, frames/
> period=256,  periods/buffer=3), using a 16 tracks midi file and a 29MB sound
> font, the following message appeared:
> 
> [ 1098.445807] ALSA /home/marco/build/linux-2.6.24-19-rt/alsa-1.0.17/
> driver-patched/alsa-driver-1.0.17/usb/caiaq/../../alsa-kernel/usb/caiaq/
> caiaq-midi.c:84: snd-usb-caiaq log: snd_usb_caiaq_midi_send(f64c66c0):
> usb_submit_urb() failed, -22

Hmm... what about this version?


Takashi

---
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/caiaq-device.h
index f9fbdba..ab56e73 100644
--- a/sound/usb/caiaq/caiaq-device.h
+++ b/sound/usb/caiaq/caiaq-device.h
@@ -75,6 +75,7 @@ struct snd_usb_caiaqdev {
 	wait_queue_head_t ep1_wait_queue;
 	wait_queue_head_t prepare_wait_queue;
 	int spec_received, audio_parm_answer;
+	int midi_out_active;
 
 	char vendor_name[CAIAQ_USB_STR_LEN];
 	char product_name[CAIAQ_USB_STR_LEN];
diff --git a/sound/usb/caiaq/caiaq-midi.c b/sound/usb/caiaq/caiaq-midi.c
index 30b57f9..18bbe38 100644
--- a/sound/usb/caiaq/caiaq-midi.c
+++ b/sound/usb/caiaq/caiaq-midi.c
@@ -59,6 +59,11 @@ static int snd_usb_caiaq_midi_output_open(struct snd_rawmidi_substream *substrea
 
 static int snd_usb_caiaq_midi_output_close(struct snd_rawmidi_substream *substream)
 {
+	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
+	if (dev->midi_out_active) {
+		usb_kill_urb(&dev->midi_out_urb);
+		dev->midi_out_active = 0;
+	}
 	return 0;
 }
 
@@ -69,7 +74,8 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	
 	dev->midi_out_buf[0] = EP1_CMD_MIDI_WRITE;
 	dev->midi_out_buf[1] = 0; /* port */
-	len = snd_rawmidi_transmit_peek(substream, dev->midi_out_buf+3, EP1_BUFSIZE-3);
+	len = snd_rawmidi_transmit(substream, dev->midi_out_buf + 3,
+				   EP1_BUFSIZE - 3);
 	
 	if (len <= 0)
 		return;
@@ -79,24 +85,24 @@ static void snd_usb_caiaq_midi_send(struct snd_usb_caiaqdev *dev,
 	
 	ret = usb_submit_urb(&dev->midi_out_urb, GFP_ATOMIC);
 	if (ret < 0)
-		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed, %d\n",
-				substream, ret);
+		log("snd_usb_caiaq_midi_send(%p): usb_submit_urb() failed,"
+		    "ret=%d, len=%d\n",
+		    substream, ret, len);
+	else
+		dev->midi_out_active = 1;
 }
 
 static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
 {
 	struct snd_usb_caiaqdev *dev = substream->rmidi->private_data;
 	
-	if (dev->midi_out_substream != NULL)
-		return;
-	
-	if (!up) {
+	if (up) {
+		dev->midi_out_substream = substream;
+		if (!dev->midi_out_active)
+			snd_usb_caiaq_midi_send(dev, substream);
+	} else {
 		dev->midi_out_substream = NULL;
-		return;
 	}
-	
-	dev->midi_out_substream = substream;
-	snd_usb_caiaq_midi_send(dev, substream);
 }
 
 
@@ -163,14 +169,13 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb)
 	struct snd_usb_caiaqdev *dev = urb->context;
       	char *buf = urb->transfer_buffer;
 	
+	dev->midi_out_active = 0;
 	if (urb->status != 0)
 		return;
 
 	if (!dev->midi_out_substream)
 		return;
 
-	snd_rawmidi_transmit_ack(dev->midi_out_substream, buf[2]);
-	dev->midi_out_substream = NULL;
 	snd_usb_caiaq_midi_send(dev, dev->midi_out_substream);
 }

  reply	other threads:[~2009-01-08 11:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-04 16:29 snd_usb_caiaq bug? Marco Santamaria
2009-01-07 10:56 ` Takashi Iwai
2009-01-07 15:41   ` Marco Santamaria
2009-01-07 16:35     ` Takashi Iwai
2009-01-07 18:46       ` Marco Santamaria
2009-01-07 20:06         ` Mysth-R
2009-01-07 22:52           ` Takashi Iwai
2009-01-08  0:59             ` Marco Santamaria
2009-01-08  1:34               ` Marco Santamaria
2009-01-08 11:20                 ` Takashi Iwai [this message]
2009-01-08 14:26                   ` Mysth-R
2009-01-08 14:37                     ` Takashi Iwai
2009-01-08 14:43                       ` Mysth-R
2009-01-08 14:46                         ` Takashi Iwai
2009-01-08 22:14                         ` Daniel Mack
2009-01-08 20:06                       ` Marco Santamaria
2009-01-08 22:11                       ` Daniel Mack
2009-01-09  6:54                         ` Takashi Iwai
2009-01-10 12:53                           ` Marco Santamaria
2009-01-11 12:03                             ` Takashi Iwai
2009-01-12 14:30                               ` Marco Santamaria

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=s5h4p0at563.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=daniel@caiaq.de \
    --cc=marco.santamaria@gmail.com \
    --cc=mysthr21@gmail.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.