Skip to content

Commit

Permalink
framework, os/audio: fix issue with apb data size reinit
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
abhishek-samsung authored and Taejun-Kwon committed Sep 9, 2024
1 parent 4b31e3a commit 12be199
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions framework/src/tinyalsa/tinyalsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion os/audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 12be199

Please sign in to comment.