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: Kevin Rocard <krocard@google.com> (cherry picked from commit 01c7d9ee)
Loading
Please register or sign in to comment