Repository navigation
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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).