Skip to content

Commit

Permalink
ALSA: snd-usb-caiaq: only warn once on streaming errors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Daniel Mack authored and Takashi Iwai committed Mar 18, 2009
1 parent 238c027 commit 1313e70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sound/usb/caiaq/caiaq-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion sound/usb/caiaq/caiaq-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 1313e70

Please sign in to comment.