aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2005-08-15 08:25:50 +0200
committerJaroslav Kysela <perex@suse.cz>2005-08-30 08:45:50 +0200
commitdaa150ef7d437d17973210f47a1c58623415df94 (patch)
treee41056adf7f00cad4681051d4b7d6b524ea8a68f /sound
parent9624ea812c7afd2e403c56366cadddb9ecfb88c6 (diff)
[ALSA] usb-audio: properly lock hwptr_done accesses
USB generic driver Take the substream lock when reading hwptr_done to avoid a race condition with the updates in the URB callbacks. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/usbaudio.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 3f7930c0b61..8d4a085f642 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -815,8 +815,14 @@ static int wait_clear_urbs(snd_usb_substream_t *subs)
*/
static snd_pcm_uframes_t snd_usb_pcm_pointer(snd_pcm_substream_t *substream)
{
- snd_usb_substream_t *subs = (snd_usb_substream_t *)substream->runtime->private_data;
- return subs->hwptr_done;
+ snd_usb_substream_t *subs;
+ snd_pcm_uframes_t hwptr_done;
+
+ subs = (snd_usb_substream_t *)substream->runtime->private_data;
+ spin_lock(&subs->lock);
+ hwptr_done = subs->hwptr_done;
+ spin_unlock(&subs->lock);
+ return hwptr_done;
}