Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 20a44f84 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Fix secondary output under&over run



There were three issues with the implementation
of Audio Playback Capture patches on secondary outputs.

1) Patch tracks were always forced to be ready, even if there were not
enough audio to be played. That led to playing partial buffers if the
source output had smaller (time wise) buffer than the secondary output.

This is fixed by avoiding setting CBLK_FORCEREADY on every buffer push
from the primary output thread.

2) After 1 is fixed, the patch tracks now behave like regular (non fast)
tracks. This means that the track only starts when it is full.
That leads to overrun on startup as the primary and secondary outputs
usually do not have the same write period.

What makes the issue worst is that Remote submix has a fixed buffer in bytes,
so its write period changes depending on sample rate contrary to the
primary HAL which pulls with fixed time periods (usually 20/40ms).

This patch solution is to introduce a ready threshold. The track will be
considered ready to be active if there are more than frames in its buffer.

To avoid changing previous latency behaviour except for APC,
legacy tracks have this threshold set to their buffer size and
non APC patch tracks have it set to 1, similar to setting
CBLK_FORCEREADY.

3) The patch track buffer size calculation of the patch track did not take
into account primary and secondary output could be of different sampling
rate.
This mean that the patch track buffer was usually too small as the
secondary output usually had smaller sampling rate (Live caption
requests 16kHz) than the track (music usually plays in 48kHz).
This made the two problems even worst.

This was easily fixed by scaling the buffer size with each side sample rate.

Bug: 136691300
Test: play audio
      adb shell audiorecorder  --target /data/file1.raw
      # Check that the recorded file has no underrun
Change-Id: Ib2846b2827afd1b953d4a25acb18c7cadf57cd3e
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 229c543d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment