diff mbox

[2/7] ALSA: USB-audio: Also move out hwptr_done wrap from prepare_playback_urb()

Message ID 1444906657-16791-3-git-send-email-ricardw@axis.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ricard Wanderlof Oct. 15, 2015, 10:57 a.m. UTC
Refactoring in preparation for adding Zoom R16 quirk.

Signed-off-by: Ricard Wanderlof <ricardw@axis.com>
---
 sound/usb/pcm.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 4292bad..ee8dd9e 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -1383,6 +1383,8 @@  static inline void fill_playback_urb_dsd_dop(struct snd_usb_substream *subs,
 			subs->hwptr_done++;
 		}
 	}
+	if (subs->hwptr_done >= runtime->buffer_size * stride)
+		subs->hwptr_done -= runtime->buffer_size * stride;
 }
 
 static void copy_to_urb(struct snd_usb_substream *subs,
@@ -1403,6 +1405,8 @@  static void copy_to_urb(struct snd_usb_substream *subs,
 		       runtime->dma_area + subs->hwptr_done, bytes);
 	}
 	subs->hwptr_done += bytes;
+	if (subs->hwptr_done >= runtime->buffer_size * stride)
+		subs->hwptr_done -= runtime->buffer_size * stride;
 }
 
 static void prepare_playback_urb(struct snd_usb_substream *subs,
@@ -1480,14 +1484,13 @@  static void prepare_playback_urb(struct snd_usb_substream *subs,
 		}
 
 		subs->hwptr_done += bytes;
+		if (subs->hwptr_done >= runtime->buffer_size * stride)
+			subs->hwptr_done -= runtime->buffer_size * stride;
 	} else {
 		/* usual PCM */
 		copy_to_urb(subs, urb, stride, bytes);
 	}
 
-	if (subs->hwptr_done >= runtime->buffer_size * stride)
-		subs->hwptr_done -= runtime->buffer_size * stride;
-
 	/* update delay with exact number of samples queued */
 	runtime->delay = subs->last_delay;
 	runtime->delay += frames;