mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
app: port to the new GLib thread API
This commit is contained in:
parent
37f9177817
commit
acde0579f8
2 changed files with 127 additions and 126 deletions
|
@ -82,8 +82,8 @@ struct _GstAppSinkPrivate
|
||||||
guint max_buffers;
|
guint max_buffers;
|
||||||
gboolean drop;
|
gboolean drop;
|
||||||
|
|
||||||
GCond *cond;
|
GCond cond;
|
||||||
GMutex *mutex;
|
GMutex mutex;
|
||||||
GQueue *queue;
|
GQueue *queue;
|
||||||
GstBuffer *preroll;
|
GstBuffer *preroll;
|
||||||
GstCaps *preroll_caps;
|
GstCaps *preroll_caps;
|
||||||
|
@ -351,8 +351,8 @@ gst_app_sink_init (GstAppSink * appsink)
|
||||||
G_TYPE_INSTANCE_GET_PRIVATE (appsink, GST_TYPE_APP_SINK,
|
G_TYPE_INSTANCE_GET_PRIVATE (appsink, GST_TYPE_APP_SINK,
|
||||||
GstAppSinkPrivate);
|
GstAppSinkPrivate);
|
||||||
|
|
||||||
priv->mutex = g_mutex_new ();
|
g_mutex_init (&priv->mutex);
|
||||||
priv->cond = g_cond_new ();
|
g_cond_init (&priv->cond);
|
||||||
priv->queue = g_queue_new ();
|
priv->queue = g_queue_new ();
|
||||||
|
|
||||||
priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
|
priv->emit_signals = DEFAULT_PROP_EMIT_SIGNALS;
|
||||||
|
@ -380,13 +380,13 @@ gst_app_sink_dispose (GObject * obj)
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (appsink);
|
GST_OBJECT_UNLOCK (appsink);
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
while ((queue_obj = g_queue_pop_head (priv->queue)))
|
while ((queue_obj = g_queue_pop_head (priv->queue)))
|
||||||
gst_mini_object_unref (queue_obj);
|
gst_mini_object_unref (queue_obj);
|
||||||
gst_buffer_replace (&priv->preroll, NULL);
|
gst_buffer_replace (&priv->preroll, NULL);
|
||||||
gst_caps_replace (&priv->preroll_caps, NULL);
|
gst_caps_replace (&priv->preroll_caps, NULL);
|
||||||
gst_caps_replace (&priv->last_caps, NULL);
|
gst_caps_replace (&priv->last_caps, NULL);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
||||||
}
|
}
|
||||||
|
@ -397,8 +397,8 @@ gst_app_sink_finalize (GObject * obj)
|
||||||
GstAppSink *appsink = GST_APP_SINK_CAST (obj);
|
GstAppSink *appsink = GST_APP_SINK_CAST (obj);
|
||||||
GstAppSinkPrivate *priv = appsink->priv;
|
GstAppSinkPrivate *priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_free (priv->mutex);
|
g_mutex_clear (&priv->mutex);
|
||||||
g_cond_free (priv->cond);
|
g_cond_clear (&priv->cond);
|
||||||
g_queue_free (priv->queue);
|
g_queue_free (priv->queue);
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||||
|
@ -470,11 +470,11 @@ gst_app_sink_unlock_start (GstBaseSink * bsink)
|
||||||
GstAppSink *appsink = GST_APP_SINK_CAST (bsink);
|
GstAppSink *appsink = GST_APP_SINK_CAST (bsink);
|
||||||
GstAppSinkPrivate *priv = appsink->priv;
|
GstAppSinkPrivate *priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "unlock start");
|
GST_DEBUG_OBJECT (appsink, "unlock start");
|
||||||
priv->unlock = TRUE;
|
priv->unlock = TRUE;
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -485,11 +485,11 @@ gst_app_sink_unlock_stop (GstBaseSink * bsink)
|
||||||
GstAppSink *appsink = GST_APP_SINK_CAST (bsink);
|
GstAppSink *appsink = GST_APP_SINK_CAST (bsink);
|
||||||
GstAppSinkPrivate *priv = appsink->priv;
|
GstAppSinkPrivate *priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "unlock stop");
|
GST_DEBUG_OBJECT (appsink, "unlock stop");
|
||||||
priv->unlock = FALSE;
|
priv->unlock = FALSE;
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ gst_app_sink_flush_unlocked (GstAppSink * appsink)
|
||||||
while ((obj = g_queue_pop_head (priv->queue)))
|
while ((obj = g_queue_pop_head (priv->queue)))
|
||||||
gst_mini_object_unref (obj);
|
gst_mini_object_unref (obj);
|
||||||
priv->num_buffers = 0;
|
priv->num_buffers = 0;
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -515,12 +515,12 @@ gst_app_sink_start (GstBaseSink * psink)
|
||||||
GstAppSink *appsink = GST_APP_SINK_CAST (psink);
|
GstAppSink *appsink = GST_APP_SINK_CAST (psink);
|
||||||
GstAppSinkPrivate *priv = appsink->priv;
|
GstAppSinkPrivate *priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "starting");
|
GST_DEBUG_OBJECT (appsink, "starting");
|
||||||
priv->flushing = FALSE;
|
priv->flushing = FALSE;
|
||||||
priv->started = TRUE;
|
priv->started = TRUE;
|
||||||
gst_segment_init (&priv->last_segment, GST_FORMAT_TIME);
|
gst_segment_init (&priv->last_segment, GST_FORMAT_TIME);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -531,14 +531,14 @@ gst_app_sink_stop (GstBaseSink * psink)
|
||||||
GstAppSink *appsink = GST_APP_SINK_CAST (psink);
|
GstAppSink *appsink = GST_APP_SINK_CAST (psink);
|
||||||
GstAppSinkPrivate *priv = appsink->priv;
|
GstAppSinkPrivate *priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "stopping");
|
GST_DEBUG_OBJECT (appsink, "stopping");
|
||||||
priv->flushing = TRUE;
|
priv->flushing = TRUE;
|
||||||
priv->started = FALSE;
|
priv->started = FALSE;
|
||||||
gst_app_sink_flush_unlocked (appsink);
|
gst_app_sink_flush_unlocked (appsink);
|
||||||
gst_caps_replace (&priv->preroll_caps, NULL);
|
gst_caps_replace (&priv->preroll_caps, NULL);
|
||||||
gst_caps_replace (&priv->last_caps, NULL);
|
gst_caps_replace (&priv->last_caps, NULL);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -549,11 +549,11 @@ gst_app_sink_setcaps (GstBaseSink * sink, GstCaps * caps)
|
||||||
GstAppSink *appsink = GST_APP_SINK_CAST (sink);
|
GstAppSink *appsink = GST_APP_SINK_CAST (sink);
|
||||||
GstAppSinkPrivate *priv = appsink->priv;
|
GstAppSinkPrivate *priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "receiving CAPS");
|
GST_DEBUG_OBJECT (appsink, "receiving CAPS");
|
||||||
g_queue_push_tail (priv->queue, gst_event_new_caps (caps));
|
g_queue_push_tail (priv->queue, gst_event_new_caps (caps));
|
||||||
gst_caps_replace (&priv->preroll_caps, caps);
|
gst_caps_replace (&priv->preroll_caps, caps);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -566,17 +566,17 @@ gst_app_sink_event (GstBaseSink * sink, GstEvent * event)
|
||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case GST_EVENT_SEGMENT:
|
case GST_EVENT_SEGMENT:
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "receiving SEGMENT");
|
GST_DEBUG_OBJECT (appsink, "receiving SEGMENT");
|
||||||
g_queue_push_tail (priv->queue, gst_event_ref (event));
|
g_queue_push_tail (priv->queue, gst_event_ref (event));
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
break;
|
break;
|
||||||
case GST_EVENT_EOS:
|
case GST_EVENT_EOS:
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "receiving EOS");
|
GST_DEBUG_OBJECT (appsink, "receiving EOS");
|
||||||
priv->is_eos = TRUE;
|
priv->is_eos = TRUE;
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
/* emit EOS now */
|
/* emit EOS now */
|
||||||
if (priv->callbacks.eos)
|
if (priv->callbacks.eos)
|
||||||
|
@ -591,10 +591,10 @@ gst_app_sink_event (GstBaseSink * sink, GstEvent * event)
|
||||||
GST_DEBUG_OBJECT (appsink, "received FLUSH_START");
|
GST_DEBUG_OBJECT (appsink, "received FLUSH_START");
|
||||||
break;
|
break;
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsink, "received FLUSH_STOP");
|
GST_DEBUG_OBJECT (appsink, "received FLUSH_STOP");
|
||||||
gst_app_sink_flush_unlocked (appsink);
|
gst_app_sink_flush_unlocked (appsink);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -610,16 +610,16 @@ gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer)
|
||||||
GstAppSinkPrivate *priv = appsink->priv;
|
GstAppSinkPrivate *priv = appsink->priv;
|
||||||
gboolean emit;
|
gboolean emit;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (priv->flushing)
|
if (priv->flushing)
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
|
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
|
||||||
gst_buffer_replace (&priv->preroll, buffer);
|
gst_buffer_replace (&priv->preroll, buffer);
|
||||||
|
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
emit = priv->emit_signals;
|
emit = priv->emit_signals;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
if (priv->callbacks.new_preroll)
|
if (priv->callbacks.new_preroll)
|
||||||
res = priv->callbacks.new_preroll (appsink, priv->user_data);
|
res = priv->callbacks.new_preroll (appsink, priv->user_data);
|
||||||
|
@ -631,7 +631,7 @@ gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer)
|
||||||
flushing:
|
flushing:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return GST_FLOW_FLUSHING;
|
return GST_FLOW_FLUSHING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
|
||||||
gboolean emit;
|
gboolean emit;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (priv->flushing)
|
if (priv->flushing)
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
|
||||||
|
@ -720,7 +720,7 @@ restart:
|
||||||
|
|
||||||
if (priv->unlock) {
|
if (priv->unlock) {
|
||||||
/* we are asked to unlock, call the wait_preroll method */
|
/* we are asked to unlock, call the wait_preroll method */
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
if ((ret = gst_base_sink_wait_preroll (psink)) != GST_FLOW_OK)
|
if ((ret = gst_base_sink_wait_preroll (psink)) != GST_FLOW_OK)
|
||||||
goto stopping;
|
goto stopping;
|
||||||
|
|
||||||
|
@ -729,7 +729,7 @@ restart:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* wait for a buffer to be removed or flush */
|
/* wait for a buffer to be removed or flush */
|
||||||
g_cond_wait (priv->cond, priv->mutex);
|
g_cond_wait (&priv->cond, &priv->mutex);
|
||||||
if (priv->flushing)
|
if (priv->flushing)
|
||||||
goto flushing;
|
goto flushing;
|
||||||
}
|
}
|
||||||
|
@ -737,9 +737,9 @@ restart:
|
||||||
/* we need to ref the buffer when pushing it in the queue */
|
/* we need to ref the buffer when pushing it in the queue */
|
||||||
g_queue_push_tail (priv->queue, gst_buffer_ref (buffer));
|
g_queue_push_tail (priv->queue, gst_buffer_ref (buffer));
|
||||||
priv->num_buffers++;
|
priv->num_buffers++;
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
emit = priv->emit_signals;
|
emit = priv->emit_signals;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
if (priv->callbacks.new_sample)
|
if (priv->callbacks.new_sample)
|
||||||
priv->callbacks.new_sample (appsink, priv->user_data);
|
priv->callbacks.new_sample (appsink, priv->user_data);
|
||||||
|
@ -751,7 +751,7 @@ restart:
|
||||||
flushing:
|
flushing:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
GST_DEBUG_OBJECT (appsink, "we are flushing");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return GST_FLOW_FLUSHING;
|
return GST_FLOW_FLUSHING;
|
||||||
}
|
}
|
||||||
stopping:
|
stopping:
|
||||||
|
@ -889,7 +889,7 @@ gst_app_sink_is_eos (GstAppSink * appsink)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (!priv->started)
|
if (!priv->started)
|
||||||
goto not_started;
|
goto not_started;
|
||||||
|
|
||||||
|
@ -900,14 +900,14 @@ gst_app_sink_is_eos (GstAppSink * appsink)
|
||||||
GST_DEBUG_OBJECT (appsink, "we are not yet EOS");
|
GST_DEBUG_OBJECT (appsink, "we are not yet EOS");
|
||||||
ret = FALSE;
|
ret = FALSE;
|
||||||
}
|
}
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
not_started:
|
not_started:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return TRUE");
|
GST_DEBUG_OBJECT (appsink, "we are stopped, return TRUE");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -930,9 +930,9 @@ gst_app_sink_set_emit_signals (GstAppSink * appsink, gboolean emit)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
priv->emit_signals = emit;
|
priv->emit_signals = emit;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -954,9 +954,9 @@ gst_app_sink_get_emit_signals (GstAppSink * appsink)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
result = priv->emit_signals;
|
result = priv->emit_signals;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -979,13 +979,13 @@ gst_app_sink_set_max_buffers (GstAppSink * appsink, guint max)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (max != priv->max_buffers) {
|
if (max != priv->max_buffers) {
|
||||||
priv->max_buffers = max;
|
priv->max_buffers = max;
|
||||||
/* signal the change */
|
/* signal the change */
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
}
|
}
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1006,9 +1006,9 @@ gst_app_sink_get_max_buffers (GstAppSink * appsink)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
result = priv->max_buffers;
|
result = priv->max_buffers;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1030,13 +1030,13 @@ gst_app_sink_set_drop (GstAppSink * appsink, gboolean drop)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (priv->drop != drop) {
|
if (priv->drop != drop) {
|
||||||
priv->drop = drop;
|
priv->drop = drop;
|
||||||
/* signal the change */
|
/* signal the change */
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
}
|
}
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1059,9 +1059,9 @@ gst_app_sink_get_drop (GstAppSink * appsink)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
result = priv->drop;
|
result = priv->drop;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1099,7 +1099,7 @@ gst_app_sink_pull_preroll (GstAppSink * appsink)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
||||||
|
@ -1114,13 +1114,13 @@ gst_app_sink_pull_preroll (GstAppSink * appsink)
|
||||||
|
|
||||||
/* nothing to return, wait */
|
/* nothing to return, wait */
|
||||||
GST_DEBUG_OBJECT (appsink, "waiting for the preroll buffer");
|
GST_DEBUG_OBJECT (appsink, "waiting for the preroll buffer");
|
||||||
g_cond_wait (priv->cond, priv->mutex);
|
g_cond_wait (&priv->cond, &priv->mutex);
|
||||||
}
|
}
|
||||||
sample =
|
sample =
|
||||||
gst_sample_new (priv->preroll, priv->preroll_caps, &priv->last_segment,
|
gst_sample_new (priv->preroll, priv->preroll_caps, &priv->last_segment,
|
||||||
NULL);
|
NULL);
|
||||||
GST_DEBUG_OBJECT (appsink, "we have the preroll sample %p", sample);
|
GST_DEBUG_OBJECT (appsink, "we have the preroll sample %p", sample);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return sample;
|
return sample;
|
||||||
|
|
||||||
|
@ -1128,13 +1128,13 @@ gst_app_sink_pull_preroll (GstAppSink * appsink)
|
||||||
eos:
|
eos:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
not_started:
|
not_started:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1169,7 +1169,7 @@ gst_app_sink_pull_sample (GstAppSink * appsink)
|
||||||
|
|
||||||
priv = appsink->priv;
|
priv = appsink->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
GST_DEBUG_OBJECT (appsink, "trying to grab a buffer");
|
||||||
|
@ -1184,15 +1184,15 @@ gst_app_sink_pull_sample (GstAppSink * appsink)
|
||||||
|
|
||||||
/* nothing to return, wait */
|
/* nothing to return, wait */
|
||||||
GST_DEBUG_OBJECT (appsink, "waiting for a buffer");
|
GST_DEBUG_OBJECT (appsink, "waiting for a buffer");
|
||||||
g_cond_wait (priv->cond, priv->mutex);
|
g_cond_wait (&priv->cond, &priv->mutex);
|
||||||
}
|
}
|
||||||
buffer = dequeue_buffer (appsink);
|
buffer = dequeue_buffer (appsink);
|
||||||
GST_DEBUG_OBJECT (appsink, "we have a buffer %p", buffer);
|
GST_DEBUG_OBJECT (appsink, "we have a buffer %p", buffer);
|
||||||
sample = gst_sample_new (buffer, priv->last_caps, &priv->last_segment, NULL);
|
sample = gst_sample_new (buffer, priv->last_caps, &priv->last_segment, NULL);
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
g_cond_signal (priv->cond);
|
g_cond_signal (&priv->cond);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return sample;
|
return sample;
|
||||||
|
|
||||||
|
@ -1200,13 +1200,13 @@ gst_app_sink_pull_sample (GstAppSink * appsink)
|
||||||
eos:
|
eos:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
GST_DEBUG_OBJECT (appsink, "we are EOS, return NULL");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
not_started:
|
not_started:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
GST_DEBUG_OBJECT (appsink, "we are stopped, return NULL");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,8 @@
|
||||||
|
|
||||||
struct _GstAppSrcPrivate
|
struct _GstAppSrcPrivate
|
||||||
{
|
{
|
||||||
GCond *cond;
|
GCond cond;
|
||||||
GMutex *mutex;
|
GMutex mutex;
|
||||||
GQueue *queue;
|
GQueue *queue;
|
||||||
|
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
@ -492,8 +492,8 @@ gst_app_src_init (GstAppSrc * appsrc)
|
||||||
priv = appsrc->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsrc, GST_TYPE_APP_SRC,
|
priv = appsrc->priv = G_TYPE_INSTANCE_GET_PRIVATE (appsrc, GST_TYPE_APP_SRC,
|
||||||
GstAppSrcPrivate);
|
GstAppSrcPrivate);
|
||||||
|
|
||||||
priv->mutex = g_mutex_new ();
|
g_mutex_init (&priv->mutex);
|
||||||
priv->cond = g_cond_new ();
|
g_cond_init (&priv->cond);
|
||||||
priv->queue = g_queue_new ();
|
priv->queue = g_queue_new ();
|
||||||
|
|
||||||
priv->size = DEFAULT_PROP_SIZE;
|
priv->size = DEFAULT_PROP_SIZE;
|
||||||
|
@ -541,8 +541,9 @@ gst_app_src_finalize (GObject * obj)
|
||||||
GstAppSrc *appsrc = GST_APP_SRC_CAST (obj);
|
GstAppSrc *appsrc = GST_APP_SRC_CAST (obj);
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_free (priv->mutex);
|
g_mutex_clear (&priv->mutex);
|
||||||
g_cond_free (priv->cond);
|
g_cond_clear (&priv->cond);
|
||||||
|
g_cond_clear (&priv->cond);
|
||||||
g_queue_free (priv->queue);
|
g_queue_free (priv->queue);
|
||||||
|
|
||||||
g_free (priv->uri);
|
g_free (priv->uri);
|
||||||
|
@ -689,11 +690,11 @@ gst_app_src_unlock (GstBaseSrc * bsrc)
|
||||||
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "unlock start");
|
GST_DEBUG_OBJECT (appsrc, "unlock start");
|
||||||
priv->flushing = TRUE;
|
priv->flushing = TRUE;
|
||||||
g_cond_broadcast (priv->cond);
|
g_cond_broadcast (&priv->cond);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -704,11 +705,11 @@ gst_app_src_unlock_stop (GstBaseSrc * bsrc)
|
||||||
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "unlock stop");
|
GST_DEBUG_OBJECT (appsrc, "unlock stop");
|
||||||
priv->flushing = FALSE;
|
priv->flushing = FALSE;
|
||||||
g_cond_broadcast (priv->cond);
|
g_cond_broadcast (&priv->cond);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -719,7 +720,7 @@ gst_app_src_start (GstBaseSrc * bsrc)
|
||||||
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "starting");
|
GST_DEBUG_OBJECT (appsrc, "starting");
|
||||||
priv->new_caps = FALSE;
|
priv->new_caps = FALSE;
|
||||||
priv->started = TRUE;
|
priv->started = TRUE;
|
||||||
|
@ -727,7 +728,7 @@ gst_app_src_start (GstBaseSrc * bsrc)
|
||||||
* in random-access mode. */
|
* in random-access mode. */
|
||||||
priv->offset = -1;
|
priv->offset = -1;
|
||||||
priv->flushing = FALSE;
|
priv->flushing = FALSE;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
gst_base_src_set_format (bsrc, priv->format);
|
gst_base_src_set_format (bsrc, priv->format);
|
||||||
|
|
||||||
|
@ -740,13 +741,13 @@ gst_app_src_stop (GstBaseSrc * bsrc)
|
||||||
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
|
GstAppSrc *appsrc = GST_APP_SRC_CAST (bsrc);
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "stopping");
|
GST_DEBUG_OBJECT (appsrc, "stopping");
|
||||||
priv->is_eos = FALSE;
|
priv->is_eos = FALSE;
|
||||||
priv->flushing = TRUE;
|
priv->flushing = TRUE;
|
||||||
priv->started = FALSE;
|
priv->started = FALSE;
|
||||||
gst_app_src_flush_queued (appsrc);
|
gst_app_src_flush_queued (appsrc);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -796,12 +797,12 @@ gst_app_src_query (GstBaseSrc * src, GstQuery * query)
|
||||||
res = gst_base_src_query_latency (src, &live, &min, &max);
|
res = gst_base_src_query_latency (src, &live, &min, &max);
|
||||||
|
|
||||||
/* overwrite with our values when we need to */
|
/* overwrite with our values when we need to */
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (priv->min_latency != -1)
|
if (priv->min_latency != -1)
|
||||||
min = priv->min_latency;
|
min = priv->min_latency;
|
||||||
if (priv->max_latency != -1)
|
if (priv->max_latency != -1)
|
||||||
max = priv->max_latency;
|
max = priv->max_latency;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
gst_query_set_latency (query, live, min, max);
|
gst_query_set_latency (query, live, min, max);
|
||||||
break;
|
break;
|
||||||
|
@ -853,9 +854,9 @@ gst_app_src_do_seek (GstBaseSrc * src, GstSegment * segment)
|
||||||
else {
|
else {
|
||||||
gboolean emit;
|
gboolean emit;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
emit = priv->emit_signals;
|
emit = priv->emit_signals;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
if (emit)
|
if (emit)
|
||||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
||||||
|
@ -882,7 +883,7 @@ gst_app_src_emit_seek (GstAppSrc * appsrc, guint64 offset)
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
|
|
||||||
emit = priv->emit_signals;
|
emit = priv->emit_signals;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsrc,
|
GST_DEBUG_OBJECT (appsrc,
|
||||||
"we are at %" G_GINT64_FORMAT ", seek to %" G_GINT64_FORMAT,
|
"we are at %" G_GINT64_FORMAT ", seek to %" G_GINT64_FORMAT,
|
||||||
|
@ -894,7 +895,7 @@ gst_app_src_emit_seek (GstAppSrc * appsrc, guint64 offset)
|
||||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_SEEK_DATA], 0,
|
||||||
offset, &res);
|
offset, &res);
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -908,7 +909,7 @@ gst_app_src_emit_need_data (GstAppSrc * appsrc, guint size)
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
|
|
||||||
emit = priv->emit_signals;
|
emit = priv->emit_signals;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
/* we have no data, we need some. We fire the signal with the size hint. */
|
/* we have no data, we need some. We fire the signal with the size hint. */
|
||||||
if (priv->callbacks.need_data)
|
if (priv->callbacks.need_data)
|
||||||
|
@ -917,7 +918,7 @@ gst_app_src_emit_need_data (GstAppSrc * appsrc, guint size)
|
||||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_NEED_DATA], 0, size,
|
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_NEED_DATA], 0, size,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
/* we can be flushing now because we released the lock */
|
/* we can be flushing now because we released the lock */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,10 +951,10 @@ gst_app_src_negotiate (GstBaseSrc * basesrc)
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
gboolean result;
|
gboolean result;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
result = gst_app_src_do_negotiate (basesrc);
|
result = gst_app_src_do_negotiate (basesrc);
|
||||||
priv->new_caps = FALSE;
|
priv->new_caps = FALSE;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -980,7 +981,7 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
GST_OBJECT_UNLOCK (appsrc);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
/* check flushing first */
|
/* check flushing first */
|
||||||
if (G_UNLIKELY (priv->flushing))
|
if (G_UNLIKELY (priv->flushing))
|
||||||
goto flushing;
|
goto flushing;
|
||||||
|
@ -1024,7 +1025,7 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
||||||
priv->offset += buf_size;
|
priv->offset += buf_size;
|
||||||
|
|
||||||
/* signal that we removed an item */
|
/* signal that we removed an item */
|
||||||
g_cond_broadcast (priv->cond);
|
g_cond_broadcast (&priv->cond);
|
||||||
|
|
||||||
/* see if we go lower than the empty-percent */
|
/* see if we go lower than the empty-percent */
|
||||||
if (priv->min_percent && priv->max_bytes) {
|
if (priv->min_percent && priv->max_bytes) {
|
||||||
|
@ -1058,27 +1059,27 @@ gst_app_src_create (GstBaseSrc * bsrc, guint64 offset, guint size,
|
||||||
goto eos;
|
goto eos;
|
||||||
|
|
||||||
/* nothing to return, wait a while for new data or flushing. */
|
/* nothing to return, wait a while for new data or flushing. */
|
||||||
g_cond_wait (priv->cond, priv->mutex);
|
g_cond_wait (&priv->cond, &priv->mutex);
|
||||||
}
|
}
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
flushing:
|
flushing:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsrc, "we are flushing");
|
GST_DEBUG_OBJECT (appsrc, "we are flushing");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return GST_FLOW_FLUSHING;
|
return GST_FLOW_FLUSHING;
|
||||||
}
|
}
|
||||||
eos:
|
eos:
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (appsrc, "we are EOS");
|
GST_DEBUG_OBJECT (appsrc, "we are EOS");
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return GST_FLOW_EOS;
|
return GST_FLOW_EOS;
|
||||||
}
|
}
|
||||||
seek_error:
|
seek_error:
|
||||||
{
|
{
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
GST_ELEMENT_ERROR (appsrc, RESOURCE, READ, ("failed to seek"),
|
GST_ELEMENT_ERROR (appsrc, RESOURCE, READ, ("failed to seek"),
|
||||||
GST_ERROR_SYSTEM);
|
GST_ERROR_SYSTEM);
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
|
@ -1116,9 +1117,9 @@ gst_app_src_set_caps (GstAppSrc * appsrc, const GstCaps * caps)
|
||||||
priv->caps = NULL;
|
priv->caps = NULL;
|
||||||
if (old)
|
if (old)
|
||||||
gst_caps_unref (old);
|
gst_caps_unref (old);
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
priv->new_caps = TRUE;
|
priv->new_caps = TRUE;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
}
|
}
|
||||||
GST_OBJECT_UNLOCK (appsrc);
|
GST_OBJECT_UNLOCK (appsrc);
|
||||||
}
|
}
|
||||||
|
@ -1259,14 +1260,14 @@ gst_app_src_set_max_bytes (GstAppSrc * appsrc, guint64 max)
|
||||||
|
|
||||||
priv = appsrc->priv;
|
priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (max != priv->max_bytes) {
|
if (max != priv->max_bytes) {
|
||||||
GST_DEBUG_OBJECT (appsrc, "setting max-bytes to %" G_GUINT64_FORMAT, max);
|
GST_DEBUG_OBJECT (appsrc, "setting max-bytes to %" G_GUINT64_FORMAT, max);
|
||||||
priv->max_bytes = max;
|
priv->max_bytes = max;
|
||||||
/* signal the change */
|
/* signal the change */
|
||||||
g_cond_broadcast (priv->cond);
|
g_cond_broadcast (&priv->cond);
|
||||||
}
|
}
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1287,10 +1288,10 @@ gst_app_src_get_max_bytes (GstAppSrc * appsrc)
|
||||||
|
|
||||||
priv = appsrc->priv;
|
priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
result = priv->max_bytes;
|
result = priv->max_bytes;
|
||||||
GST_DEBUG_OBJECT (appsrc, "getting max-bytes of %" G_GUINT64_FORMAT, result);
|
GST_DEBUG_OBJECT (appsrc, "getting max-bytes of %" G_GUINT64_FORMAT, result);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1302,7 +1303,7 @@ gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min,
|
||||||
GstAppSrcPrivate *priv = appsrc->priv;
|
GstAppSrcPrivate *priv = appsrc->priv;
|
||||||
gboolean changed = FALSE;
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (do_min && priv->min_latency != min) {
|
if (do_min && priv->min_latency != min) {
|
||||||
priv->min_latency = min;
|
priv->min_latency = min;
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
|
@ -1311,7 +1312,7 @@ gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min,
|
||||||
priv->max_latency = max;
|
priv->max_latency = max;
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
GST_DEBUG_OBJECT (appsrc, "posting latency changed");
|
GST_DEBUG_OBJECT (appsrc, "posting latency changed");
|
||||||
|
@ -1352,12 +1353,12 @@ gst_app_src_get_latency (GstAppSrc * appsrc, guint64 * min, guint64 * max)
|
||||||
|
|
||||||
priv = appsrc->priv;
|
priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
if (min)
|
if (min)
|
||||||
*min = priv->min_latency;
|
*min = priv->min_latency;
|
||||||
if (max)
|
if (max)
|
||||||
*max = priv->max_latency;
|
*max = priv->max_latency;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1378,9 +1379,9 @@ gst_app_src_set_emit_signals (GstAppSrc * appsrc, gboolean emit)
|
||||||
|
|
||||||
priv = appsrc->priv;
|
priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
priv->emit_signals = emit;
|
priv->emit_signals = emit;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1402,9 +1403,9 @@ gst_app_src_get_emit_signals (GstAppSrc * appsrc)
|
||||||
|
|
||||||
priv = appsrc->priv;
|
priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
result = priv->emit_signals;
|
result = priv->emit_signals;
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1421,7 +1422,7 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
|
||||||
|
|
||||||
priv = appsrc->priv;
|
priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
/* can't accept buffers when we are flushing or EOS */
|
/* can't accept buffers when we are flushing or EOS */
|
||||||
|
@ -1441,7 +1442,7 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
|
||||||
|
|
||||||
emit = priv->emit_signals;
|
emit = priv->emit_signals;
|
||||||
/* only signal on the first push */
|
/* only signal on the first push */
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
if (priv->callbacks.enough_data)
|
if (priv->callbacks.enough_data)
|
||||||
priv->callbacks.enough_data (appsrc, priv->user_data);
|
priv->callbacks.enough_data (appsrc, priv->user_data);
|
||||||
|
@ -1449,7 +1450,7 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
|
||||||
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_ENOUGH_DATA], 0,
|
g_signal_emit (appsrc, gst_app_src_signals[SIGNAL_ENOUGH_DATA], 0,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
/* continue to check for flushing/eos after releasing the lock */
|
/* continue to check for flushing/eos after releasing the lock */
|
||||||
first = FALSE;
|
first = FALSE;
|
||||||
continue;
|
continue;
|
||||||
|
@ -1458,7 +1459,7 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
|
||||||
GST_DEBUG_OBJECT (appsrc, "waiting for free space");
|
GST_DEBUG_OBJECT (appsrc, "waiting for free space");
|
||||||
/* we are filled, wait until a buffer gets popped or when we
|
/* we are filled, wait until a buffer gets popped or when we
|
||||||
* flush. */
|
* flush. */
|
||||||
g_cond_wait (priv->cond, priv->mutex);
|
g_cond_wait (&priv->cond, &priv->mutex);
|
||||||
} else {
|
} else {
|
||||||
/* no need to wait for free space, we just pump more data into the
|
/* no need to wait for free space, we just pump more data into the
|
||||||
* queue hoping that the caller reacts to the enough-data signal and
|
* queue hoping that the caller reacts to the enough-data signal and
|
||||||
|
@ -1474,8 +1475,8 @@ gst_app_src_push_buffer_full (GstAppSrc * appsrc, GstBuffer * buffer,
|
||||||
gst_buffer_ref (buffer);
|
gst_buffer_ref (buffer);
|
||||||
g_queue_push_tail (priv->queue, buffer);
|
g_queue_push_tail (priv->queue, buffer);
|
||||||
priv->queued_bytes += gst_buffer_get_size (buffer);
|
priv->queued_bytes += gst_buffer_get_size (buffer);
|
||||||
g_cond_broadcast (priv->cond);
|
g_cond_broadcast (&priv->cond);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
@ -1485,7 +1486,7 @@ flushing:
|
||||||
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
|
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are flushing", buffer);
|
||||||
if (steal_ref)
|
if (steal_ref)
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return GST_FLOW_FLUSHING;
|
return GST_FLOW_FLUSHING;
|
||||||
}
|
}
|
||||||
eos:
|
eos:
|
||||||
|
@ -1493,7 +1494,7 @@ eos:
|
||||||
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
|
GST_DEBUG_OBJECT (appsrc, "refuse buffer %p, we are EOS", buffer);
|
||||||
if (steal_ref)
|
if (steal_ref)
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
return GST_FLOW_EOS;
|
return GST_FLOW_EOS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1546,7 +1547,7 @@ gst_app_src_end_of_stream (GstAppSrc * appsrc)
|
||||||
|
|
||||||
priv = appsrc->priv;
|
priv = appsrc->priv;
|
||||||
|
|
||||||
g_mutex_lock (priv->mutex);
|
g_mutex_lock (&priv->mutex);
|
||||||
/* can't accept buffers when we are flushing. We can accept them when we are
|
/* can't accept buffers when we are flushing. We can accept them when we are
|
||||||
* EOS although it will not do anything. */
|
* EOS although it will not do anything. */
|
||||||
if (priv->flushing)
|
if (priv->flushing)
|
||||||
|
@ -1554,15 +1555,15 @@ gst_app_src_end_of_stream (GstAppSrc * appsrc)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (appsrc, "sending EOS");
|
GST_DEBUG_OBJECT (appsrc, "sending EOS");
|
||||||
priv->is_eos = TRUE;
|
priv->is_eos = TRUE;
|
||||||
g_cond_broadcast (priv->cond);
|
g_cond_broadcast (&priv->cond);
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
flushing:
|
flushing:
|
||||||
{
|
{
|
||||||
g_mutex_unlock (priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
GST_DEBUG_OBJECT (appsrc, "refuse EOS, we are flushing");
|
GST_DEBUG_OBJECT (appsrc, "refuse EOS, we are flushing");
|
||||||
return GST_FLOW_FLUSHING;
|
return GST_FLOW_FLUSHING;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue