diff options
author | Sven Gothel <[email protected]> | 2023-10-15 07:06:53 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-10-15 07:06:53 +0200 |
commit | b1956113f5601b0cc6ac525d3918a0dfa8d240af (patch) | |
tree | b7365f799d5bdad00f8b0f60632884175cff4ef1 /src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java | |
parent | 86210fde931400ff6f1b0a2da48ca031a957df8d (diff) |
Bug 1472: Enhance GLMediaPlayer AV Sync: Utilize SCR aware audio PTS used as master-clock, enabling proper AV sync w/ untouched audio
We can finally utilize the added pass through audio PTS, see commits
- GlueGen 52725b4c6525487f93407f529dc0a758b387a4fc
- JOAL 12029f1ec1d8afa576e1ac61655f318cc37c1d16
This enables us to use the audio PTS as the master-clock and adjust video to the untouched audio.
In case no audio is selected/playing or audio is muted,
we sync merely on the system-clock (SCR) w/o audio.
AV granularity is 22ms, however, since the ALAudioSink PTS may be a little late,
it renders even a slightly better sync in case of too early audio (d_apts < 0).
Since video frames are sync'ed to audio, the resync procedure may result
in a hysteresis swinging into sync. This might be notable at start
and when resumed audio or after seek.
We leave the audio frames untouched to reduce processing burden
and allow non-disrupted listening.
Passed AV sync tests
- Five-minute-sync-test.mp4
- Audio-Video-Sync-Test-Calibration-23.98fps-24fps.mp4
- Audio-Video-Sync-Test-2.mkv
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index 336084734..2c2fc57d0 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -30,10 +30,13 @@ package jogamp.opengl.util.av.impl; import java.io.IOException; +import com.jogamp.common.av.PTS; +import com.jogamp.common.os.Clock; import com.jogamp.opengl.GL; import com.jogamp.opengl.GLException; import com.jogamp.opengl.egl.EGL; +import com.jogamp.opengl.util.av.GLMediaPlayer.State; import com.jogamp.opengl.util.texture.TextureSequence; import jogamp.opengl.util.av.EGLMediaPlayerImpl; @@ -123,9 +126,21 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected int getAudioPTSImpl() { - return 0!=moviePtr ? _getCurrentPosition(moviePtr) : 0; + protected PTS getAudioPTSImpl() { return audio_pts; } + @Override + protected PTS getUpdatedAudioPTS() { + if( 0 != moviePtr ) { + audio_pts.set(Clock.currentMillis(), _getCurrentPosition(moviePtr)); + } else { + audio_pts.set(Clock.currentMillis(), 0); + } + return audio_pts; } + @Override + protected int getAudioQueuedDuration() { return 0; } + @Override + protected int getLastBufferedAudioPTS() { return audio_pts.getLast(); } + private final PTS audio_pts = new PTS( () -> { return State.Playing == getState() ? getPlaySpeed() : 0f; } ); @Override protected boolean setPlaySpeedImpl(final float rate) { |