From f6021300d928f6902fb582cd3e9fc74bb0261db1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 9 May 2023 07:02:19 +0200 Subject: Fix GLMediaPlayerImpl.initGL(GL): Allow null==gl and audio-only mode (regression to initial implementation) --- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 49 +++++++++++++++------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index de949bbd6..cffd8426c 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -664,23 +664,33 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { throw streamInitErr; } } + if(DEBUG) { + System.err.println("GLMediaPlayer.initGL: "+this); + } try { - if( STREAM_ID_NONE != vid && State.Uninitialized != state ) { - resetAVPTSAndFlush(); - removeAllTextureFrames(gl); + resetAVPTSAndFlush(); + removeAllTextureFrames(gl); + if( State.Uninitialized != state ) { initGLImpl(gl); if(DEBUG) { System.err.println("initGLImpl.X "+this); } - videoFramesOrig = createTexFrames(gl, textureCount); - if( TEXTURE_COUNT_MIN == textureCount ) { + if( null != gl ) { + videoFramesOrig = createTexFrames(gl, textureCount); + if( TEXTURE_COUNT_MIN == textureCount ) { + videoFramesFree = null; + videoFramesDecoded = null; + lastFrame = videoFramesOrig[0]; + } else { + videoFramesFree = new LFRingbuffer(videoFramesOrig); + videoFramesDecoded = new LFRingbuffer(TextureFrame[].class, textureCount); + lastFrame = videoFramesFree.getBlocking( ); + } + } else { + videoFramesOrig = null; videoFramesFree = null; videoFramesDecoded = null; - lastFrame = videoFramesOrig[0]; - } else { - videoFramesFree = new LFRingbuffer(videoFramesOrig); - videoFramesDecoded = new LFRingbuffer(TextureFrame[].class, textureCount); - lastFrame = videoFramesFree.getBlocking( ); + lastFrame = null; } if( null == streamWorker && ( TEXTURE_COUNT_MIN < textureCount || STREAM_ID_NONE == vid ) ) // Enable StreamWorker for 'audio only' as well (Bug 918). @@ -691,10 +701,17 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { streamWorker.doResume(); changeState(new GLMediaPlayer.EventMask(), State.Paused); resume(); + } else if( null == gl ) { + width = 0; + height = 0; + setTextureFormat(GL.GL_RGBA, GL.GL_RGBA); + setTextureType(GL.GL_UNSIGNED_BYTE); + textureCount = 0; + videoFramesOrig = null; + videoFramesFree = null; + videoFramesDecoded = null; + lastFrame = null; } else { - resetAVPTSAndFlush(); - removeAllTextureFrames(gl); - // initGLImpl(gl); // Using a dummy test frame width = TestTexture.singleton.getWidth(); height = TestTexture.singleton.getHeight(); @@ -711,9 +728,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { videoFramesDecoded = new LFRingbuffer(TextureFrame[].class, textureCount); lastFrame = videoFramesFree.getBlocking( ); } - videoFramesFree = null; - videoFramesDecoded = null; - lastFrame = videoFramesOrig[0]; // changeState(0, State.Paused); } } catch (final Throwable t) { @@ -1239,6 +1253,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } public final synchronized void initGL(final GL gl) { + if( null == gl ) { + return; + } final GLContext glCtx = gl.getContext(); final boolean glCtxCurrent = glCtx.isCurrent(); final GLProfile glp = gl.getGLProfile(); -- cgit v1.2.3