summaryrefslogtreecommitdiff
path: root/gst/audiomixer
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2017-05-20 17:47:04 +0200
committerOlivier CrĂȘte <olivier.crete@collabora.com>2017-05-20 17:52:00 +0200
commit57ede2603137add8bce9720df308f57fe6965146 (patch)
treee2f6d3e2e23c4ec13c60eb4285bc7cefe3299ef4 /gst/audiomixer
parent583e6552342cf8e06861b6ae53a20f857debe053 (diff)
audiointerleave: Take object lock while modifying channel count
Diffstat (limited to 'gst/audiomixer')
-rw-r--r--gst/audiomixer/gstaudiointerleave.c13
-rw-r--r--gst/audiomixer/gstaudiointerleave.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/gst/audiomixer/gstaudiointerleave.c b/gst/audiomixer/gstaudiointerleave.c
index dfae4a51a..cc10e2145 100644
--- a/gst/audiomixer/gstaudiointerleave.c
+++ b/gst/audiomixer/gstaudiointerleave.c
@@ -513,8 +513,11 @@ gst_audio_interleave_update_src_caps (GstAggregator * agg, GstCaps * caps,
/* This means that either no caps have been set on the sink pad (if
* sinkcaps is NULL) or that there is no sink pad (if channels == 0).
*/
- if (self->sinkcaps == NULL || self->channels == 0)
+ GST_OBJECT_LOCK (self);
+ if (self->sinkcaps == NULL || self->channels == 0) {
+ GST_OBJECT_UNLOCK (self);
return GST_FLOW_NOT_NEGOTIATED;
+ }
*ret = gst_caps_copy (self->sinkcaps);
s = gst_caps_get_structure (*ret, 0);
@@ -523,6 +526,8 @@ gst_audio_interleave_update_src_caps (GstAggregator * agg, GstCaps * caps,
G_TYPE_STRING, "interleaved", "channel-mask", GST_TYPE_BITMASK,
gst_audio_interleave_get_channel_mask (self), NULL);
+ GST_OBJECT_UNLOCK (self);
+
return GST_FLOW_OK;
}
@@ -726,10 +731,12 @@ gst_audio_interleave_request_new_pad (GstElement * element,
/* FIXME: We ignore req_name, this is evil! */
+ GST_OBJECT_LOCK (self);
padnumber = g_atomic_int_add (&self->padcounter, 1);
- channel = g_atomic_int_add (&self->channels, 1);
+ channel = self->channels++;
if (!self->channel_positions_from_input)
channel = padnumber;
+ GST_OBJECT_UNLOCK (self);
pad_name = g_strdup_printf ("sink_%u", padnumber);
newpad = (GstAudioInterleavePad *)
@@ -776,7 +783,7 @@ gst_audio_interleave_release_pad (GstElement * element, GstPad * pad)
/* Take lock to make sure we're not changing this when processing buffers */
GST_OBJECT_LOCK (self);
- g_atomic_int_add (&self->channels, -1);
+ self->channels--;
position = GST_AUDIO_INTERLEAVE_PAD (pad)->channel;
g_value_array_remove (self->input_channel_positions, position);
diff --git a/gst/audiomixer/gstaudiointerleave.h b/gst/audiomixer/gstaudiointerleave.h
index ef959ceef..bf46f4a50 100644
--- a/gst/audiomixer/gstaudiointerleave.h
+++ b/gst/audiomixer/gstaudiointerleave.h
@@ -56,7 +56,7 @@ struct _GstAudioInterleave {
GstAudioAggregator parent;
gint padcounter;
- guint channels;
+ guint channels; /* object lock */
GstCaps *sinkcaps;