From 3a26aa701b4a1a0991cd997a0d295a1b83cd12f3 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Mon, 9 Apr 2012 04:49:41 +0200
Subject: GLMediaPlayer*: Revised - Working on buggy MediaPlayer impl. (Android
 ICS Tegra)

GLMediaPlayer:
  Merging 'initStream()' and 'initGL()' to 'initGLStream()' due to incompatible/buggy implementations (Android/Tegra)
  requiring the GL texture being setup before preparing the stream.
  This also implies that w/o an GL context we cannot fetch the stream information (size, ..)
  hence we need to evaluate this detail (FIXME).

  'getNextTexture(GL gl, boolean blocking)' can request the impl. to block

GLMediaEventListener:
  The TextureFrame not yet available, adding 'when'
---
 .../jogamp/opengl/av/EGLMediaPlayerImpl.java       | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

(limited to 'src/jogl/classes/jogamp/opengl/av/EGLMediaPlayerImpl.java')

diff --git a/src/jogl/classes/jogamp/opengl/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/av/EGLMediaPlayerImpl.java
index abc5d5912..2f6744fc5 100644
--- a/src/jogl/classes/jogamp/opengl/av/EGLMediaPlayerImpl.java
+++ b/src/jogl/classes/jogamp/opengl/av/EGLMediaPlayerImpl.java
@@ -27,8 +27,11 @@
  */
 package jogamp.opengl.av;
 
-import javax.media.opengl.GLContext;
+import java.nio.IntBuffer;
 
+import javax.media.opengl.GL;
+
+import com.jogamp.common.nio.Buffers;
 import com.jogamp.opengl.util.texture.Texture;
 
 import jogamp.opengl.egl.EGL;
@@ -80,22 +83,23 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl {
     }
 
     @Override
-    protected TextureFrame createTexImage(GLContext ctx, int idx, int[] tex) {
-        final Texture texture = super.createTexImageImpl(ctx, idx, tex, true);
+    protected TextureFrame createTexImage(GL gl, int idx, int[] tex) {
+        final Texture texture = super.createTexImageImpl(gl, idx, tex, true);
         final long image;
         final long sync;
         
-        final EGLContext eglCtx = (EGLContext) ctx;
+        final EGLContext eglCtx = (EGLContext) gl.getContext();
         final EGLExt eglExt = eglCtx.getEGLExt();
         final EGLDrawable eglDrawable = (EGLDrawable) eglCtx.getGLDrawable();            
         int[] tmp = new int[1];
+        IntBuffer nioTmp = Buffers.newDirectIntBuffer(1);
         
         if(TextureType.KHRImage == texType) {
             // create EGLImage from texture
-            tmp[0] = EGL.EGL_NONE;
+            nioTmp.put(0, EGL.EGL_NONE);
             image =  eglExt.eglCreateImageKHR( eglDrawable.getDisplay(), eglCtx.getHandle(),
                                                EGLExt.EGL_GL_TEXTURE_2D_KHR,
-                                               tex[idx], tmp, 0);
+                                               null /* buffer */, nioTmp);
             if (0==image) {
                 throw new RuntimeException("EGLImage creation failed: "+EGL.eglGetError()+", ctx "+eglCtx+", tex "+tex[idx]+", err "+toHexString(EGL.eglGetError()));
             }
@@ -119,8 +123,8 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl {
     }
     
     @Override
-    protected void destroyTexImage(GLContext ctx, TextureFrame imgTex) {
-        final EGLContext eglCtx = (EGLContext) ctx;
+    protected void destroyTexImage(GL gl, TextureFrame imgTex) {
+        final EGLContext eglCtx = (EGLContext) gl.getContext();
         final EGLExt eglExt = eglCtx.getEGLExt();
         final EGLDrawable eglDrawable = (EGLDrawable) eglCtx.getGLDrawable();
         final EGLTextureFrame eglTex = (EGLTextureFrame) imgTex;
@@ -131,6 +135,6 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl {
         if(0!=eglTex.getSync()) {
             eglExt.eglDestroySyncKHR(eglDrawable.getDisplay(), eglTex.getSync());
         }
-        super.destroyTexImage(ctx, imgTex);
+        super.destroyTexImage(gl, imgTex);
     }
 }
-- 
cgit v1.2.3