[farsight2/master] Protect sink addition/removal with a mutex
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:26:51 PST 2008
---
transmitters/nice/fs-nice-transmitter.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/transmitters/nice/fs-nice-transmitter.c b/transmitters/nice/fs-nice-transmitter.c
index b2c4780..f8cff4d 100644
--- a/transmitters/nice/fs-nice-transmitter.c
+++ b/transmitters/nice/fs-nice-transmitter.c
@@ -615,6 +615,9 @@ struct _NiceGstStream {
gulong *probe_ids;
+ /* Protects the sending field and the addition/state of the elements */
+ GStaticMutex mutex;
+
gboolean sending;
};
@@ -630,6 +633,8 @@ fs_nice_transmitter_add_gst_stream (FsNiceTransmitter *self,
NiceGstStream *ns = NULL;
ns = g_slice_new0 (NiceGstStream);
+ ns->sending = TRUE;
+ g_static_mutex_init (&ns->mutex);
ns->nicesrcs = g_new0 (GstElement *, self->components + 1);
ns->nicesinks = g_new0 (GstElement *, self->components + 1);
ns->requested_tee_pads = g_new0 (GstPad *, self->components + 1);
@@ -670,8 +675,6 @@ fs_nice_transmitter_add_gst_stream (FsNiceTransmitter *self,
goto error;
}
- ns->sending = TRUE;
-
return ns;
error:
@@ -736,8 +739,13 @@ fs_nice_transmitter_set_sending (FsNiceTransmitter *self,
{
guint c;
+ g_static_mutex_lock (&ns->mutex);
+
if (ns->sending == sending)
+ {
+ g_static_mutex_lock (&ns->mutex);
return;
+ }
if (ns->sending)
{
@@ -778,4 +786,7 @@ fs_nice_transmitter_set_sending (FsNiceTransmitter *self,
}
ns->sending = sending;
+
+ g_static_mutex_unlock (&ns->mutex);
+
}
--
1.5.6.5
More information about the farsight-commits
mailing list