ALSA: snd-usb-caiaq: drop bogus iso packets

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Thursday, March 26, 2009 - 12:19 pm

Gitweb:     http://git.kernel.org/linus/9311c9b4f12218b588e51806c44d290cfec678a3
Commit:     9311c9b4f12218b588e51806c44d290cfec678a3
Parent:     1313e7041480f523a09dedc7ef2185d8ee94c163
Author:     Daniel Mack <daniel@caiaq.de>
AuthorDate: Wed Mar 18 11:03:54 2009 +0100
Committer:  Takashi Iwai <tiwai@suse.de>
CommitDate: Wed Mar 18 11:31:08 2009 +0100

    ALSA: snd-usb-caiaq: drop bogus iso packets
    
    Drop inbound packets that are smaller than expected. This has been
    observed at the very beginning of the streaming transaction.
    
    And when the hardware is in panic mode (which can only very rarely
    happen in case of massive EMI chaos), mute the input channels.
    
    Signed-off-by: Daniel Mack <daniel@caiaq.de>
    Tested-by: Mark Hills <mark@pogo.org.uk>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/usb/caiaq/caiaq-audio.c  |    6 ++++++
 sound/usb/caiaq/caiaq-device.c |    2 ++
 sound/usb/caiaq/caiaq-device.h |    2 +-
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/sound/usb/caiaq/caiaq-audio.c b/sound/usb/caiaq/caiaq-audio.c
index 577b112..08d51e0 100644
--- a/sound/usb/caiaq/caiaq-audio.c
+++ b/sound/usb/caiaq/caiaq-audio.c
@@ -377,6 +377,9 @@ static void read_in_urb_mode2(struct snd_usb_caiaqdev *dev,
 
 		for (stream = 0; stream < dev->n_streams; stream++, i++) {
 			sub = dev->sub_capture[stream];
+			if (dev->input_panic)
+				usb_buf[i] = 0;
+
 			if (sub) {
 				struct snd_pcm_runtime *rt = sub->runtime;
 				char *audio_buf = rt->dma_area;
@@ -398,6 +401,9 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
 	if (!dev->streaming)
 		return;
 
+	if (iso->actual_length < dev->bpp)
+		return;
+
 	switch (dev->spec.data_alignment) {
 	case 0:
 		read_in_urb_mode0(dev, urb, iso);
diff --git a/sound/usb/caiaq/caiaq-device.c b/sound/usb/caiaq/caiaq-device.c
index 5736669..336a93d 100644
--- a/sound/usb/caiaq/caiaq-device.c
+++ b/sound/usb/caiaq/caiaq-device.c
@@ -251,6 +251,8 @@ int snd_usb_caiaq_set_audio_params (struct snd_usb_caiaqdev *dev,
 		
 	if (dev->audio_parm_answer != 1) 
 		debug("unable to set the device's audio params\n");
+	else
+		dev->bpp = bpp;
 
 	return dev->audio_parm_answer == 1 ? 0 : -EINVAL;
 }
diff --git a/sound/usb/caiaq/caiaq-device.h b/sound/usb/caiaq/caiaq-device.h
index 098b194..4cce1ad 100644
--- a/sound/usb/caiaq/caiaq-device.h
+++ b/sound/usb/caiaq/caiaq-device.h
@@ -91,7 +91,7 @@ struct snd_usb_caiaqdev {
 	int period_out_count[MAX_STREAMS];
 	int input_panic, output_panic, warned;
 	char *audio_in_buf, *audio_out_buf;
-	unsigned int samplerates;
+	unsigned int samplerates, bpp;
 
 	struct snd_pcm_substream *sub_playback[MAX_STREAMS];
 	struct snd_pcm_substream *sub_capture[MAX_STREAMS];
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
ALSA: snd-usb-caiaq: drop bogus iso packets, Linux Kernel Mailing ..., (Thu Mar 26, 12:19 pm)