This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 854cd0ca216cf381cdb280f34bb184f1727ad0d7 Author: yangyalei <[email protected]> AuthorDate: Mon Aug 18 14:24:15 2025 +0800 nuttx/audio: clear apb buffer when playback dequeue memset apb buffer to zero when dequeue Signed-off-by: yangyalei <[email protected]> --- audio/audio.c | 7 +++++++ include/nuttx/audio/audio.h | 16 ++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 28bf839f899..855d9772411 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -477,6 +477,7 @@ static int audio_configure(FAR struct file *filep, /* INPUT/OUTPUT configure success here */ audio_setstate(upper, AUDIO_STATE_PREPARED); + upper->info.type = caps->ac_type; upper->info.format = caps->ac_subtype; upper->info.channels = caps->ac_channels; upper->info.subformat = caps->ac_format.b[0]; @@ -1424,6 +1425,12 @@ static inline void audio_dequeuebuffer(FAR struct audio_upperhalf_s *upper, audinfo("Entry\n"); + if (upper->info.type == AUDIO_TYPE_OUTPUT) + { + apb->nbytes = 0; + memset(apb->samp, 0, apb->nmaxbytes); + } + flags = spin_lock_irqsave_nopreempt(&upper->spinlock); upper->status->tail++; audio_try_enqueue(upper); diff --git a/include/nuttx/audio/audio.h b/include/nuttx/audio/audio.h index d175b049e87..624c4ea836e 100644 --- a/include/nuttx/audio/audio.h +++ b/include/nuttx/audio/audio.h @@ -732,16 +732,12 @@ struct audio_caps_desc_s struct audio_info_s { - uint32_t samplerate; /* Sample Rate of the audio data */ - uint8_t channels; /* Number of channels (1, 2, 5, 7) */ - uint8_t format; /* Audio data format */ - uint8_t subformat; /* Audio subformat - * (maybe should be combined with format?) - */ - - /* Codec extra params */ - - struct audio_codec_s codec; + uint32_t samplerate; /* Sample Rate of the audio data */ + uint8_t channels; /* Number of channels (1, 2, 5, 7) */ + uint8_t format; /* Audio data format */ + uint8_t subformat; /* Audio subformat */ + uint8_t type; /* device type */ + struct audio_codec_s codec; /* Codec extra params */ }; /* This structure describes the preferred number and size of
