ALSA: snd-usb-caiaq: only warn once on streaming errors
authorDaniel Mack <daniel@caiaq.de>
Wed, 18 Mar 2009 10:03:53 +0000 (11:03 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 18 Mar 2009 10:27:51 +0000 (11:27 +0100)
Limit the number of printed warnings to one in case of streaming errors.
printk() happens to be expensive, especially in code called as often as
here.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/caiaq/caiaq-audio.c
sound/usb/caiaq/caiaq-device.h

index fc6d571eeac68c2879dcc6cd85c82931a6042635..577b1129de0e68641d2363a84959c7ac402a898f 100644 (file)
@@ -114,6 +114,7 @@ static int stream_start(struct snd_usb_caiaqdev *dev)
        dev->output_panic = 0;
        dev->first_packet = 1;
        dev->streaming = 1;
+       dev->warned = 0;
 
        for (i = 0; i < N_URBS; i++) {
                ret = usb_submit_urb(dev->data_urbs_in[i], GFP_ATOMIC);
@@ -406,10 +407,11 @@ static void read_in_urb(struct snd_usb_caiaqdev *dev,
                break;
        }
 
-       if (dev->input_panic || dev->output_panic) {
+       if ((dev->input_panic || dev->output_panic) && !dev->warned) {
                debug("streaming error detected %s %s\n", 
                                dev->input_panic ? "(input)" : "",
                                dev->output_panic ? "(output)" : "");
+               dev->warned = 1;
        }
 }
 
index 0560c327d99691bdafade458439bdec86405bf97..098b194f72592a0c7e992b8ee198698968d62657 100644 (file)
@@ -89,7 +89,7 @@ struct snd_usb_caiaqdev {
        int audio_out_buf_pos[MAX_STREAMS];
        int period_in_count[MAX_STREAMS];
        int period_out_count[MAX_STREAMS];
-       int input_panic, output_panic;
+       int input_panic, output_panic, warned;
        char *audio_in_buf, *audio_out_buf;
        unsigned int samplerates;