From e9606ada9330cc6943470c1417f8edaf46127781 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 22 Nov 2005 11:25:01 +0000 Subject: [PATCH] gst/base/gstbasesink.c: Make sure the GstFlowReturn is returned. Original commit message from CVS: * gst/base/gstbasesink.c: (gst_base_sink_handle_object): Make sure the GstFlowReturn is returned. * gst/gstbus.c: (gst_bus_add_signal_watch_full), (gst_bus_add_signal_watch): * gst/gstbus.h: add gst_bus_add_signal_watch_full. * gst/gstplugin.c: (gst_plugin_load_file): Small style cleanup. --- ChangeLog | 13 +++++++++ gst/base/gstbasesink.c | 8 ++--- gst/gstbus.c | 58 +++++++++++++++++++++++++------------ gst/gstbus.h | 1 + gst/gstplugin.c | 11 ++++--- libs/gst/base/gstbasesink.c | 8 ++--- 6 files changed, 67 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index f70ebcdd9f..c9ce5118e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-11-22 Wim Taymans + + * gst/base/gstbasesink.c: (gst_base_sink_handle_object): + Make sure the GstFlowReturn is returned. + + * gst/gstbus.c: (gst_bus_add_signal_watch_full), + (gst_bus_add_signal_watch): + * gst/gstbus.h: + add gst_bus_add_signal_watch_full. + + * gst/gstplugin.c: (gst_plugin_load_file): + Small style cleanup. + 2005-11-22 Jan Schmidt * check/gst/gstevent.c: (test_event), (GST_START_TEST): diff --git a/gst/base/gstbasesink.c b/gst/base/gstbasesink.c index 1d35d4d7cd..646b72f90b 100644 --- a/gst/base/gstbasesink.c +++ b/gst/base/gstbasesink.c @@ -558,6 +558,7 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad, { gint length; gboolean have_event; + GstFlowReturn ret; GST_PAD_PREROLL_LOCK (pad); /* push object on the queue */ @@ -658,7 +659,6 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad, /* if it's a buffer, we need to call the preroll method */ if (GST_IS_BUFFER (obj)) { GstBaseSinkClass *bclass; - GstFlowReturn pres; GstBuffer *buf = GST_BUFFER (obj); GST_DEBUG_OBJECT (basesink, "preroll buffer %" GST_TIME_FORMAT, @@ -666,7 +666,7 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad, bclass = GST_BASE_SINK_GET_CLASS (basesink); if (bclass->preroll) - if ((pres = bclass->preroll (basesink, buf)) != GST_FLOW_OK) + if ((ret = bclass->preroll (basesink, buf)) != GST_FLOW_OK) goto preroll_failed; } } @@ -721,8 +721,6 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad, no_preroll: { - GstFlowReturn ret; - GST_DEBUG_OBJECT (basesink, "no preroll needed"); /* maybe it was another sink that blocked in preroll, need to check for buffers to drain */ @@ -767,7 +765,7 @@ preroll_failed: GST_DEBUG_OBJECT (basesink, "abort state"); gst_element_abort_state (GST_ELEMENT (basesink)); - return GST_FLOW_ERROR; + return ret; } } diff --git a/gst/gstbus.c b/gst/gstbus.c index c0e4de07b8..e0376d0590 100644 --- a/gst/gstbus.c +++ b/gst/gstbus.c @@ -903,6 +903,45 @@ gst_bus_sync_signal_handler (GstBus * bus, GstMessage * message, gpointer data) return GST_BUS_PASS; } +/** + * gst_bus_add_signal_watch_full: + * @bus: a #GstBus on which you want to recieve the "message" signal + * @priority: The priority of the watch. + * + * Adds a bus signal watch to the default main context with the given priority. + * After calling this statement, the bus will emit the message signal for each + * message posted on the bus. + * + * This function may be called multiple times. To clean up, the caller is + * responsible for calling gst_bus_remove_signal_watch() as many times as this + * function is called. + * + * MT safe. + */ +void +gst_bus_add_signal_watch_full (GstBus * bus, gint priority) +{ + g_return_if_fail (GST_IS_BUS (bus)); + + /* I know the callees don't take this lock, so go ahead and abuse it */ + GST_OBJECT_LOCK (bus); + + if (bus->num_signal_watchers > 0) + goto done; + + g_assert (bus->signal_watch_id == 0); + + bus->signal_watch_id = + gst_bus_add_watch_full (bus, priority, gst_bus_async_signal_func, NULL, + NULL); + +done: + + bus->num_signal_watchers++; + + GST_OBJECT_UNLOCK (bus); +} + /** * gst_bus_add_signal_watch: * @bus: a #GstBus on which you want to recieve the "message" signal @@ -920,24 +959,7 @@ gst_bus_sync_signal_handler (GstBus * bus, GstMessage * message, gpointer data) void gst_bus_add_signal_watch (GstBus * bus) { - g_return_if_fail (GST_IS_BUS (bus)); - - /* I know the callees don't take this lock, so go ahead and abuse it */ - GST_OBJECT_LOCK (bus); - - if (bus->num_signal_watchers > 0) - goto done; - - g_assert (bus->signal_watch_id == 0); - - bus->signal_watch_id = - gst_bus_add_watch (bus, gst_bus_async_signal_func, NULL); - -done: - - bus->num_signal_watchers++; - - GST_OBJECT_UNLOCK (bus); + gst_bus_add_signal_watch_full (bus, G_PRIORITY_DEFAULT); } /** diff --git a/gst/gstbus.h b/gst/gstbus.h index 54930132d3..8dcd1dbb14 100644 --- a/gst/gstbus.h +++ b/gst/gstbus.h @@ -168,6 +168,7 @@ GstBusSyncReply gst_bus_sync_signal_handler (GstBus *bus, GstMessage *message, /* convenience api to add/remove a gsource that emits the async signals */ void gst_bus_add_signal_watch (GstBus * bus); +void gst_bus_add_signal_watch_full (GstBus * bus, gint priority); void gst_bus_remove_signal_watch (GstBus * bus); G_END_DECLS diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 7003a078fb..d6d90b4c29 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -467,11 +467,14 @@ gst_plugin_load_file (const gchar * filename, GError ** error) g_static_mutex_unlock (&gst_plugin_loading_mutex); return plugin; + return_error: - if (plugin) - gst_object_unref (plugin); - g_static_mutex_unlock (&gst_plugin_loading_mutex); - return NULL; + { + if (plugin) + gst_object_unref (plugin); + g_static_mutex_unlock (&gst_plugin_loading_mutex); + return NULL; + } } static void diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index 1d35d4d7cd..646b72f90b 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -558,6 +558,7 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad, { gint length; gboolean have_event; + GstFlowReturn ret; GST_PAD_PREROLL_LOCK (pad); /* push object on the queue */ @@ -658,7 +659,6 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad, /* if it's a buffer, we need to call the preroll method */ if (GST_IS_BUFFER (obj)) { GstBaseSinkClass *bclass; - GstFlowReturn pres; GstBuffer *buf = GST_BUFFER (obj); GST_DEBUG_OBJECT (basesink, "preroll buffer %" GST_TIME_FORMAT, @@ -666,7 +666,7 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad, bclass = GST_BASE_SINK_GET_CLASS (basesink); if (bclass->preroll) - if ((pres = bclass->preroll (basesink, buf)) != GST_FLOW_OK) + if ((ret = bclass->preroll (basesink, buf)) != GST_FLOW_OK) goto preroll_failed; } } @@ -721,8 +721,6 @@ gst_base_sink_handle_object (GstBaseSink * basesink, GstPad * pad, no_preroll: { - GstFlowReturn ret; - GST_DEBUG_OBJECT (basesink, "no preroll needed"); /* maybe it was another sink that blocked in preroll, need to check for buffers to drain */ @@ -767,7 +765,7 @@ preroll_failed: GST_DEBUG_OBJECT (basesink, "abort state"); gst_element_abort_state (GST_ELEMENT (basesink)); - return GST_FLOW_ERROR; + return ret; } }