mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
eglglessink: Fix race condition
This commit is contained in:
parent
99f738bbc0
commit
caf9d1febd
1 changed files with 26 additions and 0 deletions
|
@ -1082,7 +1082,9 @@ render_thread_func (GstEglGlesSink * eglglessink)
|
||||||
if (caps != eglglessink->configured_caps) {
|
if (caps != eglglessink->configured_caps) {
|
||||||
if (!gst_eglglessink_configure_caps (eglglessink, caps)) {
|
if (!gst_eglglessink_configure_caps (eglglessink, caps)) {
|
||||||
eglglessink->last_flow = GST_FLOW_NOT_NEGOTIATED;
|
eglglessink->last_flow = GST_FLOW_NOT_NEGOTIATED;
|
||||||
|
g_mutex_lock (eglglessink->render_lock);
|
||||||
g_cond_broadcast (eglglessink->render_cond);
|
g_cond_broadcast (eglglessink->render_cond);
|
||||||
|
g_mutex_unlock (eglglessink->render_lock);
|
||||||
item->destroy (item);
|
item->destroy (item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1090,15 +1092,24 @@ render_thread_func (GstEglGlesSink * eglglessink)
|
||||||
}
|
}
|
||||||
|
|
||||||
eglglessink->last_flow = gst_eglglessink_render_and_display (eglglessink, buf);
|
eglglessink->last_flow = gst_eglglessink_render_and_display (eglglessink, buf);
|
||||||
|
g_mutex_lock (eglglessink->render_lock);
|
||||||
g_cond_broadcast (eglglessink->render_cond);
|
g_cond_broadcast (eglglessink->render_cond);
|
||||||
|
g_mutex_unlock (eglglessink->render_lock);
|
||||||
item->destroy (item);
|
item->destroy (item);
|
||||||
if (eglglessink->last_flow != GST_FLOW_OK)
|
if (eglglessink->last_flow != GST_FLOW_OK)
|
||||||
break;
|
break;
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Successfully handled object");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_mutex_lock (eglglessink->render_lock);
|
||||||
|
g_cond_broadcast (eglglessink->render_cond);
|
||||||
|
g_mutex_unlock (eglglessink->render_lock);
|
||||||
|
|
||||||
if (eglglessink->last_flow == GST_FLOW_OK)
|
if (eglglessink->last_flow == GST_FLOW_OK)
|
||||||
eglglessink->last_flow = GST_FLOW_WRONG_STATE;
|
eglglessink->last_flow = GST_FLOW_WRONG_STATE;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Shutting down thread");
|
||||||
|
|
||||||
/* EGL/GLES cleanup */
|
/* EGL/GLES cleanup */
|
||||||
if (eglglessink->rendering_path == GST_EGLGLESSINK_RENDER_SLOW) {
|
if (eglglessink->rendering_path == GST_EGLGLESSINK_RENDER_SLOW) {
|
||||||
glUseProgram (0);
|
glUseProgram (0);
|
||||||
|
@ -1158,6 +1169,8 @@ gst_eglglessink_start (GstEglGlesSink * eglglessink)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Starting");
|
||||||
|
|
||||||
if (!eglglessink->egl_started) {
|
if (!eglglessink->egl_started) {
|
||||||
GST_ERROR_OBJECT (eglglessink, "EGL uninitialized. Bailing out");
|
GST_ERROR_OBJECT (eglglessink, "EGL uninitialized. Bailing out");
|
||||||
goto HANDLE_ERROR;
|
goto HANDLE_ERROR;
|
||||||
|
@ -1188,6 +1201,8 @@ gst_eglglessink_start (GstEglGlesSink * eglglessink)
|
||||||
if (!eglglessink->thread || error != NULL)
|
if (!eglglessink->thread || error != NULL)
|
||||||
goto HANDLE_ERROR;
|
goto HANDLE_ERROR;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Started");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
HANDLE_ERROR:
|
HANDLE_ERROR:
|
||||||
|
@ -1199,8 +1214,12 @@ HANDLE_ERROR:
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_eglglessink_stop (GstEglGlesSink * eglglessink)
|
gst_eglglessink_stop (GstEglGlesSink * eglglessink)
|
||||||
{
|
{
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Stopping");
|
||||||
|
|
||||||
gst_data_queue_set_flushing (eglglessink->queue, TRUE);
|
gst_data_queue_set_flushing (eglglessink->queue, TRUE);
|
||||||
|
g_mutex_lock (eglglessink->render_lock);
|
||||||
g_cond_broadcast (eglglessink->render_cond);
|
g_cond_broadcast (eglglessink->render_cond);
|
||||||
|
g_mutex_unlock (eglglessink->render_lock);
|
||||||
|
|
||||||
if (eglglessink->thread) {
|
if (eglglessink->thread) {
|
||||||
g_thread_join (eglglessink->thread);
|
g_thread_join (eglglessink->thread);
|
||||||
|
@ -1220,6 +1239,8 @@ gst_eglglessink_stop (GstEglGlesSink * eglglessink)
|
||||||
eglglessink->current_caps = NULL;
|
eglglessink->current_caps = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Stopped");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2027,15 +2048,20 @@ gst_eglglessink_queue_buffer (GstEglGlesSink * eglglessink,
|
||||||
item->visible = (buf ? TRUE : FALSE);
|
item->visible = (buf ? TRUE : FALSE);
|
||||||
item->destroy = (GDestroyNotify) queue_item_destroy;
|
item->destroy = (GDestroyNotify) queue_item_destroy;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Queueing buffer %" GST_PTR_FORMAT, buf);
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
g_mutex_lock (eglglessink->render_lock);
|
g_mutex_lock (eglglessink->render_lock);
|
||||||
if (!gst_data_queue_push (eglglessink->queue, item)) {
|
if (!gst_data_queue_push (eglglessink->queue, item)) {
|
||||||
g_mutex_unlock (eglglessink->render_lock);
|
g_mutex_unlock (eglglessink->render_lock);
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Flushing");
|
||||||
return GST_FLOW_WRONG_STATE;
|
return GST_FLOW_WRONG_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf) {
|
if (buf) {
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Waiting for buffer to be rendered");
|
||||||
g_cond_wait (eglglessink->render_cond, eglglessink->render_lock);
|
g_cond_wait (eglglessink->render_cond, eglglessink->render_lock);
|
||||||
|
GST_DEBUG_OBJECT (eglglessink, "Buffer rendered: %s", gst_flow_get_name (eglglessink->last_flow));
|
||||||
g_mutex_unlock (eglglessink->render_lock);
|
g_mutex_unlock (eglglessink->render_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue