[farsight2/master] rtp: Move locking into callback

Olivier Crête olivier.crete at collabora.co.uk
Mon Dec 21 13:45:57 PST 2009


---
 gst/fsrtpconference/fs-rtp-session.c   |   18 ++++++++++++------
 gst/fsrtpconference/fs-rtp-substream.c |    8 +++-----
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gst/fsrtpconference/fs-rtp-session.c b/gst/fsrtpconference/fs-rtp-session.c
index c4a9813..9bd6436 100644
--- a/gst/fsrtpconference/fs-rtp-session.c
+++ b/gst/fsrtpconference/fs-rtp-session.c
@@ -250,7 +250,7 @@ static GType fs_rtp_session_get_stream_transmitter_type (FsSession *session,
 
 static void _substream_no_rtcp_timedout_cb (FsRtpSubStream *substream,
     FsRtpSession *session);
-static GstElement *_substream_get_codec_bin_locked (FsRtpSubStream *substream,
+static GstElement *_substream_get_codec_bin (FsRtpSubStream *substream,
     FsRtpStream *stream, FsCodec *current_codec, FsCodec **new_codec,
     GError **error, FsRtpSession *session);
 
@@ -2531,8 +2531,8 @@ fs_rtp_session_new_recv_pad (FsRtpSession *session, GstPad *new_pad,
     return;
   }
 
-  g_signal_connect_object (substream, "get-codec-bin-locked",
-      G_CALLBACK (_substream_get_codec_bin_locked), session, 0);
+  g_signal_connect_object (substream, "get-codec-bin",
+      G_CALLBACK (_substream_get_codec_bin), session, 0);
 
   g_signal_connect_object (substream, "unlinked",
       G_CALLBACK (_substream_unlinked), session, 0);
@@ -3479,12 +3479,14 @@ fs_rtp_session_verify_send_codec_bin (FsRtpSession *self)
 
 /*
  * This callback is called when the pad of a substream has been locked because
- * the codec needs to be changed. It will see if there is a new codec to be set,
- * if there is, it will change the codec bin.
+ * the codec needs to be changed.
+ *
+ * It will return a new codecbin if it needs changing. If there is an error,
+ * the GError * will be set.
  */
 
 static GstElement *
-_substream_get_codec_bin_locked (FsRtpSubStream *substream,
+_substream_get_codec_bin (FsRtpSubStream *substream,
     FsRtpStream *stream, FsCodec *current_codec, FsCodec **new_codec,
     GError **error, FsRtpSession *session)
 {
@@ -3495,6 +3497,8 @@ _substream_get_codec_bin_locked (FsRtpSubStream *substream,
   if (fs_rtp_session_has_disposed_enter (session, NULL))
     return NULL;
 
+  FS_RTP_SESSION_LOCK (session);
+
   ca = fs_rtp_session_get_recv_codec_locked (session, substream->pt, stream,
       new_codec, error);
 
@@ -3516,6 +3520,8 @@ _substream_get_codec_bin_locked (FsRtpSubStream *substream,
 
   fs_rtp_session_has_disposed_exit (session);
 
+  FS_RTP_SESSION_UNLOCK (session);
+
   return codecbin;
 }
 
diff --git a/gst/fsrtpconference/fs-rtp-substream.c b/gst/fsrtpconference/fs-rtp-substream.c
index 188ee7b..e7b9753 100644
--- a/gst/fsrtpconference/fs-rtp-substream.c
+++ b/gst/fsrtpconference/fs-rtp-substream.c
@@ -53,7 +53,7 @@ enum
   SRC_PAD_ADDED,
   CODEC_CHANGED,
   ERROR_SIGNAL,
-  GET_CODEC_BIN_LOCKED,
+  GET_CODEC_BIN,
   UNLINKED,
   LAST_SIGNAL
 };
@@ -364,7 +364,7 @@ fs_rtp_sub_stream_class_init (FsRtpSubStreamClass *klass)
    *
    * Returns: The Codec Bin
    */
-  signals[GET_CODEC_BIN_LOCKED] = g_signal_new ("get-codec-bin-locked",
+  signals[GET_CODEC_BIN] = g_signal_new ("get-codec-bin",
       G_TYPE_FROM_CLASS (klass),
       G_SIGNAL_RUN_LAST,
       0,
@@ -1288,10 +1288,8 @@ _rtpbin_pad_blocked_callback (GstPad *pad, gboolean blocked, gpointer user_data)
 
   for (;;)
   {
-    FS_RTP_SESSION_LOCK (substream->priv->session);
-    g_signal_emit (substream, signals[GET_CODEC_BIN_LOCKED], 0,
+    g_signal_emit (substream, signals[GET_CODEC_BIN], 0,
         substream->priv->stream, substream->codec, &codec, &error, &codecbin);
-    FS_RTP_SESSION_UNLOCK (substream->priv->session);
 
    if (!codecbin)
     {
-- 
1.5.6.5




More information about the farsight-commits mailing list