[farsight2/master] Make clear in FsRtpStream what is called with a lock held and what isnt

Olivier Crête olivier.crete at collabora.co.uk
Fri Dec 12 16:55:32 PST 2008


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

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index a34addb..e55bab0 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -2304,12 +2304,9 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
 
   g_clear_error (&error);
 
-
-  FS_RTP_SESSION_UNLOCK (session);
-
   if (stream)
   {
-    if (!fs_rtp_stream_add_substream (stream, substream, &error))
+    if (!fs_rtp_stream_add_substream_locked (stream, substream, &error))
       fs_session_emit_error (FS_SESSION (session), error->code,
           "Could not add the output ghostpad to the new substream",
           error->message);
@@ -2317,6 +2314,8 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
     g_clear_error (&error);
     g_object_unref (stream);
   }
+
+  FS_RTP_SESSION_UNLOCK (session);
 }
 
 
@@ -3465,14 +3464,14 @@ fs_rtp_session_associate_free_substreams (FsRtpSession *session,
 {
   gboolean added = FALSE;
 
+  FS_RTP_SESSION_LOCK (session);
+
   for (;;)
   {
     FsRtpSubStream *substream = NULL;
     GList *item = NULL;
     GError *error = NULL;
 
-    FS_RTP_SESSION_LOCK (session);
-
     for (item = g_list_first (session->priv->free_substreams);
          item;
          item = g_list_next (item))
@@ -3490,7 +3489,6 @@ fs_rtp_session_associate_free_substreams (FsRtpSession *session,
         break;
       }
     }
-    FS_RTP_SESSION_UNLOCK (session);
 
     if (!substream)
       break;
@@ -3503,7 +3501,7 @@ fs_rtp_session_associate_free_substreams (FsRtpSession *session,
         g_signal_handlers_disconnect_by_func (substream, "no-rtcp-timedout",
             session) > 0);
 
-    if (fs_rtp_stream_add_substream (stream, substream, &error))
+    if (fs_rtp_stream_add_substream_locked (stream, substream, &error))
     {
       fs_rtp_sub_stream_verify_codec_locked (substream);
       GST_DEBUG ("Associated SSRC %x in session %u", ssrc, session->id);
@@ -3518,6 +3516,7 @@ fs_rtp_session_associate_free_substreams (FsRtpSession *session,
     }
     g_clear_error (&error);
   }
+  FS_RTP_SESSION_UNLOCK (session);
 
   if (added == FALSE)
     GST_DEBUG ("No free substream with SSRC %x in session %u",
@@ -3614,7 +3613,7 @@ _substream_no_rtcp_timedout_cb (FsRtpSubStream *substream,
   while (
       g_signal_handlers_disconnect_by_func (substream, "no-rtcp-timedout", session) > 0);
 
-  if (fs_rtp_stream_add_substream (
+  if (fs_rtp_stream_add_substream_locked (
           g_list_first (session->priv->streams)->data,
           substream, &error))
     fs_rtp_sub_stream_verify_codec_locked (substream);
diff --git a/gst/fsrtpconference/fs-rtp-stream.c b/gst/fsrtpconference/fs-rtp-stream.c
index dd79ce1..d80a4b7 100644
--- a/gst/fsrtpconference/fs-rtp-stream.c
+++ b/gst/fsrtpconference/fs-rtp-stream.c
@@ -748,7 +748,7 @@ _substream_error (FsRtpSubStream *substream,
 }
 
 /**
- * fs_rtp_stream_add_substream:
+ * fs_rtp_stream_add_substream_locked:
  * @stream: a #FsRtpStream
  * @substream: the #FsRtpSubStream to associate with this stream
  *
@@ -757,14 +757,13 @@ _substream_error (FsRtpSubStream *substream,
  * Returns: TRUE on success, FALSE on failure
  */
 gboolean
-fs_rtp_stream_add_substream (FsRtpStream *stream,
+fs_rtp_stream_add_substream_locked (FsRtpStream *stream,
     FsRtpSubStream *substream,
     GError **error)
 {
   FsCodec *codec = NULL;
   gboolean ret = TRUE;
 
-  FS_RTP_SESSION_LOCK (stream->priv->session);
   stream->substreams = g_list_prepend (stream->substreams,
       substream);
   g_object_set (substream,
@@ -787,8 +786,6 @@ fs_rtp_stream_add_substream (FsRtpStream *stream,
     fs_codec_destroy (codec);
   }
 
-  FS_RTP_SESSION_UNLOCK (stream->priv->session);
-
   return ret;
 }
 
diff --git a/gst/fsrtpconference/fs-rtp-stream.h b/gst/fsrtpconference/fs-rtp-stream.h
index 6688362..22f8a8e 100644
--- a/gst/fsrtpconference/fs-rtp-stream.h
+++ b/gst/fsrtpconference/fs-rtp-stream.h
@@ -98,7 +98,7 @@ FsRtpStream *fs_rtp_stream_new (FsRtpSession *session,
     gpointer user_data_for_cb,
     GError **error);
 
-gboolean fs_rtp_stream_add_substream (FsRtpStream *stream,
+gboolean fs_rtp_stream_add_substream_locked (FsRtpStream *stream,
     FsRtpSubStream *substream,
     GError **error);
 
-- 
1.5.6.5




More information about the farsight-commits mailing list