Skip to content

audio: report the FRDDR FIFO fill as playback delay - #59

Open
matthane wants to merge 1 commit into
CoreELEC:5.15.196_20260225from
matthane:pr/ce-audio-fifo-delay
Open

matthane wants to merge 1 commit into
CoreELEC:5.15.196_20260225from
matthane:pr/ce-audio-fifo-delay

Conversation

@matthane

Copy link
Copy Markdown
Contributor

Depends on no other PR. The CoreELEC/xbmc A/V sync PRs were measured with it.

Problem

On Amlogic boxes ALSA reports less playback delay than the audio really has, so a player that syncs to it plays audio up to 5.5 ms late at the HDMI output.

Change

The playback pointer reports the FRDDR fetch address, which runs up to 1 KiB of FIFO ahead of the serializer, so ALSA's delay leaves out the audio still queued in the chip. The pointers now read the fetch address and the FIFO fill as one consistent pair and report the fill as runtime->delay, as mainline pcm_dmaengine reports its in-flight bytes. FRDDR_FIFO_CNT is corrected to bits 16:8.

Tested with

The A/V offset is measured at the HDMI output at playback start on A/V marker clips (1080p23.976, a frame code and a click every second), six starts per codec on each device. Without this PR is the stock kernel, and both arms run the same Kodi. A value is the median of one device's starts, and a cell gives the range over the four devices. Positive means the audio leaves the box after its picture. Full data in the measurement data. Every sample ran on each device listed under Tested on. The 1 KiB of FIFO holds about 2.7 ms of PCM 2.0, 5.3 ms of AC-3 or DTS, 1.3 ms of E-AC-3 and 0.3 ms of a DTS-HD MA or TrueHD stream, which is about how far each row moves.

Sample Without this PR, A/V offset at start (ms) With this PR, A/V offset at start (ms)
A/V marker clip, PCM 2.0 +2.7 to +2.9 +0.3 to +0.6
A/V marker clip, AC-3 +4.6 to +5.5 -0.6 to +0.1
A/V marker clip, E-AC-3 +0.4 to +1.1 -0.5 to -0.2
A/V marker clip, DTS +4.3 to +4.9 -0.5 to -0.2
A/V marker clip, DTS-HD MA -0.4 to +0.1 -0.8 to -0.4
A/V marker clip, TrueHD -0.3 to +0.1 -0.4 to 0.0

Result

Audio leaves the HDMI output within 1 ms of when ALSA says it does, so lip sync starts where the player set it.

Tested on

CoreELEC 22 nightly 20261124 with this PR's commit and an earlier build of the CoreELEC/xbmc A/V sync PRs, common_drivers on Linux 5.15.196, tested 2026-11-24. Both kernels carry two capture taps used only for the measurement. No library change and no CoreELEC patch needed. AM9 Pro (S905X5), AM6B+ (S922X), Dune/Homatics R 4K Plus (S905X4), Fire TV Cube 3rd gen (T7).

The playback pointer reads the FRDDR fetch address, which runs up to
one FIFO depth (1 KiB) ahead of what the serializer has sent. ALSA's
delay leaves that queue out, so the HDMI output trails the reported
delay by 3 to 5.5 ms for PCM 2.0, AC-3 and DTS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant