From aabe6fe0137e05ca84fca6a30ba189fb222e5084 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 4 Oct 2005 18:46:09 +0000 Subject: [PATCH] gst/elements/: Protect last_message with lock. Original commit message from CVS: * gst/elements/gstfakesink.c: (gst_fake_sink_get_property), (gst_fake_sink_event), (gst_fake_sink_preroll), (gst_fake_sink_render), (gst_fake_sink_change_state): * gst/elements/gstfakesrc.c: (gst_fake_src_event_handler), (gst_fake_src_get_property), (gst_fake_src_create), (gst_fake_src_stop): * gst/elements/gstidentity.c: (gst_identity_stop): Protect last_message with lock. --- ChangeLog | 11 +++++++++++ gst/elements/gstfakesink.c | 10 ++++++++++ gst/elements/gstfakesrc.c | 8 ++++++++ gst/elements/gstidentity.c | 2 ++ gst/elements/gsttee.c | 1 + plugins/elements/gstfakesink.c | 10 ++++++++++ plugins/elements/gstfakesrc.c | 8 ++++++++ plugins/elements/gstidentity.c | 2 ++ plugins/elements/gsttee.c | 1 + 9 files changed, 53 insertions(+) diff --git a/ChangeLog b/ChangeLog index 51186b4..32ab61e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-10-04 Wim Taymans + + * gst/elements/gstfakesink.c: (gst_fake_sink_get_property), + (gst_fake_sink_event), (gst_fake_sink_preroll), + (gst_fake_sink_render), (gst_fake_sink_change_state): + * gst/elements/gstfakesrc.c: (gst_fake_src_event_handler), + (gst_fake_src_get_property), (gst_fake_src_create), + (gst_fake_src_stop): + * gst/elements/gstidentity.c: (gst_identity_stop): + Protect last_message with lock. + 2005-10-04 Edward Hervey * gst/gstformat.h: diff --git a/gst/elements/gstfakesink.c b/gst/elements/gstfakesink.c index 7adab5d..f4aff51 100644 --- a/gst/elements/gstfakesink.c +++ b/gst/elements/gstfakesink.c @@ -274,7 +274,9 @@ gst_fake_sink_get_property (GObject * object, guint prop_id, GValue * value, g_value_set_boolean (value, sink->signal_handoffs); break; case PROP_LAST_MESSAGE: + GST_LOCK (sink); g_value_set_string (value, sink->last_message); + GST_UNLOCK (sink); break; case PROP_CAN_ACTIVATE_PUSH: g_value_set_boolean (value, GST_BASE_SINK (sink)->can_activate_push); @@ -297,6 +299,7 @@ gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event) if (!sink->silent) { gchar *sstr; + GST_LOCK (sink); g_free (sink->last_message); if ((s = gst_event_get_structure (event))) @@ -308,6 +311,7 @@ gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event) g_strdup_printf ("event ******* E (type: %d, %s) %p", GST_EVENT_TYPE (event), sstr, event); g_free (sstr); + GST_UNLOCK (sink); g_object_notify (G_OBJECT (sink), "last_message"); } @@ -321,9 +325,11 @@ gst_fake_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer) GstFakeSink *sink = GST_FAKE_SINK (bsink); if (!sink->silent) { + GST_LOCK (sink); g_free (sink->last_message); sink->last_message = g_strdup_printf ("preroll ******* "); + GST_UNLOCK (sink); g_object_notify (G_OBJECT (sink), "last_message"); } @@ -336,6 +342,7 @@ gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf) GstFakeSink *sink = GST_FAKE_SINK (bsink); if (!sink->silent) { + GST_LOCK (sink); g_free (sink->last_message); sink->last_message = @@ -346,6 +353,7 @@ gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf) GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_MINI_OBJECT (buf)->flags, buf); + GST_UNLOCK (sink); g_object_notify (G_OBJECT (sink), "last_message"); } @@ -397,8 +405,10 @@ gst_fake_sink_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_READY_TO_NULL: if (fakesink->state_error == FAKE_SINK_STATE_ERROR_READY_NULL) goto error; + GST_LOCK (fakesink); g_free (fakesink->last_message); fakesink->last_message = NULL; + GST_UNLOCK (fakesink); break; default: break; diff --git a/gst/elements/gstfakesrc.c b/gst/elements/gstfakesrc.c index 485625d..86caa35 100644 --- a/gst/elements/gstfakesrc.c +++ b/gst/elements/gstfakesrc.c @@ -351,11 +351,13 @@ gst_fake_src_event_handler (GstBaseSrc * basesrc, GstEvent * event) src = GST_FAKE_SRC (basesrc); if (!src->silent) { + GST_LOCK (src); g_free (src->last_message); src->last_message = g_strdup_printf ("event ******* E (type: %d) %p", GST_EVENT_TYPE (event), event); + GST_UNLOCK (src); g_object_notify (G_OBJECT (src), "last_message"); } @@ -506,7 +508,9 @@ gst_fake_src_get_property (GObject * object, guint prop_id, GValue * value, g_value_set_boolean (value, src->dump); break; case PROP_LAST_MESSAGE: + GST_LOCK (src); g_value_set_string (value, src->last_message); + GST_UNLOCK (src); break; case PROP_CAN_ACTIVATE_PUSH: g_value_set_boolean (value, GST_BASE_SRC (src)->can_activate_push); @@ -693,6 +697,7 @@ gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, GST_BUFFER_TIMESTAMP (buf) = time; if (!src->silent) { + GST_LOCK (src); g_free (src->last_message); src->last_message = @@ -703,6 +708,7 @@ gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_MINI_OBJECT (buf)->flags, buf); + GST_UNLOCK (src); g_object_notify (G_OBJECT (src), "last_message"); } @@ -741,12 +747,14 @@ gst_fake_src_stop (GstBaseSrc * basesrc) src = GST_FAKE_SRC (basesrc); + GST_LOCK (src); if (src->parent) { gst_buffer_unref (src->parent); src->parent = NULL; } g_free (src->last_message); src->last_message = NULL; + GST_UNLOCK (src); return TRUE; } diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index 5c7393d..c3dd2dc 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -497,8 +497,10 @@ gst_identity_stop (GstBaseTransform * trans) identity = GST_IDENTITY (trans); + GST_LOCK (identity); g_free (identity->last_message); identity->last_message = NULL; + GST_UNLOCK (identity); return TRUE; } diff --git a/gst/elements/gsttee.c b/gst/elements/gsttee.c index d97337b..836bb45 100644 --- a/gst/elements/gsttee.c +++ b/gst/elements/gsttee.c @@ -274,6 +274,7 @@ gst_tee_do_push (GstPad * pad, GValue * ret, PushData * data) res = gst_pad_push (pad, gst_buffer_ref (data->buffer)); g_value_set_enum (ret, res); + gst_object_unref (pad); return (res == GST_FLOW_OK); diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c index 7adab5d..f4aff51 100644 --- a/plugins/elements/gstfakesink.c +++ b/plugins/elements/gstfakesink.c @@ -274,7 +274,9 @@ gst_fake_sink_get_property (GObject * object, guint prop_id, GValue * value, g_value_set_boolean (value, sink->signal_handoffs); break; case PROP_LAST_MESSAGE: + GST_LOCK (sink); g_value_set_string (value, sink->last_message); + GST_UNLOCK (sink); break; case PROP_CAN_ACTIVATE_PUSH: g_value_set_boolean (value, GST_BASE_SINK (sink)->can_activate_push); @@ -297,6 +299,7 @@ gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event) if (!sink->silent) { gchar *sstr; + GST_LOCK (sink); g_free (sink->last_message); if ((s = gst_event_get_structure (event))) @@ -308,6 +311,7 @@ gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event) g_strdup_printf ("event ******* E (type: %d, %s) %p", GST_EVENT_TYPE (event), sstr, event); g_free (sstr); + GST_UNLOCK (sink); g_object_notify (G_OBJECT (sink), "last_message"); } @@ -321,9 +325,11 @@ gst_fake_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer) GstFakeSink *sink = GST_FAKE_SINK (bsink); if (!sink->silent) { + GST_LOCK (sink); g_free (sink->last_message); sink->last_message = g_strdup_printf ("preroll ******* "); + GST_UNLOCK (sink); g_object_notify (G_OBJECT (sink), "last_message"); } @@ -336,6 +342,7 @@ gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf) GstFakeSink *sink = GST_FAKE_SINK (bsink); if (!sink->silent) { + GST_LOCK (sink); g_free (sink->last_message); sink->last_message = @@ -346,6 +353,7 @@ gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf) GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_MINI_OBJECT (buf)->flags, buf); + GST_UNLOCK (sink); g_object_notify (G_OBJECT (sink), "last_message"); } @@ -397,8 +405,10 @@ gst_fake_sink_change_state (GstElement * element, GstStateChange transition) case GST_STATE_CHANGE_READY_TO_NULL: if (fakesink->state_error == FAKE_SINK_STATE_ERROR_READY_NULL) goto error; + GST_LOCK (fakesink); g_free (fakesink->last_message); fakesink->last_message = NULL; + GST_UNLOCK (fakesink); break; default: break; diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c index 485625d..86caa35 100644 --- a/plugins/elements/gstfakesrc.c +++ b/plugins/elements/gstfakesrc.c @@ -351,11 +351,13 @@ gst_fake_src_event_handler (GstBaseSrc * basesrc, GstEvent * event) src = GST_FAKE_SRC (basesrc); if (!src->silent) { + GST_LOCK (src); g_free (src->last_message); src->last_message = g_strdup_printf ("event ******* E (type: %d) %p", GST_EVENT_TYPE (event), event); + GST_UNLOCK (src); g_object_notify (G_OBJECT (src), "last_message"); } @@ -506,7 +508,9 @@ gst_fake_src_get_property (GObject * object, guint prop_id, GValue * value, g_value_set_boolean (value, src->dump); break; case PROP_LAST_MESSAGE: + GST_LOCK (src); g_value_set_string (value, src->last_message); + GST_UNLOCK (src); break; case PROP_CAN_ACTIVATE_PUSH: g_value_set_boolean (value, GST_BASE_SRC (src)->can_activate_push); @@ -693,6 +697,7 @@ gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, GST_BUFFER_TIMESTAMP (buf) = time; if (!src->silent) { + GST_LOCK (src); g_free (src->last_message); src->last_message = @@ -703,6 +708,7 @@ gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), GST_MINI_OBJECT (buf)->flags, buf); + GST_UNLOCK (src); g_object_notify (G_OBJECT (src), "last_message"); } @@ -741,12 +747,14 @@ gst_fake_src_stop (GstBaseSrc * basesrc) src = GST_FAKE_SRC (basesrc); + GST_LOCK (src); if (src->parent) { gst_buffer_unref (src->parent); src->parent = NULL; } g_free (src->last_message); src->last_message = NULL; + GST_UNLOCK (src); return TRUE; } diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index 5c7393d..c3dd2dc 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -497,8 +497,10 @@ gst_identity_stop (GstBaseTransform * trans) identity = GST_IDENTITY (trans); + GST_LOCK (identity); g_free (identity->last_message); identity->last_message = NULL; + GST_UNLOCK (identity); return TRUE; } diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index d97337b..836bb45 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -274,6 +274,7 @@ gst_tee_do_push (GstPad * pad, GValue * ret, PushData * data) res = gst_pad_push (pad, gst_buffer_ref (data->buffer)); g_value_set_enum (ret, res); + gst_object_unref (pad); return (res == GST_FLOW_OK); -- 2.7.4