Steps will reproduce the problem:
Play a big sample rate stream after closing a small sample rate one.
(1) sox -b 16 -r 12000 --buffer 256 -c 2 -n -t alsa default synth sine 1000 sine 1000
Now the min_cb_level will be set to 64.
Audio Debug Stats:
-------------devices------------
Output dev: kbl_r5514_5663_max: :0,0
buffer_size: 16384
min_buffer_level: 0
min_cb_level: 64
max_cb_level: 256
frame_rate: 48000
num_channels: 2
est_rate_ratio: 0.999995
num_underruns: 2
num_severe_underruns: 0
-------------stream_dump------------
stream: 2e0000 dev: 6
direction: Output
stream_type: CRAS_STREAM_TYPE_DEFAULT
buffer_frames: 128
cb_threshold: 64
frame_rate: 12000
num_channels: 2
longest_fetch_sec: 0.000195014
num_overruns: 0
channel map:0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1
(2) Close stream in (1).
Now the device min_cb_level for device is still 64 for 10 sec.
-------------devices------------
Output dev: kbl_r5514_5663_max: :0,0
buffer_size: 16384
min_buffer_level: 0
min_cb_level: 64
max_cb_level: 0
frame_rate: 48000
num_channels: 2
est_rate_ratio: 1.000000
num_underruns: 2
num_severe_underruns: 0
(3) sox -b 16 -r 48000 --buffer 8192 -c 2 -n -t alsa default synth sine 800 sine 800
Then you can hear device underrun easily, since it is still using min_cb_level=64.
-------------devices------------
Output dev: kbl_r5514_5663_max: :0,0
buffer_size: 16384
min_buffer_level: 0
min_cb_level: 64
max_cb_level: 2048
frame_rate: 48000
num_channels: 2
est_rate_ratio: 1.000000
num_underruns: 2
num_severe_underruns: 0
-------------stream_dump------------
stream: 3740000 dev: 6
direction: Output
stream_type: CRAS_STREAM_TYPE_DEFAULT
buffer_frames: 4096
cb_threshold: 2048
frame_rate: 48000
num_channels: 2
longest_fetch_sec: 0.000000000
num_overruns: 0
channel map:0 1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[Action]
Need to adjust min_cb_level for device when adding a new input stream in (3).
Comment 1 by bugdroid1@chromium.org
, May 11 2018