android: opengl video rendering resources handling corrections

- don't try to manually call glDelete* on context lost (documentation
says resources will be automagically freed)
- add a stop condition to the unroll gl-error loop
parent cf0ea749
......@@ -113,8 +113,8 @@ static int android_display_set_window(MSFilter *f, void *arg){
ms_message("Sending opengles_display pointer as long: %p -> %u\n", ad->ogl, ptr);
(*jenv)->CallVoidMethod(jenv,ad->android_video_window,ad->set_opengles_display_id, ptr);
} else {
/* surface if being destroyed, release GL resources */
ogl_display_uninit(ad->ogl);
/* when context is lost GL resources are freed by Android */
ogl_display_uninit(ad->ogl, FALSE);
}
ms_filter_unlock(f);
......
......@@ -129,7 +129,7 @@ void ogl_display_init(struct opengles_display* gldisp, int width, int height) {
gldisp->glResourcesInitialized = TRUE;
}
void ogl_display_uninit(struct opengles_display* gldisp) {
void ogl_display_uninit(struct opengles_display* gldisp, bool_t freeGLresources) {
ms_message("uninit opengles_display (gl initialized:%d)\n", gldisp->glResourcesInitialized);
if (gldisp->yuv) {
......@@ -137,16 +137,16 @@ void ogl_display_uninit(struct opengles_display* gldisp) {
gldisp->yuv = NULL;
}
if (gldisp->glResourcesInitialized) {
if (gldisp->glResourcesInitialized && freeGLresources) {
// destroy gl resources
GL_OPERATION(glDeleteTextures(3, gldisp->textures));
GL_OPERATION(glDeleteProgram(gldisp->program));
}
gldisp->allocatedTexturesW = 0;
gldisp->allocatedTexturesH = 0;
gldisp->allocatedTexturesW = 0;
gldisp->allocatedTexturesH = 0;
gldisp->glResourcesInitialized = FALSE;
}
gldisp->glResourcesInitialized = FALSE;
}
void ogl_display_set_yuv_to_display(struct opengles_display* gldisp, mblk_t *yuv) {
......@@ -223,19 +223,21 @@ void ogl_display_render(struct opengles_display* gldisp) {
}
static void check_GL_errors(const char* context) {
int maxIterations=10;
GLenum error;
while ((error = glGetError()) != GL_NO_ERROR)
while (((error = glGetError()) != GL_NO_ERROR) && maxIterations > 0)
{
switch(error)
{
case GL_INVALID_ENUM: ms_error("GL error: '%s' -> GL_INVALID_ENUM\n", context); break;
case GL_INVALID_VALUE: ms_error("GL error: '%s' -> GL_INVALID_VALUE\n", context); break;
case GL_INVALID_OPERATION: ms_error("GL error: '%s' -> GL_INVALID_OPERATION\n", context); break;
case GL_OUT_OF_MEMORY: ms_error("GL error: '%s' -> GL_OUT_OF_MEMORY\n", context); break;
case GL_INVALID_FRAMEBUFFER_OPERATION: ms_error("GL error: '%s' -> GL_INVALID_FRAMEBUFFER_OPERATION\n", context); break;
case GL_INVALID_ENUM: ms_error("[%2d]GL error: '%s' -> GL_INVALID_ENUM\n", maxIterations, context); break;
case GL_INVALID_VALUE: ms_error("[%2d]GL error: '%s' -> GL_INVALID_VALUE\n", maxIterations, context); break;
case GL_INVALID_OPERATION: ms_error("[%2d]GL error: '%s' -> GL_INVALID_OPERATION\n", maxIterations, context); break;
case GL_OUT_OF_MEMORY: ms_error("[%2d]GL error: '%s' -> GL_OUT_OF_MEMORY\n", maxIterations, context); break;
case GL_INVALID_FRAMEBUFFER_OPERATION: ms_error("[%2d]GL error: '%s' -> GL_INVALID_FRAMEBUFFER_OPERATION\n", maxIterations, context); break;
default:
ms_error("GL error: '%s' -> %x\n", context, error);
ms_error("[%2d]GL error: '%s' -> %x\n", maxIterations, context, error);
}
maxIterations--;
}
}
......
......@@ -32,7 +32,7 @@ void ogl_display_free(struct opengles_display* gldisp);
void ogl_display_init(struct opengles_display* gldisp, int width, int height);
void ogl_display_uninit(struct opengles_display* gldisp);
void ogl_display_uninit(struct opengles_display* gldisp, bool_t freeGLresources);
void ogl_display_set_yuv_to_display(struct opengles_display* gldisp, mblk_t *yuv);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment