AnsweredAssumed Answered

About the problem of i.MX6 alsa setup the rate

Question asked by liang yu on Jul 3, 2017
Latest reply on Jul 17, 2017 by liang yu

Hi everyone, I met a problem about the i.MX6 alsa setup the rate. When I use the aplay to play a wav file, the log show it is ok,but when I setup alsa param in linphone, the alsa problem comes. I can't setup the rate what I want. The log is follow as:

 

platform: i.MX6 LTIB

 

aplay -vv /unit_tests/audio8k16S.wav

aplay log:

   aplay -vv /unit_tests/audio8k16S.wav        (the red parts I add it in alsa-lib)
=======>best=8000,val=8000,min=8000,max=8000
Playing WAVE '/unit_tests/audio8k16S.wav' : Signed 16 bit Little Endian, Rate 8000 Hz, Stereo
====>min=2124648108
====>min=2124648108
====>min=2124647444
====>min=2124647444
====>min=2124647444
====>min=2124647444
====>min=2124647444
====>min=2124646172
====>min=2124646172
=======>best=8000,val=8000,min=8000,max=8000
Plug PCM: Direct Stream Mixing PCM
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 8000
exact rate : 8000 (8000/1)
msbits : 16
buffer_size : 2880
period_size : 320
period_time : 40000
tstamp_mode : NONE
period_step : 1
avail_min : 320
period_event : 0
start_threshold : 2880
stop_threshold : 2880
silence_threshold: 0
silence_size : 0
boundary : 1509949440
Hardware PCM card 0 'wm8960-audio' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 8000
exact rate : 8000 (8000/1)
msbits : 16
buffer_size : 2880
period_size : 320
period_time : 40000
tstamp_mode : ENABLE
period_step : 1
avail_min : 320
period_event : 0
start_threshold : 1
stop_threshold : 1509949440
silence_threshold: 0
silence_size : 1509949440
boundary : 1509949440
appl_ptr : 0
hw_ptr : 0
##+ | 03%

#############################################################

 

linphone alsa log:

 

MSFilePlayer[0x6fec90]: /unit_tests/audio8k16S.wav opened: rate=8000,channel=2
alsa_open_w: opening default at 8000Hz, bits=16, stereo=0
=======>best=8000,val=8000,min=8000,max=8000
====>min=743887532
====>min=743887532
====>min=743886868
====>min=743886868
====>min=743886868
====>min=743886868
====>min=743886868
=============11111=============>
ACCESS: RW_INTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 16
CHANNELS: 1
RATE: [4000 4294967295)
PERIOD_TIME: 40000
PERIOD_SIZE: [160 171798692)
PERIOD_BYTES: [320 343597384)
PERIODS: (0 9663677)
BUFFER_TIME: [1 4294967295]
BUFFER_SIZE: [320 1546188226]
BUFFER_BYTES: [640 3092376452]
TICK_TIME: ALL
===========>exact_uvalue=8000
=======>best=716636324,val=716636324,min=716636324,max=716636324
===============2222================>
ACCESS: RW_INTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 16
CHANNELS: 1
RATE: 716636324
PERIOD_TIME: 40000
PERIOD_SIZE: (28665452 28665453)
PERIOD_BYTES: (57330904 57330906)
PERIODS: (1 10)
BUFFER_TIME: (79999 360000)
BUFFER_SIZE: [57330905 257989076]
BUFFER_BYTES: [114661810 515978152]
TICK_TIME: ALL

 

In linphone Log, the red parts in alsa-lib(I add) , the blue is before snd_pcm_hw_params_set_period_size_near, and the green is after snd_pcm_hw_params_set_period_size_near function.

 

I want to know why same code show different result. What make the alsa "snd_pcm_hw_params_set_period_size_near" wrong?

 

 

Thank you!

Outcomes