diff options
author | Reynaldo H. Verdejo Pinochet <reynaldo@collabora.com> | 2012-05-24 00:16:53 -0400 |
---|---|---|
committer | Reynaldo H. Verdejo Pinochet <reynaldo@collabora.com> | 2012-08-15 01:13:35 -0400 |
commit | e8921065f11bb3edf4de49055e79e8ac8404bb85 (patch) | |
tree | c5708e8c661543dc953cd999776389ecf07cb218 | |
parent | 6b10afc75000929af46af34d8cd01270ed3148bc (diff) |
Debork locking for render_and_display()
Ensure locking if needed and avoid locking otheriwise.
-rw-r--r-- | sys/android/gstvidroidsink.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/android/gstvidroidsink.c b/sys/android/gstvidroidsink.c index f5e660246..8f7d89dbc 100644 --- a/sys/android/gstvidroidsink.c +++ b/sys/android/gstvidroidsink.c @@ -1037,15 +1037,18 @@ gst_vidroidsink_render_and_display (GstViDroidSink * vidroidsink, if (!vidroidsink->have_texture) { GST_INFO_OBJECT (vidroidsink, "Doing initial texture setup"); + g_mutex_lock (vidroidsink->flow_lock); + glGenTextures (1, &vidroidsink->texture[0]); if (got_gl_error ("glGenTextures")) - goto HANDLE_ERROR; + goto HANDLE_ERROR_LOCKED; glBindTexture (GL_TEXTURE_2D, vidroidsink->texture[0]); if (got_gl_error ("glBindTexture")) - goto HANDLE_ERROR; + goto HANDLE_ERROR_LOCKED; vidroidsink->have_texture = TRUE; + g_mutex_unlock (vidroidsink->flow_lock); } /* XXX: Need to find a way to pass real buffer's @@ -1069,6 +1072,8 @@ gst_vidroidsink_render_and_display (GstViDroidSink * vidroidsink, if (!vidroidsink->have_vbo) { GST_DEBUG_OBJECT (vidroidsink, "Doing initial VBO setup"); + g_mutex_lock (vidroidsink->flow_lock); + vidroidsink->coordarray[0].x = -1; vidroidsink->coordarray[0].y = 1; vidroidsink->coordarray[0].z = 0; @@ -1093,34 +1098,35 @@ gst_vidroidsink_render_and_display (GstViDroidSink * vidroidsink, glGenBuffers (1, &vidroidsink->vdata); glGenBuffers (1, &vidroidsink->idata); if (got_gl_error ("glGenBuffers")) - goto HANDLE_ERROR; + goto HANDLE_ERROR_LOCKED; glBindBuffer (GL_ARRAY_BUFFER, vidroidsink->vdata); if (got_gl_error ("glBindBuffer vdata")) - goto HANDLE_ERROR; + goto HANDLE_ERROR_LOCKED; glBufferData (GL_ARRAY_BUFFER, sizeof (vidroidsink->coordarray), vidroidsink->coordarray, GL_STATIC_DRAW); if (got_gl_error ("glBufferData vdata")) - goto HANDLE_ERROR; + goto HANDLE_ERROR_LOCKED; glVertexAttribPointer (0, 3, GL_FLOAT, GL_FALSE, 0, 0); if (got_gl_error ("glVertexAttribPointer")) - goto HANDLE_ERROR; + goto HANDLE_ERROR_LOCKED; glEnableVertexAttribArray (0); glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, vidroidsink->idata); if (got_gl_error ("glBindBuffer idata")) - goto HANDLE_ERROR; + goto HANDLE_ERROR_LOCKED; glBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (vidroidsink->indexarray), vidroidsink->indexarray, GL_STATIC_DRAW); if (got_gl_error ("glBufferData idata")) - goto HANDLE_ERROR; + goto HANDLE_ERROR_LOCKED; glViewport (0, 0, w, h); vidroidsink->have_vbo = TRUE; + g_mutex_unlock (vidroidsink->flow_lock); } glClearColor (1.0, 0.0, 0.0, 0.0); @@ -1157,7 +1163,8 @@ gst_vidroidsink_render_and_display (GstViDroidSink * vidroidsink, HANDLE_EGL_ERROR: GST_ERROR_OBJECT (vidroidsink, "EGL call returned error %x", eglGetError ()); */ - +HANDLE_ERROR_LOCKED: + g_mutex_unlock (vidroidsink->flow_lock); HANDLE_ERROR: GST_ERROR_OBJECT (vidroidsink, "Rendering disabled for this frame"); } @@ -1186,9 +1193,7 @@ gst_vidroidsink_show_frame (GstVideoSink * vsink, GstBuffer * buf) "available"); #endif - g_mutex_lock (vidroidsink->flow_lock); gst_vidroidsink_render_and_display (vidroidsink, buf); - g_mutex_unlock (vidroidsink->flow_lock); return GST_FLOW_OK; } |