Java Code Examples for android.opengl.EGL14#eglReleaseThread()

The following examples show how to use android.opengl.EGL14#eglReleaseThread() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EncodeAndMuxTest.java    From Android-MediaCodec-Examples with Apache License 2.0 6 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mSurface.release();

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;

    mSurface = null;
}
 
Example 2
Source File: OutputSurface.java    From SimpleVideoEdit with Apache License 2.0 6 votes vote down vote up
/**
 * Discard all resources held by this class, notably the EGL context.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mSurface.release();

    // this causes a bunch of warnings that appear harmless but might confuse someone:
    //  W BufferQueue: [unnamed-3997-2] cancelBuffer: BufferQueue has been abandoned!
    //mSurfaceTexture.release();

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;

    mTextureRender = null;
    mSurface = null;
    mSurfaceTexture = null;
}
 
Example 3
Source File: EglCore.java    From TikTok with Apache License 2.0 6 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  This must be
 * called from the thread where the context was created.
 * <p>
 * On completion, no context will be current.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        // Android is unusual in that it uses a reference-counted EGLDisplay.  So for
        // every eglInitialize() we need an eglTerminate().
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLConfig = null;
}
 
Example 4
Source File: GLMovieRecorder.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mSurface.release();

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;

    mSurface = null;
}
 
Example 5
Source File: InstantCameraView.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void finalize() throws Throwable {
    try {
        if (eglDisplay != EGL14.EGL_NO_DISPLAY) {
            EGL14.eglMakeCurrent(eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
            EGL14.eglDestroyContext(eglDisplay, eglContext);
            EGL14.eglReleaseThread();
            EGL14.eglTerminate(eglDisplay);
            eglDisplay = EGL14.EGL_NO_DISPLAY;
            eglContext = EGL14.EGL_NO_CONTEXT;
            eglConfig = null;
        }
    } finally {
        super.finalize();
    }
}
 
Example 6
Source File: OutputSurface.java    From android-transcoder with Apache License 2.0 6 votes vote down vote up
/**
 * Discard all resources held by this class, notably the EGL context.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }
    mSurface.release();
    // this causes a bunch of warnings that appear harmless but might confuse someone:
    //  W BufferQueue: [unnamed-3997-2] cancelBuffer: BufferQueue has been abandoned!
    //mSurfaceTexture.release();
    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mTextureRender = null;
    mSurface = null;
    mSurfaceTexture = null;
}
 
Example 7
Source File: OutputSurface.java    From phoenix with Apache License 2.0 6 votes vote down vote up
/**
 * Discard all resources held by this class, notably the EGL context.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }
    mSurface.release();
    // this causes a bunch of warnings that appear harmless but might confuse someone:
    //  W BufferQueue: [unnamed-3997-2] cancelBuffer: BufferQueue has been abandoned!
    //mSurfaceTexture.release();
    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLSurface = EGL14.EGL_NO_SURFACE;
    mTextureRender = null;
    mSurface = null;
    mSurfaceTexture = null;
}
 
Example 8
Source File: EglCore.java    From grafika with Apache License 2.0 6 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  This must be
 * called from the thread where the context was created.
 * <p>
 * On completion, no context will be current.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        // Android is unusual in that it uses a reference-counted EGLDisplay.  So for
        // every eglInitialize() we need an eglTerminate().
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
                EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLConfig = null;
}
 
Example 9
Source File: EglBase14.java    From UltraGpuImage with MIT License 5 votes vote down vote up
@Override
public void release() {
  checkIsNotReleased();
  releaseSurface();
  detachCurrent();
  EGL14.eglDestroyContext(eglDisplay, eglContext);
  EGL14.eglReleaseThread();
  EGL14.eglTerminate(eglDisplay);
  eglContext = EGL14.EGL_NO_CONTEXT;
  eglDisplay = EGL14.EGL_NO_DISPLAY;
  eglConfig = null;
}
 
Example 10
Source File: EGLBase14.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
	 * 関連するリソースを破棄する
	 */
	@Override
    public void release() {
//		if (DEBUG) Log.v(TAG, "release:");
        if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
	    	destroyContext();
	        EGL14.eglTerminate(mEglDisplay);
	        EGL14.eglReleaseThread();
        }
        mEglDisplay = EGL14.EGL_NO_DISPLAY;
        mContext = EGL_NO_CONTEXT;
    }
 
Example 11
Source File: SurfaceManager.java    From spydroid-ipcamera with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.  Also releases the
 * Surface that was passed to our constructor.
 */
public void release() {
	if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
		EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
				EGL14.EGL_NO_CONTEXT);
		EGL14.eglDestroySurface(mEGLDisplay, mEGLSurface);
		EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
		EGL14.eglReleaseThread();
		EGL14.eglTerminate(mEGLDisplay);
	}
	mEGLDisplay = EGL14.EGL_NO_DISPLAY;
	mEGLContext = EGL14.EGL_NO_CONTEXT;
	mEGLSurface = EGL14.EGL_NO_SURFACE;
	mSurface.release();
}
 
Example 12
Source File: EGLBase.java    From Fatigue-Detection with MIT License 5 votes vote down vote up
public void release() {
if (DEBUG) Log.v(TAG, "release:");
      if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
   	destroyContext();
       EGL14.eglTerminate(mEglDisplay);
       EGL14.eglReleaseThread();
      }
      mEglDisplay = EGL14.EGL_NO_DISPLAY;
      mEglContext = EGL14.EGL_NO_CONTEXT;
  }
 
Example 13
Source File: EglBase14.java    From VideoCRE with MIT License 5 votes vote down vote up
@Override
public void release() {
  checkIsNotReleased();
  releaseSurface();
  detachCurrent();
  EGL14.eglDestroyContext(eglDisplay, eglContext);
  EGL14.eglReleaseThread();
  EGL14.eglTerminate(eglDisplay);
  eglContext = EGL14.EGL_NO_CONTEXT;
  eglDisplay = EGL14.EGL_NO_DISPLAY;
  eglConfig = null;
}
 
Example 14
Source File: EGLBase.java    From AudioVideoRecordingSample with Apache License 2.0 5 votes vote down vote up
public void release() {
if (DEBUG) Log.v(TAG, "release:");
      if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
   	destroyContext();
       EGL14.eglTerminate(mEglDisplay);
       EGL14.eglReleaseThread();
      }
      mEglDisplay = EGL14.EGL_NO_DISPLAY;
      mEglContext = EGL14.EGL_NO_CONTEXT;
  }
 
Example 15
Source File: SurfaceManager.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 5 votes vote down vote up
/**
 * Discards all resources held by this class, notably the EGL context.
 */
public void release() {
  if (eglDisplay != EGL14.EGL_NO_DISPLAY) {
    EGL14.eglMakeCurrent(eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE,
        EGL14.EGL_NO_CONTEXT);
    EGL14.eglDestroySurface(eglDisplay, eglSurface);
    EGL14.eglDestroyContext(eglDisplay, eglContext);
    EGL14.eglReleaseThread();
    EGL14.eglTerminate(eglDisplay);
  }
  eglDisplay = EGL14.EGL_NO_DISPLAY;
  eglContext = EGL14.EGL_NO_CONTEXT;
  eglSurface = EGL14.EGL_NO_SURFACE;
}
 
Example 16
Source File: EglCore.java    From kickflip-android-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Discard all resources held by this class, notably the EGL context.
 */
public void release() {
    if (mEGLDisplay != EGL14.EGL_NO_DISPLAY) {
        // Android is unusual in that it uses a reference-counted EGLDisplay.  So for
        // every eglInitialize() we need an eglTerminate().
        EGL14.eglMakeCurrent(mEGLDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
        EGL14.eglDestroyContext(mEGLDisplay, mEGLContext);
        EGL14.eglReleaseThread();
        EGL14.eglTerminate(mEGLDisplay);
    }

    mEGLDisplay = EGL14.EGL_NO_DISPLAY;
    mEGLContext = EGL14.EGL_NO_CONTEXT;
    mEGLConfig = null;
}
 
Example 17
Source File: EglBase14Impl.java    From webrtc_android with MIT License 5 votes vote down vote up
@Override
public void release() {
  checkIsNotReleased();
  releaseSurface();
  detachCurrent();
  EGL14.eglDestroyContext(eglDisplay, eglContext);
  EGL14.eglReleaseThread();
  EGL14.eglTerminate(eglDisplay);
  eglContext = EGL14.EGL_NO_CONTEXT;
  eglDisplay = EGL14.EGL_NO_DISPLAY;
  eglConfig = null;
}
 
Example 18
Source File: EGLBase.java    From AudioVideoPlayerSample with Apache License 2.0 5 votes vote down vote up
public void release() {
if (DEBUG) Log.v(TAG, "release:");
      if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
   	destroyContext();
       EGL14.eglTerminate(mEglDisplay);
       EGL14.eglReleaseThread();
      }
      mEglDisplay = EGL14.EGL_NO_DISPLAY;
      mEglContext = EGL14.EGL_NO_CONTEXT;
  }
 
Example 19
Source File: EGLBase.java    From MegviiFacepp-Android-SDK with Apache License 2.0 5 votes vote down vote up
public void release() {
if (DEBUG) Log.v(TAG, "release:");
      if (mEglDisplay != EGL14.EGL_NO_DISPLAY) {
   	destroyContext();
       EGL14.eglTerminate(mEglDisplay);
       EGL14.eglReleaseThread();
      }
      mEglDisplay = EGL14.EGL_NO_DISPLAY;
      mEglContext = EGL14.EGL_NO_CONTEXT;
  }
 
Example 20
Source File: EGLSurfaceTexture.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/** Releases all allocated resources. */
@SuppressWarnings({"nullness:argument.type.incompatible"})
public void release() {
  handler.removeCallbacks(this);
  try {
    if (texture != null) {
      texture.release();
      GLES20.glDeleteTextures(1, textureIdHolder, 0);
    }
  } finally {
    if (display != null && !display.equals(EGL14.EGL_NO_DISPLAY)) {
      EGL14.eglMakeCurrent(
          display, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT);
    }
    if (surface != null && !surface.equals(EGL14.EGL_NO_SURFACE)) {
      EGL14.eglDestroySurface(display, surface);
    }
    if (context != null) {
      EGL14.eglDestroyContext(display, context);
    }
    // EGL14.eglReleaseThread could crash before Android K (see [internal: b/11327779]).
    if (Util.SDK_INT >= 19) {
      EGL14.eglReleaseThread();
    }
    if (display != null && !display.equals(EGL14.EGL_NO_DISPLAY)) {
      // Android is unusual in that it uses a reference-counted EGLDisplay.  So for
      // every eglInitialize() we need an eglTerminate().
      EGL14.eglTerminate(display);
    }
    display = null;
    context = null;
    surface = null;
    texture = null;
  }
}