diff options
author | Sven Gothel <[email protected]> | 2023-10-16 13:56:23 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-10-16 13:56:23 +0200 |
commit | b7d41ff2430adad96d546228c99b4a4610a6b752 (patch) | |
tree | 7fb61de841007704e7bf70a7a580de2d75cb0e4a /src/jogl/classes | |
parent | 11ee5d827d634cfcb3d9785912a42bfd874976ba (diff) |
GLMediaPlayer: Recognize !use_audio when repeating (caching) a video-frame, i.e. ignore audio_queued_ms in such case (Fixes video sync on SCR w/o audio)
Diffstat (limited to 'src/jogl/classes')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 901550af7..30068d51e 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -1080,6 +1080,30 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { char syncModeA = '_', syncModeB = '_'; char resetModeA = '_', resetModeV = '_'; + final PTS audio_pts = new PTS( () -> { return State.Playing == state ? playSpeed : 0f; } ); + final int audio_pts_lb; + final boolean use_audio; + if( audioStreamEnabled ) { + final PTS apts = getUpdatedAudioPTS(); + if( !apts.isValid() ) { + audio_pts.set(currentMillis, 0); + use_audio = false; + } else { + audio_pts.set(apts); + use_audio = true; + if( audio_scr_reset ) { + audio_scr_reset = false; + resetSCR(apts); + resetModeA = 'A'; + } + } + audio_pts_lb = getLastBufferedAudioPTS(); + } else { + audio_pts.set(currentMillis, 0); + audio_pts_lb = 0; + use_audio = false; + } + final boolean droppedFrame; if( dropFrame ) { presentedFrameCount--; @@ -1088,10 +1112,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } else { droppedFrame = false; } + final PTS video_pts = new PTS( () -> { return State.Playing == state ? playSpeed : 0f; } ); final boolean hasVideoFrame; TextureFrame nextFrame; - if( null != cachedFrame && ( audio_queued_ms > min0_audio_queued_ms || video_queue_growth > 0 ) ) { + if( null != cachedFrame && ( audio_queued_ms > min0_audio_queued_ms || !use_audio || video_queue_growth > 0 ) ) { nextFrame = cachedFrame; cachedFrame = null; presentedFrameCount--; @@ -1130,30 +1155,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } - final PTS audio_pts = new PTS( () -> { return State.Playing == state ? playSpeed : 0f; } ); - final int audio_pts_lb; - final boolean use_audio; - if( audioStreamEnabled ) { - final PTS apts = getUpdatedAudioPTS(); - if( !apts.isValid() ) { - audio_pts.set(video_pts); - use_audio = false; - } else { - audio_pts.set(apts); - use_audio = true; - if( audio_scr_reset ) { - audio_scr_reset = false; - resetSCR(apts); - resetModeA = 'A'; - } - } - audio_pts_lb = getLastBufferedAudioPTS(); - } else { - audio_pts.set(video_pts); - audio_pts_lb = 0; - use_audio = false; - } - if( hasVideoFrame && video_pts.isValid() ) { final int frame_period_last = video_pts.diffLast(video_pts_last); // rendering loop interrupted ? if( video_scr_reset || frame_period_last > frame_duration*10 ) { @@ -1253,7 +1254,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final int dt_v = (int) ( getDPTSAvg(video_dpts_cum, video_dpts_count) + 0.5f ); // final TextureFrame _nextFrame = nextFrame; if( dt_v > maxVideoDelay && d_vpts >= 0 && - ( audio_queued_ms > min1_audio_queued_ms || video_queue_growth > 0 ) ) + ( audio_queued_ms > min1_audio_queued_ms || !use_audio || video_queue_growth > 0 ) ) { cachedFrame = nextFrame; nextFrame = null; |