mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
appsink: don't block in paused
When we are asked to unlock we should either leave the render function or call the wait_preroll method to release the stream lock. Fixes #592657
This commit is contained in:
parent
7868660f1e
commit
2c08c76383
1 changed files with 21 additions and 2 deletions
|
@ -102,6 +102,7 @@ struct _GstAppSinkPrivate
|
|||
GQueue *queue;
|
||||
GstBuffer *preroll;
|
||||
gboolean flushing;
|
||||
gboolean unlock;
|
||||
gboolean started;
|
||||
gboolean is_eos;
|
||||
|
||||
|
@ -577,7 +578,7 @@ gst_app_sink_unlock_start (GstBaseSink * bsink)
|
|||
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsink, "unlock start");
|
||||
appsink->priv->flushing = TRUE;
|
||||
appsink->priv->unlock = TRUE;
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
|
@ -591,7 +592,7 @@ gst_app_sink_unlock_stop (GstBaseSink * bsink)
|
|||
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
GST_DEBUG_OBJECT (appsink, "unlock stop");
|
||||
appsink->priv->flushing = FALSE;
|
||||
appsink->priv->unlock = FALSE;
|
||||
g_cond_signal (appsink->priv->cond);
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
|
||||
|
@ -716,9 +717,11 @@ static GstFlowReturn
|
|||
gst_app_sink_render_common (GstBaseSink * psink, GstMiniObject * data,
|
||||
gboolean is_list)
|
||||
{
|
||||
GstFlowReturn ret;
|
||||
GstAppSink *appsink = GST_APP_SINK (psink);
|
||||
gboolean emit;
|
||||
|
||||
restart:
|
||||
g_mutex_lock (appsink->priv->mutex);
|
||||
if (appsink->priv->flushing)
|
||||
goto flushing;
|
||||
|
@ -738,6 +741,17 @@ gst_app_sink_render_common (GstBaseSink * psink, GstMiniObject * data,
|
|||
} else {
|
||||
GST_DEBUG_OBJECT (appsink, "waiting for free space, length %d >= %d",
|
||||
appsink->priv->queue->length, appsink->priv->max_buffers);
|
||||
|
||||
if (appsink->priv->unlock) {
|
||||
/* we are asked to unlock, call the wait_preroll method */
|
||||
g_mutex_unlock (appsink->priv->mutex);
|
||||
if ((ret = gst_base_sink_wait_preroll (psink)) != GST_FLOW_OK)
|
||||
goto stopping;
|
||||
|
||||
/* we are allowed to continue now */
|
||||
goto restart;
|
||||
}
|
||||
|
||||
/* wait for a buffer to be removed or flush */
|
||||
g_cond_wait (appsink->priv->cond, appsink->priv->mutex);
|
||||
if (appsink->priv->flushing)
|
||||
|
@ -768,6 +782,11 @@ flushing:
|
|||
g_mutex_unlock (appsink->priv->mutex);
|
||||
return GST_FLOW_WRONG_STATE;
|
||||
}
|
||||
stopping:
|
||||
{
|
||||
GST_DEBUG_OBJECT (appsink, "we are stopping");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
|
Loading…
Reference in a new issue