mirror of
https://github.com/apache/nuttx.git
synced 2026-08-09 22:45:08 +00:00
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 <wurui3@xiaomi.com>
This commit is contained in:
parent
42e416d054
commit
de2920605d
1 changed files with 12 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue