[ALSA] usb-audio: properly lock hwptr_done accesses
[linux-2.6.git] / sound / usb / usbaudio.c
index 3f7930c0b6168e58f7bfa13e68d7f6c9ed43cfd4..8d4a085f642a2ac347a73b4c448976fc493e2ab4 100644 (file)
@@ -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;
 }