You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/16 07:40:43 UTC
(nuttx) 02/02: sim_offload: add MONO channel encode method and set samplerate before encode.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit de2920605dee71f52ab6bd61793dcfefa91e40e8
Author: wurui3 <wu...@xiaomi.com>
AuthorDate: Thu Nov 23 11:28:36 2023 +0800
sim_offload: add MONO channel encode method and set samplerate before encode.
According to different pcm data format, set real sample rate and encode separately.
Signed-off-by: wurui3 <wu...@xiaomi.com>
---
arch/sim/src/sim/sim_offload.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/arch/sim/src/sim/sim_offload.c b/arch/sim/src/sim/sim_offload.c
index 77577be724..49b763f9f9 100644
--- a/arch/sim/src/sim/sim_offload.c
+++ b/arch/sim/src/sim/sim_offload.c
@@ -457,6 +457,7 @@ void *sim_audio_lame_init(struct audio_info_s *info)
{
lame_set_num_channels(codec->gfp, info->channels);
lame_set_mode(codec->gfp, info->channels > 1 ? STEREO : MONO);
+ lame_set_in_samplerate(codec->gfp, (int)info->samplerate);
}
ret = lame_init_params(codec->gfp);
@@ -510,8 +511,17 @@ static int sim_audio_lame_encode(void *handle,
chs = lame_get_num_channels(codec->gfp);
samples = insize / (sizeof(short int) * chs);
- ret = lame_encode_buffer_interleaved(codec->gfp, (short int *)in, samples,
- codec->out, codec->max);
+ if (chs > 1)
+ {
+ ret = lame_encode_buffer_interleaved(codec->gfp, (short int *)in,
+ samples, codec->out, codec->max);
+ }
+ else
+ {
+ ret = lame_encode_buffer(codec->gfp, (short int *)in, NULL, samples,
+ codec->out, codec->max);
+ }
+
if (ret < 0)
{
return ret;