From 12be1992de0af4a41fc4b187e008e11ec180cb69 Mon Sep 17 00:00:00 2001 From: Abhishek Akkabathula Date: Thu, 5 Sep 2024 19:31:47 +0530 Subject: [PATCH] framework, os/audio: fix issue with apb data size reinit previously, apb->nbytes was set to zero during dequeue. However, this data is still relavent during recoridng as it holds the audio data size. Hence, set apb->nbytes to zero in pcm_writei. Signed-off-by: Abhishek Akkabathula --- framework/src/tinyalsa/tinyalsa.c | 2 ++ os/audio/audio.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/src/tinyalsa/tinyalsa.c b/framework/src/tinyalsa/tinyalsa.c index 7d5074de68..b54515987b 100644 --- a/framework/src/tinyalsa/tinyalsa.c +++ b/framework/src/tinyalsa/tinyalsa.c @@ -504,6 +504,7 @@ int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) /* First time we will use empty pBuffer, and then wait until one of them dequeued */ if (pcm->buf_idx < pcm->buffer_cnt) { apb = pcm->pBuffers[pcm->buf_idx]; + apb->nbytes = 0; pcm->buf_idx++; } else { /* We dont have any empty buffers. wait for deque message from kernel */ @@ -515,6 +516,7 @@ int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) if (msg.msgId == AUDIO_MSG_DEQUEUE) { apb = (struct ap_buffer_s *)msg.u.pPtr; apb->flags = 0; + apb->nbytes = 0; } else if (msg.msgId == AUDIO_MSG_XRUN) { /* Underrun to be handled by client */ return -EPIPE; diff --git a/os/audio/audio.c b/os/audio/audio.c index ce39835a96..aae6fb0895 100644 --- a/os/audio/audio.c +++ b/os/audio/audio.c @@ -744,7 +744,6 @@ static inline void audio_dequeuebuffer(FAR struct audio_upperhalf_s *upper, FAR msg.session = session; #endif apb->flags |= AUDIO_APB_DEQUEUED; - apb->nbytes = 0; mq_send(upper->usermq, (FAR const char *)&msg, sizeof(msg), CONFIG_AUDIO_BUFFER_DEQUEUE_PRIO); } }