rtpssrcdemux: Make the pads lock recursive and hold it across the signal emit

We need to keep the lock held because we don't want a push before the "new-ssrc-pad"
handler has completed. But we may want to push an event from inside that handler, hence
the recursive mutex.

https://bugzilla.gnome.org/show_bug.cgi?id=650916
This commit is contained in:
Olivier Crête 2011-05-24 11:29:57 +03:00 committed by Mark Nauwelaerts
parent e26b5391c2
commit c7b9b98648
2 changed files with 7 additions and 7 deletions

View file

@ -83,8 +83,8 @@ GST_STATIC_PAD_TEMPLATE ("rtcp_src_%d",
GST_STATIC_CAPS ("application/x-rtcp")
);
#define GST_PAD_LOCK(obj) (g_mutex_lock ((obj)->padlock))
#define GST_PAD_UNLOCK(obj) (g_mutex_unlock ((obj)->padlock))
#define GST_PAD_LOCK(obj) (g_static_rec_mutex_lock (&(obj)->padlock))
#define GST_PAD_UNLOCK(obj) (g_static_rec_mutex_unlock (&(obj)->padlock))
/* signals */
enum
@ -214,14 +214,14 @@ find_or_create_demux_pad_for_ssrc (GstRtpSsrcDemux * demux, guint32 ssrc)
gst_rtp_ssrc_demux_iterate_internal_links_src);
gst_pad_set_active (rtcp_pad, TRUE);
GST_PAD_UNLOCK (demux);
gst_element_add_pad (GST_ELEMENT_CAST (demux), rtp_pad);
gst_element_add_pad (GST_ELEMENT_CAST (demux), rtcp_pad);
g_signal_emit (G_OBJECT (demux),
gst_rtp_ssrc_demux_signals[SIGNAL_NEW_SSRC_PAD], 0, ssrc, rtp_pad);
GST_PAD_UNLOCK (demux);
return demuxpad;
}
@ -336,7 +336,7 @@ gst_rtp_ssrc_demux_init (GstRtpSsrcDemux * demux,
gst_rtp_ssrc_demux_iterate_internal_links_sink);
gst_element_add_pad (GST_ELEMENT_CAST (demux), demux->rtcp_sink);
demux->padlock = g_mutex_new ();
g_static_rec_mutex_init (&demux->padlock);
gst_segment_init (&demux->segment, GST_FORMAT_UNDEFINED);
}
@ -378,7 +378,7 @@ gst_rtp_ssrc_demux_finalize (GObject * object)
GstRtpSsrcDemux *demux;
demux = GST_RTP_SSRC_DEMUX (object);
g_mutex_free (demux->padlock);
g_static_rec_mutex_free (&demux->padlock);
G_OBJECT_CLASS (parent_class)->finalize (object);
}

View file

@ -41,7 +41,7 @@ struct _GstRtpSsrcDemux
GstPad *rtp_sink;
GstPad *rtcp_sink;
GMutex *padlock;
GStaticRecMutex padlock;
GSList *srcpads;
};