tree e41056adf7f00cad4681051d4b7d6b524ea8a68f
parent 9624ea812c7afd2e403c56366cadddb9ecfb88c6
author Clemens Ladisch <[EMAIL PROTECTED]> Mon, 15 Aug 2005 08:25:50 +0200
committer Jaroslav Kysela <[EMAIL PROTECTED]> Tue, 30 Aug 2005 08:45:50 +0200

[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 <[EMAIL PROTECTED]>

 sound/usb/usbaudio.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -815,8 +815,14 @@ static int wait_clear_urbs(snd_usb_subst
  */
 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;
 }
 
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to