frei0r: Protect set/get property and processing functions from concurrent access

The frei0r documentation says that these functions must not be called
on the same instance from different threads at the same time. All
other functions are guaranteed to be threadsafe.
This commit is contained in:
Sebastian Dröge 2010-02-27 19:08:49 +01:00
parent 678f7ddb16
commit 125efbffcc
3 changed files with 19 additions and 1 deletions

View file

@ -1,5 +1,5 @@
/* GStreamer
* Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* Copyright (C) 2009,2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@ -85,6 +85,7 @@ gst_frei0r_filter_transform (GstBaseTransform * trans, GstBuffer * inbuf,
time = ((gdouble) GST_BUFFER_TIMESTAMP (inbuf)) / GST_SECOND;
GST_OBJECT_LOCK (self);
if (klass->ftable->update2)
klass->ftable->update2 (self->f0r_instance, time,
(const guint32 *) GST_BUFFER_DATA (inbuf), NULL, NULL,
@ -93,6 +94,7 @@ gst_frei0r_filter_transform (GstBaseTransform * trans, GstBuffer * inbuf,
klass->ftable->update (self->f0r_instance, time,
(const guint32 *) GST_BUFFER_DATA (inbuf),
(guint32 *) GST_BUFFER_DATA (outbuf));
GST_OBJECT_UNLOCK (self);
return GST_FLOW_OK;
}
@ -123,10 +125,12 @@ gst_frei0r_filter_get_property (GObject * object, guint prop_id, GValue * value,
GstFrei0rFilter *self = GST_FREI0R_FILTER (object);
GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (object);
GST_OBJECT_LOCK (self);
if (!gst_frei0r_get_property (self->f0r_instance, klass->ftable,
klass->properties, klass->n_properties, self->property_cache, prop_id,
value))
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
GST_OBJECT_UNLOCK (self);
}
static void
@ -136,10 +140,12 @@ gst_frei0r_filter_set_property (GObject * object, guint prop_id,
GstFrei0rFilter *self = GST_FREI0R_FILTER (object);
GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (object);
GST_OBJECT_LOCK (self);
if (!gst_frei0r_set_property (self->f0r_instance, klass->ftable,
klass->properties, klass->n_properties, self->property_cache, prop_id,
value))
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
GST_OBJECT_UNLOCK (self);
}
static void

View file

@ -84,10 +84,12 @@ gst_frei0r_mixer_get_property (GObject * object, guint prop_id, GValue * value,
GstFrei0rMixer *self = GST_FREI0R_MIXER (object);
GstFrei0rMixerClass *klass = GST_FREI0R_MIXER_GET_CLASS (object);
GST_OBJECT_LOCK (self);
if (!gst_frei0r_get_property (self->f0r_instance, klass->ftable,
klass->properties, klass->n_properties, self->property_cache, prop_id,
value))
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
GST_OBJECT_UNLOCK (self);
}
static void
@ -97,10 +99,12 @@ gst_frei0r_mixer_set_property (GObject * object, guint prop_id,
GstFrei0rMixer *self = GST_FREI0R_MIXER (object);
GstFrei0rMixerClass *klass = GST_FREI0R_MIXER_GET_CLASS (object);
GST_OBJECT_LOCK (self);
if (!gst_frei0r_set_property (self->f0r_instance, klass->ftable,
klass->properties, klass->n_properties, self->property_cache, prop_id,
value))
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
GST_OBJECT_UNLOCK (self);
}
static GstStateChangeReturn
@ -584,11 +588,13 @@ gst_frei0r_mixer_collected (GstCollectPads * pads, GstFrei0rMixer * self)
GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS);
time = ((gdouble) GST_BUFFER_TIMESTAMP (outbuf)) / GST_SECOND;
GST_OBJECT_LOCK (self);
klass->ftable->update2 (self->f0r_instance, time,
(const guint32 *) GST_BUFFER_DATA (inbuf0),
(const guint32 *) GST_BUFFER_DATA (inbuf1),
(inbuf2) ? (const guint32 *) GST_BUFFER_DATA (inbuf2) : NULL,
(guint32 *) GST_BUFFER_DATA (outbuf));
GST_OBJECT_UNLOCK (self);
gst_buffer_unref (inbuf0);
gst_buffer_unref (inbuf1);

View file

@ -113,12 +113,14 @@ gst_frei0r_src_create (GstPushSrc * src, GstBuffer ** buf)
time = ((gdouble) GST_BUFFER_TIMESTAMP (outbuf)) / GST_SECOND;
GST_OBJECT_LOCK (self);
if (klass->ftable->update2)
klass->ftable->update2 (self->f0r_instance, time, NULL, NULL, NULL,
(guint32 *) GST_BUFFER_DATA (outbuf));
else
klass->ftable->update (self->f0r_instance, time, NULL,
(guint32 *) GST_BUFFER_DATA (outbuf));
GST_OBJECT_UNLOCK (self);
*buf = outbuf;
@ -291,10 +293,12 @@ gst_frei0r_src_get_property (GObject * object, guint prop_id, GValue * value,
GstFrei0rSrc *self = GST_FREI0R_SRC (object);
GstFrei0rSrcClass *klass = GST_FREI0R_SRC_GET_CLASS (object);
GST_OBJECT_LOCK (self);
if (!gst_frei0r_get_property (self->f0r_instance, klass->ftable,
klass->properties, klass->n_properties, self->property_cache, prop_id,
value))
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
GST_OBJECT_UNLOCK (self);
}
static void
@ -304,10 +308,12 @@ gst_frei0r_src_set_property (GObject * object, guint prop_id,
GstFrei0rSrc *self = GST_FREI0R_SRC (object);
GstFrei0rSrcClass *klass = GST_FREI0R_SRC_GET_CLASS (object);
GST_OBJECT_LOCK (self);
if (!gst_frei0r_set_property (self->f0r_instance, klass->ftable,
klass->properties, klass->n_properties, self->property_cache, prop_id,
value))
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
GST_OBJECT_UNLOCK (self);
}
static void