Skip to content

Commit

Permalink
ALSA: snd-usb-caiaq: Missing lock around use of buffer positions
Browse files Browse the repository at this point in the history
Fix a race which causes snd_pcm_update_hw_ptr_pos() to report a bug.

Signed-off-by: Mark Hills <mark@pogo.org.uk>
Acked-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Mark Hills authored and Takashi Iwai committed Oct 30, 2009
1 parent e8e0929 commit 3702b08
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sound/usb/caiaq/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,22 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
{
int index = sub->number;
struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub);
snd_pcm_uframes_t ptr;

spin_lock(&dev->spinlock);

if (dev->input_panic || dev->output_panic)
return SNDRV_PCM_POS_XRUN;
ptr = SNDRV_PCM_POS_XRUN;

if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK)
return bytes_to_frames(sub->runtime,
ptr = bytes_to_frames(sub->runtime,
dev->audio_out_buf_pos[index]);
else
return bytes_to_frames(sub->runtime,
ptr = bytes_to_frames(sub->runtime,
dev->audio_in_buf_pos[index]);

spin_unlock(&dev->spinlock);
return ptr;
}

/* operators for both playback and capture */
Expand Down

0 comments on commit 3702b08

Please sign in to comment.