aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-10-16 06:11:13 +0200
committerSven Gothel <[email protected]>2023-10-16 06:11:13 +0200
commit11ee5d827d634cfcb3d9785912a42bfd874976ba (patch)
treeba2cfd934ae74d031eb44573fc25e47fbdf7bdb6
parent14e3a4640844e7857bb8569379129964ff46cab2 (diff)
GLMediaPlayerImpl: Use a PTS av_scr_cpy from av_scr for getPTS() avoiding direct user-exposure and potential data-race
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
index 7061fa5ec..901550af7 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java
@@ -180,6 +180,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
/** AV System Clock Reference (SCR) */
private final PTS av_scr = new PTS( () -> { return State.Playing == state ? playSpeed : 0f; } );
+ private final PTS av_scr_cpy = new PTS( av_scr );
/** Trigger System Clock Reference (SCR) reset. */
private boolean video_scr_reset = false;
private boolean audio_scr_reset = false;
@@ -350,7 +351,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
public final int getPresentedFrameCount() { return presentedFrameCount; }
@Override
- public final PTS getPTS() { return av_scr; }
+ public final PTS getPTS() { return av_scr_cpy; }
@Override
public final int getVideoPTS() { return video_pts_last.get(Clock.currentMillis()); }
@@ -440,7 +441,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
streamWorker.pause(true);
}
if( flush ) {
- resetAVPTSAndFlush();
+ resetAVPTSAndFlush(false);
} else if( null != audioSink ) {
audioSink.pause();
}
@@ -463,7 +464,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
streamWorker.stop(true);
streamWorker = null;
}
- resetAVPTSAndFlush();
+ resetAVPTSAndFlush(true);
stopImpl();
changeState(new GLMediaPlayer.EventMask(), State.Uninitialized);
// attachedObjects.clear();
@@ -483,7 +484,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
streamWorker.stop(wait);
streamWorker = null;
}
- resetAVPTSAndFlush();
+ resetAVPTSAndFlush(true);
destroyImpl();
removeAllTextureFrames(gl);
lastFrame = null;
@@ -515,7 +516,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
msec = 0;
}
pts1 = seekImpl(msec);
- resetAVPTSAndFlush();
+ resetAVPTSAndFlush(false);
if( null != audioSink && State.Playing == _state ) {
audioSink.play(); // cont. w/ new data
}
@@ -751,7 +752,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
logout.println("GLMediaPlayer.initGL: "+this);
}
try {
- resetAVPTSAndFlush();
+ resetAVPTSAndFlush(true);
removeAllTextureFrames(gl);
if( State.Uninitialized != state ) {
initGLImpl(gl);
@@ -1298,6 +1299,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
}
}
displayedFrameCount++;
+ av_scr_cpy.set(av_scr);
return lastFrame;
}
}
@@ -1371,8 +1373,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer {
}
cachedFrame = null;
}
- private void resetAVPTSAndFlush() {
+ private void resetAVPTSAndFlush(final boolean set_scr_cpy) {
resetSCR(av_scr);
+ if( set_scr_cpy ) {
+ av_scr_cpy.set(av_scr);
+ }
audio_queued_last_ms = 0;
audio_dequeued_last = 0;
resetAVPTS();