New issue
Advanced search Search tips

Issue 841689 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug



Sign in to add a comment

CRAS: Device underrun by wrong min_cb_level settings

Project Member Reported by paulhsia@chromium.org, May 10 2018

Issue description

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).
 
Project Member

Comment 1 by bugdroid1@chromium.org, May 11 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/adhd/+/9ba33f943bb7f25220cb3374a8b0e26d0273dddf

commit 9ba33f943bb7f25220cb3374a8b0e26d0273dddf
Author: paulhsia <paulhsia@chromium.org>
Date: Fri May 11 19:10:51 2018

CRAS: cras_iodev - adjust min_cb_level when removing the last stream.

When removing the last stream, device's min callback level will be set to the
last min callback level and wait for 10 secs.
If the last min callback level is smaller than the next playback stream
requirement, the min callback level won't be changed and device will underrun
easily. We should set device min call back level to (iodev's buffer size) / 2
instead of using the last one.

BUG= chromium:841689 
TEST=1.sox -b 16 -r 12000 --buffer 256 -c 2 -n -t alsa default synth sine 1000
        sine 1000
     2.Close stream in 1.
     3.sox -b 16 -r 48000 --buffer 8192 -c 2 -n -t alsa default synth sine 800
        sine 800

Change-Id: Iec541c9780ed6409a9e326523817c0afa544fbdb
Reviewed-on: https://chromium-review.googlesource.com/1053620
Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>

[modify] https://crrev.com/9ba33f943bb7f25220cb3374a8b0e26d0273dddf/cras/src/tests/iodev_unittest.cc
[modify] https://crrev.com/9ba33f943bb7f25220cb3374a8b0e26d0273dddf/cras/src/server/cras_iodev.c

Status: Verified (was: Assigned)

Sign in to add a comment