[farsight2/master] Protect the list of substreams in a stream with the session lock

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:20:05 PST 2008


---
 gst/fsrtpconference/fs-rtp-session.c |    2 +-
 gst/fsrtpconference/fs-rtp-stream.c  |    7 ++++++-
 gst/fsrtpconference/fs-rtp-stream.h  |    2 +-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index a0961d7..e96f14e 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -1337,7 +1337,7 @@ fs_rtp_session_get_stream_by_ssrc_locked (FsRtpSession *self,
   for (item = g_list_first (self->priv->streams);
        item;
        item = g_list_next (item))
-    if (fs_rtp_stream_knows_ssrc (item->data, ssrc))
+    if (fs_rtp_stream_knows_ssrc_locked (item->data, ssrc))
       break;
 
 
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index 5e5c9c5..391c2e1 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -71,6 +71,7 @@ struct _FsRtpStreamPrivate
 
   GList *remote_codecs;
 
+  /* Protected by the session mutex */
   GList *substreams;
 
   GError *construction_error;
@@ -233,11 +234,13 @@ fs_rtp_stream_dispose (GObject *object)
     return;
   }
 
+  FS_RTP_SESSION_LOCK (self->priv->session);
   if (self->priv->substreams) {
     g_list_foreach (self->priv->substreams, (GFunc) gst_object_unref, NULL);
     g_list_free (self->priv->substreams);
     self->priv->substreams = NULL;
   }
+  FS_RTP_SESSION_UNLOCK (self->priv->session);
 
   if (self->priv->participant) {
     g_object_unref (self->priv->participant);
@@ -562,8 +565,10 @@ fs_rtp_stream_add_substream (FsRtpStream *stream,
 
   g_object_get (substream, "codec", &codec, NULL);
 
+  FS_RTP_SESSION_LOCK (stream->priv->session);
   stream->priv->substreams = g_list_prepend (stream->priv->substreams,
       substream);
+  FS_RTP_SESSION_UNLOCK (stream->priv->session);
 
   g_signal_emit_by_name (stream, "src-pad-added", ghostpad, codec);
 
@@ -574,7 +579,7 @@ fs_rtp_stream_add_substream (FsRtpStream *stream,
 }
 
 gboolean
-fs_rtp_stream_knows_ssrc (FsRtpStream *stream, guint32 ssrc)
+fs_rtp_stream_knows_ssrc_locked (FsRtpStream *stream, guint32 ssrc)
 {
   GList *elem;
 
diff --git a/gst/fsrtpconference/fs-rtp-stream.h b/gst/fsrtpconference/fs-rtp-stream.h
index 164071d..7534563 100644
--- a/gst/fsrtpconference/fs-rtp-stream.h
+++ b/gst/fsrtpconference/fs-rtp-stream.h
@@ -81,7 +81,7 @@ gboolean fs_rtp_stream_add_substream (FsRtpStream *stream,
     FsRtpSubStream *substream,
     GError **error);
 
-gboolean fs_rtp_stream_knows_ssrc (FsRtpStream *stream,
+gboolean fs_rtp_stream_knows_ssrc_locked (FsRtpStream *stream,
     guint32 ssrc);
 
 
-- 
1.5.6.5




More information about the farsight-commits mailing list