Commit ee03bf53 authored by Martin Samuelsson's avatar Martin Samuelsson Committed by Wim Taymans
Browse files

appsink: make callbacks return GstFlowReturn

Make the new_buffer and new_preroll callbacks return a GstFlowReturn so that
errors can be reported properly.
Fixes #577827.
parent e6798c5c
...@@ -624,6 +624,7 @@ gst_app_sink_event (GstBaseSink * sink, GstEvent * event) ...@@ -624,6 +624,7 @@ gst_app_sink_event (GstBaseSink * sink, GstEvent * event)
static GstFlowReturn static GstFlowReturn
gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer) gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer)
{ {
GstFlowReturn res = GST_FLOW_OK;
GstAppSink *appsink = GST_APP_SINK (psink); GstAppSink *appsink = GST_APP_SINK (psink);
gboolean emit; gboolean emit;
...@@ -633,16 +634,19 @@ gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer) ...@@ -633,16 +634,19 @@ gst_app_sink_preroll (GstBaseSink * psink, GstBuffer * buffer)
GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer); GST_DEBUG_OBJECT (appsink, "setting preroll buffer %p", buffer);
gst_buffer_replace (&appsink->priv->preroll, buffer); gst_buffer_replace (&appsink->priv->preroll, buffer);
g_cond_signal (appsink->priv->cond); g_cond_signal (appsink->priv->cond);
emit = appsink->priv->emit_signals; emit = appsink->priv->emit_signals;
g_mutex_unlock (appsink->priv->mutex); g_mutex_unlock (appsink->priv->mutex);
if (appsink->priv->callbacks.new_preroll) if (appsink->priv->callbacks.new_preroll)
appsink->priv->callbacks.new_preroll (appsink, appsink->priv->user_data); res =
appsink->priv->callbacks.new_preroll (appsink,
appsink->priv->user_data);
else if (emit) else if (emit)
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_PREROLL], 0); g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_PREROLL], 0);
return GST_FLOW_OK; return res;
flushing: flushing:
{ {
...@@ -655,6 +659,7 @@ flushing: ...@@ -655,6 +659,7 @@ flushing:
static GstFlowReturn static GstFlowReturn
gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer) gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
{ {
GstFlowReturn res = GST_FLOW_OK;
GstAppSink *appsink = GST_APP_SINK (psink); GstAppSink *appsink = GST_APP_SINK (psink);
gboolean emit; gboolean emit;
...@@ -685,16 +690,18 @@ gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer) ...@@ -685,16 +690,18 @@ gst_app_sink_render (GstBaseSink * psink, GstBuffer * buffer)
} }
/* 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 (appsink->priv->queue, gst_buffer_ref (buffer)); g_queue_push_tail (appsink->priv->queue, gst_buffer_ref (buffer));
g_cond_signal (appsink->priv->cond); g_cond_signal (appsink->priv->cond);
emit = appsink->priv->emit_signals; emit = appsink->priv->emit_signals;
g_mutex_unlock (appsink->priv->mutex); g_mutex_unlock (appsink->priv->mutex);
if (appsink->priv->callbacks.new_buffer) if (appsink->priv->callbacks.new_buffer)
appsink->priv->callbacks.new_buffer (appsink, appsink->priv->user_data); res =
appsink->priv->callbacks.new_buffer (appsink, appsink->priv->user_data);
else if (emit) else if (emit)
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER], 0); g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER], 0);
return GST_FLOW_OK; return res;
flushing: flushing:
{ {
......
...@@ -42,15 +42,15 @@ typedef struct _GstAppSinkPrivate GstAppSinkPrivate; ...@@ -42,15 +42,15 @@ typedef struct _GstAppSinkPrivate GstAppSinkPrivate;
/** /**
* GstAppSinkCallbacks: * GstAppSinkCallbacks:
* @eos: Signal that the end-of-stream has been reached. This signal is * @eos: Called when the end-of-stream has been reached. This callback
* emited from the steaming thread. * is called from the steaming thread.
* @new_preroll: Signal that a new preroll buffer is available. * @new_preroll: Called when a new preroll buffer is available.
* This signal is emited from the steaming thread. * This callback is called from the steaming thread.
* The new preroll buffer can be retrieved with * The new preroll buffer can be retrieved with
* gst_app_sink_pull_preroll() either from this callback * gst_app_sink_pull_preroll() either from this callback
* or from any other thread. * or from any other thread.
* @new_buffer: Signal that a new buffer is available. * @new_buffer: Called when a new buffer is available.
* This signal is emited from the steaming thread. * This callback is called from the steaming thread.
* The new buffer can be retrieved with * The new buffer can be retrieved with
* gst_app_sink_pull_buffer() either from this callback * gst_app_sink_pull_buffer() either from this callback
* or from any other thread. * or from any other thread.
...@@ -61,9 +61,9 @@ typedef struct _GstAppSinkPrivate GstAppSinkPrivate; ...@@ -61,9 +61,9 @@ typedef struct _GstAppSinkPrivate GstAppSinkPrivate;
* Since: 0.10.23 * Since: 0.10.23
*/ */
typedef struct { typedef struct {
void (*eos) (GstAppSink *sink, gpointer user_data); void (*eos) (GstAppSink *sink, gpointer user_data);
void (*new_preroll) (GstAppSink *sink, gpointer user_data); GstFlowReturn (*new_preroll) (GstAppSink *sink, gpointer user_data);
void (*new_buffer) (GstAppSink *sink, gpointer user_data); GstFlowReturn (*new_buffer) (GstAppSink *sink, gpointer user_data);
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];
......
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