提交 3702b082 编写于 作者: M Mark Hills 提交者: Takashi Iwai

ALSA: snd-usb-caiaq: Missing lock around use of buffer positions

Fix a race which causes snd_pcm_update_hw_ptr_pos() to report a bug.
Signed-off-by: NMark Hills <mark@pogo.org.uk>
Acked-by: NDaniel Mack <daniel@caiaq.de>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 e8e0929d
...@@ -269,16 +269,22 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub) ...@@ -269,16 +269,22 @@ snd_usb_caiaq_pcm_pointer(struct snd_pcm_substream *sub)
{ {
int index = sub->number; int index = sub->number;
struct snd_usb_caiaqdev *dev = snd_pcm_substream_chip(sub); 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) if (dev->input_panic || dev->output_panic)
return SNDRV_PCM_POS_XRUN; ptr = SNDRV_PCM_POS_XRUN;
if (sub->stream == SNDRV_PCM_STREAM_PLAYBACK) 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]); dev->audio_out_buf_pos[index]);
else else
return bytes_to_frames(sub->runtime, ptr = bytes_to_frames(sub->runtime,
dev->audio_in_buf_pos[index]); dev->audio_in_buf_pos[index]);
spin_unlock(&dev->spinlock);
return ptr;
} }
/* operators for both playback and capture */ /* operators for both playback and capture */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册