[PATCH] USB: gadget: u_audio: Initialize capture memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using USB audio gadget in capture mode with an non blocking API may
result in getting uninitialized memory samples. That ensure that the
memory is initialized to 0 when the stream is prepared.

Signed-off-by: Lionel Koenig <lionel.koenig@xxxxxxxxx>
---
 drivers/usb/gadget/function/u_audio.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
index 7ec6a996af26..6d708494ca77 100644
--- a/drivers/usb/gadget/function/u_audio.c
+++ b/drivers/usb/gadget/function/u_audio.c
@@ -317,6 +317,14 @@ static int uac_pcm_open(struct snd_pcm_substream *substream)
 	return 0;
 }
 
+static int uac_pcm_prepare(struct snd_pcm_substream *substream)
+{
+	struct snd_pcm_runtime *runtime = substream->runtime;
+
+	memset(runtime->dma_area,  0, runtime->dma_bytes);
+	return 0;
+}
+
 /* ALSA cries without these function pointers */
 static int uac_pcm_null(struct snd_pcm_substream *substream)
 {
@@ -331,7 +339,7 @@ static const struct snd_pcm_ops uac_pcm_ops = {
 	.hw_free = uac_pcm_hw_free,
 	.trigger = uac_pcm_trigger,
 	.pointer = uac_pcm_pointer,
-	.prepare = uac_pcm_null,
+	.prepare = uac_pcm_prepare,
 };
 
 static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep)
-- 
2.24.0.393.g34dc348eaf-goog




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux