diff options
author | Sven Göthel <[email protected]> | 2024-02-02 08:31:29 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-02-02 08:31:29 +0100 |
commit | 0dd2b17f1dd484d22d68828bfb61558be09a4bfa (patch) | |
tree | b6cc490bcf5295c0994ba94b4866b864d6176beb /src/jogl | |
parent | 23cf5279472d3ae1b2d8d1904e6b1f1e7fd8f012 (diff) |
GLMediaPlayerImpl: Allow one frame to be shown paused when issuing seek(), i.e. 'oneVideoFrameOnce'.
This allows a player to see the current seek'ed position while paused.
Diffstat (limited to 'src/jogl')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index a52efe2ac..6d71dd43e 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import com.jogamp.nativewindow.AbstractGraphicsDevice; import com.jogamp.nativewindow.DefaultGraphicsDevice; @@ -107,6 +108,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private volatile State state; private final Object stateLock = new Object(); + private final AtomicBoolean oneVideoFrameOnce = new AtomicBoolean(false); private int textureCount; private int textureTarget; @@ -548,9 +550,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final int seek(int msec) { + final int pts1; + final State preState; synchronized( stateLock ) { - final State preState = state; - final int pts1; + preState = state; switch(state) { case Playing: case Paused: @@ -577,14 +580,16 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { streamWorker.resume(); } setState( _state ); + attributesUpdated(new GLMediaPlayer.EventMask(GLMediaPlayer.EventMask.Bit.Seek)); break; default: pending_seek = msec; pts1 = 0; } - if(DEBUG) { logout.println("Seek("+msec+"): "+preState+" -> "+state+", "+toString()); } - return pts1; } + oneVideoFrameOnce.set(true); + if(DEBUG) { logout.println("Seek("+msec+"): "+preState+" -> "+state+", "+toString()); } + return pts1; } protected int pending_seek = -1; protected abstract int seekImpl(int msec); @@ -1173,7 +1178,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final TextureFrame getNextTexture(final GL gl) throws IllegalStateException { synchronized( stateLock ) { - if(State.Playing == state) { + final boolean oneVideoFrame = oneVideoFrameOnce.compareAndSet(true, false); + if( oneVideoFrame || State.Playing == state ) { boolean dropFrame = false; try { do { @@ -1265,6 +1271,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { hasVideoFrame = stGotVFrame[0]; } } + if( !hasVideoFrame && oneVideoFrame ) { + oneVideoFrameOnce.set(true); + } if( hasVideoFrame && video_pts.isValid() ) { final int frame_period_last = video_pts.diffLast(video_pts_last); // rendering loop interrupted ? |