[farsight2/master] More locking cleanup

Olivier Crête olivier.crete at collabora.co.uk
Fri Dec 12 17:12:14 PST 2008


---
 gst/fsrtpconference/fs-rtp-session.c   |    9 ++++++---
 gst/fsrtpconference/fs-rtp-stream.c    |   14 ++++++--------
 gst/fsrtpconference/fs-rtp-stream.h    |    2 +-
 gst/fsrtpconference/fs-rtp-substream.c |   11 ++++-------
 gst/fsrtpconference/fs-rtp-substream.h |    2 +-
 5 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index e55bab0..6b791c7 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -1964,7 +1964,7 @@ fs_rtp_session_distribute_recv_codecs_locked (FsRtpSession *session,
         }
       }
 
-      fs_rtp_stream_set_negotiated_codecs (stream, new_codecs);
+      fs_rtp_stream_set_negotiated_codecs_locked (stream, new_codecs);
     }
 
     if (stream != force_stream)
@@ -2312,10 +2312,12 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
           error->message);
 
     g_clear_error (&error);
-    g_object_unref (stream);
   }
 
   FS_RTP_SESSION_UNLOCK (session);
+
+  if (stream)
+    g_object_unref (stream);
 }
 
 
@@ -2765,7 +2767,8 @@ fs_rtp_session_substream_set_codec_bin_locked (FsRtpSession *session,
   if (!codecbin)
     goto out;
 
-  ret = fs_rtp_sub_stream_set_codecbin (substream, ca->codec, codecbin, error);
+  ret = fs_rtp_sub_stream_set_codecbin_locked (substream, ca->codec, codecbin,
+      error);
 
  out:
 
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index d80a4b7..3b32e4b 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -730,9 +730,11 @@ static void
 _substream_src_pad_added (FsRtpSubStream *substream, GstPad *pad,
                           FsCodec *codec, gpointer user_data)
 {
-  FsStream *stream = FS_STREAM (user_data);
+  FsRtpStream *self = FS_RTP_STREAM (user_data);
 
-  fs_stream_emit_src_pad_added (stream, pad, codec);
+  FS_RTP_SESSION_UNLOCK (self->priv->session);
+  fs_stream_emit_src_pad_added (FS_STREAM_CAST (self), pad, codec);
+  FS_RTP_SESSION_LOCK (self->priv->session);
 }
 
 static void
@@ -872,7 +874,7 @@ _substream_codec_changed (FsRtpSubStream *substream,
 }
 
 /**
- * fs_rtp_stream_set_negotiated_codecs
+ * fs_rtp_stream_set_negotiated_codecs_locked
  * @stream: a #FsRtpStream
  * @codecs: The #GList of #FsCodec to set for the negotiated-codecs property
  *
@@ -881,14 +883,12 @@ _substream_codec_changed (FsRtpSubStream *substream,
  * codecs, so you have to give it its own copy.
  */
 void
-fs_rtp_stream_set_negotiated_codecs (FsRtpStream *stream,
+fs_rtp_stream_set_negotiated_codecs_locked (FsRtpStream *stream,
     GList *codecs)
 {
-  FS_RTP_SESSION_LOCK (stream->priv->session);
   if (fs_codec_list_are_equal (stream->priv->negotiated_codecs, codecs))
   {
     fs_codec_list_destroy (codecs);
-    FS_RTP_SESSION_UNLOCK (stream->priv->session);
     return;
   }
 
@@ -897,7 +897,5 @@ fs_rtp_stream_set_negotiated_codecs (FsRtpStream *stream,
 
   stream->priv->negotiated_codecs = codecs;
 
-  FS_RTP_SESSION_UNLOCK (stream->priv->session);
-
   g_object_notify (G_OBJECT (stream), "negotiated-codecs");
 }
diff --git a/gst/fsrtpconference/fs-rtp-stream.h b/gst/fsrtpconference/fs-rtp-stream.h
index 22f8a8e..5c5779c 100644
--- a/gst/fsrtpconference/fs-rtp-stream.h
+++ b/gst/fsrtpconference/fs-rtp-stream.h
@@ -103,7 +103,7 @@ gboolean fs_rtp_stream_add_substream_locked (FsRtpStream *stream,
     GError **error);
 
 void
-fs_rtp_stream_set_negotiated_codecs (FsRtpStream *stream,
+fs_rtp_stream_set_negotiated_codecs_locked (FsRtpStream *stream,
     GList *codecs);
 
 G_END_DECLS
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index 9c178c6..4159a06 100644
--- a/gst/fsrtpconference/fs-rtp-substream.c
+++ b/gst/fsrtpconference/fs-rtp-substream.c
@@ -767,7 +767,7 @@ fs_rtp_sub_stream_get_property (GObject *object,
 }
 
 /**
- * fs_rtp_sub_stream_set_codecbin:
+ * fs_rtp_sub_stream_set_codecbin_locked:
  * @substream: a #FsRtpSubStream
  * @codec: The codec to set
  * @codecbin: the codecbin to set
@@ -781,7 +781,7 @@ fs_rtp_sub_stream_get_property (GObject *object,
  */
 
 gboolean
-fs_rtp_sub_stream_set_codecbin (FsRtpSubStream *substream,
+fs_rtp_sub_stream_set_codecbin_locked (FsRtpSubStream *substream,
     FsCodec *codec,
     GstElement *codecbin,
     GError **error)
@@ -792,8 +792,6 @@ fs_rtp_sub_stream_set_codecbin (FsRtpSubStream *substream,
   GstPad *pad;
   gboolean codec_changed = TRUE;
 
-  FS_RTP_SESSION_LOCK (substream->priv->session);
-
   if (substream->priv->codec)
   {
     if (!fs_codec_are_equal (codec, substream->priv->codec))
@@ -902,11 +900,12 @@ fs_rtp_sub_stream_set_codecbin (FsRtpSubStream *substream,
   }
   else
   {
+    FS_RTP_SESSION_UNLOCK (substream->priv->session);
     if (codec_changed)
       g_signal_emit (substream, signals[CODEC_CHANGED], 0);
+    FS_RTP_SESSION_LOCK (substream->priv->session);
   }
 
-  FS_RTP_SESSION_UNLOCK (substream->priv->session);
   return TRUE;
 
  error:
@@ -918,8 +917,6 @@ fs_rtp_sub_stream_set_codecbin (FsRtpSubStream *substream,
 
  error_no_remove:
 
-  FS_RTP_SESSION_UNLOCK (substream->priv->session);
-
   return ret;
 }
 
diff --git a/gst/fsrtpconference/fs-rtp-substream.h b/gst/fsrtpconference/fs-rtp-substream.h
index 13a84b6..99a01f2 100644
--- a/gst/fsrtpconference/fs-rtp-substream.h
+++ b/gst/fsrtpconference/fs-rtp-substream.h
@@ -80,7 +80,7 @@ FsRtpSubStream *fs_rtp_sub_stream_new (FsRtpConference *conference,
     GError **error);
 
 
-gboolean fs_rtp_sub_stream_set_codecbin (FsRtpSubStream *substream,
+gboolean fs_rtp_sub_stream_set_codecbin_locked (FsRtpSubStream *substream,
     FsCodec *codec,
     GstElement *codecbin,
     GError **error);
-- 
1.5.6.5




More information about the farsight-commits mailing list