mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
update for basetransform lock removal
This commit is contained in:
parent
c762e945be
commit
7749cd3f7b
5 changed files with 55 additions and 39 deletions
|
@ -255,6 +255,8 @@ gst_spectrum_init (GstSpectrum * spectrum)
|
|||
spectrum->interval = DEFAULT_INTERVAL;
|
||||
spectrum->bands = DEFAULT_BANDS;
|
||||
spectrum->threshold = DEFAULT_THRESHOLD;
|
||||
|
||||
g_mutex_init (&spectrum->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -334,6 +336,7 @@ gst_spectrum_finalize (GObject * object)
|
|||
GstSpectrum *spectrum = GST_SPECTRUM (object);
|
||||
|
||||
gst_spectrum_reset_state (spectrum);
|
||||
g_mutex_clear (&spectrum->lock);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -356,37 +359,37 @@ gst_spectrum_set_property (GObject * object, guint prop_id,
|
|||
break;
|
||||
case PROP_INTERVAL:{
|
||||
guint64 interval = g_value_get_uint64 (value);
|
||||
g_mutex_lock (&filter->lock);
|
||||
if (filter->interval != interval) {
|
||||
GST_BASE_TRANSFORM_LOCK (filter);
|
||||
filter->interval = interval;
|
||||
gst_spectrum_reset_state (filter);
|
||||
GST_BASE_TRANSFORM_UNLOCK (filter);
|
||||
}
|
||||
}
|
||||
g_mutex_unlock (&filter->lock);
|
||||
break;
|
||||
}
|
||||
case PROP_BANDS:{
|
||||
guint bands = g_value_get_uint (value);
|
||||
g_mutex_lock (&filter->lock);
|
||||
if (filter->bands != bands) {
|
||||
GST_BASE_TRANSFORM_LOCK (filter);
|
||||
filter->bands = bands;
|
||||
gst_spectrum_reset_state (filter);
|
||||
GST_BASE_TRANSFORM_UNLOCK (filter);
|
||||
}
|
||||
}
|
||||
g_mutex_unlock (&filter->lock);
|
||||
break;
|
||||
}
|
||||
case PROP_THRESHOLD:
|
||||
filter->threshold = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_MULTI_CHANNEL:{
|
||||
gboolean multi_channel = g_value_get_boolean (value);
|
||||
g_mutex_lock (&filter->lock);
|
||||
if (filter->multi_channel != multi_channel) {
|
||||
GST_BASE_TRANSFORM_LOCK (filter);
|
||||
filter->multi_channel = multi_channel;
|
||||
gst_spectrum_reset_state (filter);
|
||||
GST_BASE_TRANSFORM_UNLOCK (filter);
|
||||
}
|
||||
}
|
||||
g_mutex_unlock (&filter->lock);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
@ -622,6 +625,7 @@ gst_spectrum_setup (GstAudioFilter * base, const GstAudioInfo * info)
|
|||
gboolean multi_channel = spectrum->multi_channel;
|
||||
GstSpectrumInputData input_data = NULL;
|
||||
|
||||
g_mutex_lock (&spectrum->lock);
|
||||
switch (GST_AUDIO_INFO_FORMAT (info)) {
|
||||
case GST_AUDIO_FORMAT_S16:
|
||||
input_data =
|
||||
|
@ -648,6 +652,7 @@ gst_spectrum_setup (GstAudioFilter * base, const GstAudioInfo * info)
|
|||
spectrum->input_data = input_data;
|
||||
|
||||
gst_spectrum_reset_state (spectrum);
|
||||
g_mutex_unlock (&spectrum->lock);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -865,6 +870,7 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
|||
GstSpectrumChannel *cd;
|
||||
GstSpectrumInputData input_data;
|
||||
|
||||
g_mutex_lock (&spectrum->lock);
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
data = map.data;
|
||||
size = map.size;
|
||||
|
@ -997,6 +1003,7 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
|
|||
spectrum->input_pos = input_pos;
|
||||
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
g_mutex_unlock (&spectrum->lock);
|
||||
|
||||
g_assert (size == 0);
|
||||
|
||||
|
|
|
@ -78,6 +78,8 @@ struct _GstSpectrum
|
|||
guint64 error_per_interval;
|
||||
guint64 accumulated_error;
|
||||
|
||||
GMutex lock;
|
||||
|
||||
GstSpectrumInputData input_data;
|
||||
};
|
||||
|
||||
|
|
|
@ -97,6 +97,8 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
|||
#define gst_video_crop_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstVideoCrop, gst_video_crop, GST_TYPE_BASE_TRANSFORM);
|
||||
|
||||
static void gst_video_crop_finalize (GObject * object);
|
||||
|
||||
static void gst_video_crop_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_video_crop_get_property (GObject * object, guint prop_id,
|
||||
|
@ -155,6 +157,7 @@ gst_video_crop_src_event (GstBaseTransform * trans, GstEvent * event)
|
|||
}
|
||||
|
||||
GST_OBJECT_UNLOCK (vcrop);
|
||||
|
||||
return GST_BASE_TRANSFORM_CLASS (parent_class)->src_event (trans,
|
||||
(new_event ? new_event : event));
|
||||
}
|
||||
|
@ -170,25 +173,7 @@ gst_video_crop_class_init (GstVideoCropClass * klass)
|
|||
element_class = (GstElementClass *) klass;
|
||||
basetransform_class = (GstBaseTransformClass *) klass;
|
||||
|
||||
gst_element_class_set_details_simple (element_class, "Crop",
|
||||
"Filter/Effect/Video",
|
||||
"Crops video into a user-defined region",
|
||||
"Tim-Philipp Müller <tim centricular net>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_template));
|
||||
gst_element_class_set_details_simple (element_class, "Crop",
|
||||
"Filter/Effect/Video",
|
||||
"Crops video into a user-defined region",
|
||||
"Tim-Philipp Müller <tim centricular net>");
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_template));
|
||||
|
||||
gobject_class->finalize = gst_video_crop_finalize;
|
||||
gobject_class->set_property = gst_video_crop_set_property;
|
||||
gobject_class->get_property = gst_video_crop_get_property;
|
||||
|
||||
|
@ -205,6 +190,15 @@ gst_video_crop_class_init (GstVideoCropClass * klass)
|
|||
g_param_spec_int ("bottom", "Bottom", "Pixels to crop at bottom",
|
||||
0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_template));
|
||||
gst_element_class_set_details_simple (element_class, "Crop",
|
||||
"Filter/Effect/Video",
|
||||
"Crops video into a user-defined region",
|
||||
"Tim-Philipp Müller <tim centricular net>");
|
||||
|
||||
basetransform_class->transform = GST_DEBUG_FUNCPTR (gst_video_crop_transform);
|
||||
basetransform_class->transform_caps =
|
||||
GST_DEBUG_FUNCPTR (gst_video_crop_transform_caps);
|
||||
|
@ -223,6 +217,20 @@ gst_video_crop_init (GstVideoCrop * vcrop)
|
|||
vcrop->crop_left = 0;
|
||||
vcrop->crop_top = 0;
|
||||
vcrop->crop_bottom = 0;
|
||||
|
||||
g_mutex_init (&vcrop->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_video_crop_finalize (GObject * object)
|
||||
{
|
||||
GstVideoCrop *vcrop;
|
||||
|
||||
vcrop = GST_VIDEO_CROP (object);
|
||||
|
||||
g_mutex_clear (&vcrop->lock);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -465,6 +473,7 @@ gst_video_crop_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
{
|
||||
GstVideoCrop *vcrop = GST_VIDEO_CROP (trans);
|
||||
|
||||
g_mutex_lock (&vcrop->lock);
|
||||
switch (vcrop->in.packing) {
|
||||
case VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE:
|
||||
gst_video_crop_transform_packed_simple (vcrop, inbuf, outbuf);
|
||||
|
@ -478,6 +487,7 @@ gst_video_crop_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
|||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
g_mutex_unlock (&vcrop->lock);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
@ -635,8 +645,8 @@ gst_video_crop_set_caps (GstBaseTransform * trans, GstCaps * incaps,
|
|||
GST_LOG_OBJECT (crop, "incaps = %" GST_PTR_FORMAT ", outcaps = %"
|
||||
GST_PTR_FORMAT, incaps, outcaps);
|
||||
|
||||
if ((crop->crop_left | crop->crop_right | crop->crop_top | crop->
|
||||
crop_bottom) == 0) {
|
||||
if ((crop->crop_left | crop->crop_right | crop->
|
||||
crop_top | crop->crop_bottom) == 0) {
|
||||
GST_LOG_OBJECT (crop, "we are using passthrough");
|
||||
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (crop), TRUE);
|
||||
} else {
|
||||
|
@ -675,7 +685,7 @@ gst_video_crop_set_property (GObject * object, guint prop_id,
|
|||
video_crop = GST_VIDEO_CROP (object);
|
||||
|
||||
/* don't modify while we are transforming */
|
||||
GST_BASE_TRANSFORM_LOCK (GST_BASE_TRANSFORM_CAST (video_crop));
|
||||
g_mutex_lock (&video_crop->lock);
|
||||
|
||||
/* protect with the object lock so that we can read them */
|
||||
GST_OBJECT_LOCK (video_crop);
|
||||
|
@ -696,14 +706,13 @@ gst_video_crop_set_property (GObject * object, guint prop_id,
|
|||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
GST_OBJECT_UNLOCK (video_crop);
|
||||
|
||||
GST_LOG_OBJECT (video_crop, "l=%d,r=%d,b=%d,t=%d",
|
||||
video_crop->crop_left, video_crop->crop_right, video_crop->crop_bottom,
|
||||
video_crop->crop_top);
|
||||
GST_OBJECT_UNLOCK (video_crop);
|
||||
|
||||
gst_base_transform_reconfigure (GST_BASE_TRANSFORM (video_crop));
|
||||
GST_BASE_TRANSFORM_UNLOCK (GST_BASE_TRANSFORM_CAST (video_crop));
|
||||
g_mutex_unlock (&video_crop->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -68,6 +68,8 @@ struct _GstVideoCrop
|
|||
|
||||
GstVideoCropImageDetails in; /* details of input image */
|
||||
GstVideoCropImageDetails out; /* details of output image */
|
||||
|
||||
GMutex lock;
|
||||
};
|
||||
|
||||
struct _GstVideoCropClass
|
||||
|
|
|
@ -432,7 +432,7 @@ gst_video_balance_transform_frame_ip (GstVideoFilter * vfilter,
|
|||
goto not_negotiated;
|
||||
|
||||
/* if no change is needed, we are done */
|
||||
if (GST_BASE_TRANSFORM (vfilter)->passthrough)
|
||||
if (gst_base_transform_is_passthrough (GST_BASE_TRANSFORM (vfilter)))
|
||||
goto done;
|
||||
|
||||
GST_OBJECT_LOCK (videobalance);
|
||||
|
@ -584,7 +584,6 @@ gst_video_balance_colorbalance_set_value (GstColorBalance * balance,
|
|||
g_return_if_fail (GST_IS_VIDEO_FILTER (vb));
|
||||
g_return_if_fail (channel->label != NULL);
|
||||
|
||||
GST_BASE_TRANSFORM_LOCK (vb);
|
||||
GST_OBJECT_LOCK (vb);
|
||||
if (!g_ascii_strcasecmp (channel->label, "HUE")) {
|
||||
new_val = (value + 1000.0) * 2.0 / 2000.0 - 1.0;
|
||||
|
@ -607,7 +606,6 @@ gst_video_balance_colorbalance_set_value (GstColorBalance * balance,
|
|||
if (changed)
|
||||
gst_video_balance_update_properties (vb);
|
||||
GST_OBJECT_UNLOCK (vb);
|
||||
GST_BASE_TRANSFORM_UNLOCK (vb);
|
||||
|
||||
if (changed) {
|
||||
gst_color_balance_value_changed (balance, channel,
|
||||
|
@ -670,7 +668,6 @@ gst_video_balance_set_property (GObject * object, guint prop_id,
|
|||
gdouble d;
|
||||
const gchar *label = NULL;
|
||||
|
||||
GST_BASE_TRANSFORM_LOCK (balance);
|
||||
GST_OBJECT_LOCK (balance);
|
||||
switch (prop_id) {
|
||||
case PROP_CONTRAST:
|
||||
|
@ -712,7 +709,6 @@ gst_video_balance_set_property (GObject * object, guint prop_id,
|
|||
|
||||
gst_video_balance_update_properties (balance);
|
||||
GST_OBJECT_UNLOCK (balance);
|
||||
GST_BASE_TRANSFORM_UNLOCK (balance);
|
||||
|
||||
if (label) {
|
||||
GstColorBalanceChannel *channel =
|
||||
|
|
Loading…
Reference in a new issue