Skip to content

Commit 854cd0c

Browse files
yangyaleiacassis
authored andcommitted
nuttx/audio: clear apb buffer when playback dequeue
memset apb buffer to zero when dequeue Signed-off-by: yangyalei <yangyalei@xiaomi.com>
1 parent b13defe commit 854cd0c

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

audio/audio.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ static int audio_configure(FAR struct file *filep,
477477
/* INPUT/OUTPUT configure success here */
478478

479479
audio_setstate(upper, AUDIO_STATE_PREPARED);
480+
upper->info.type = caps->ac_type;
480481
upper->info.format = caps->ac_subtype;
481482
upper->info.channels = caps->ac_channels;
482483
upper->info.subformat = caps->ac_format.b[0];
@@ -1424,6 +1425,12 @@ static inline void audio_dequeuebuffer(FAR struct audio_upperhalf_s *upper,
14241425

14251426
audinfo("Entry\n");
14261427

1428+
if (upper->info.type == AUDIO_TYPE_OUTPUT)
1429+
{
1430+
apb->nbytes = 0;
1431+
memset(apb->samp, 0, apb->nmaxbytes);
1432+
}
1433+
14271434
flags = spin_lock_irqsave_nopreempt(&upper->spinlock);
14281435
upper->status->tail++;
14291436
audio_try_enqueue(upper);

include/nuttx/audio/audio.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -732,16 +732,12 @@ struct audio_caps_desc_s
732732

733733
struct audio_info_s
734734
{
735-
uint32_t samplerate; /* Sample Rate of the audio data */
736-
uint8_t channels; /* Number of channels (1, 2, 5, 7) */
737-
uint8_t format; /* Audio data format */
738-
uint8_t subformat; /* Audio subformat
739-
* (maybe should be combined with format?)
740-
*/
741-
742-
/* Codec extra params */
743-
744-
struct audio_codec_s codec;
735+
uint32_t samplerate; /* Sample Rate of the audio data */
736+
uint8_t channels; /* Number of channels (1, 2, 5, 7) */
737+
uint8_t format; /* Audio data format */
738+
uint8_t subformat; /* Audio subformat */
739+
uint8_t type; /* device type */
740+
struct audio_codec_s codec; /* Codec extra params */
745741
};
746742

747743
/* This structure describes the preferred number and size of

0 commit comments

Comments
 (0)