Commit 95eb6418 authored by Jan Schmidt's avatar Jan Schmidt

rtpbasedepayload: Make stats creation threadsafe, fix a CRITICAL

Use the object lock to protect the internal segment when updating
against access from getting the stats property.

Fix a critical in gst-inspect or when retrieving the stats
before any segment has arrived by checking whether the
segment has been initted..
parent f188a023
...@@ -561,7 +561,10 @@ gst_rtp_base_depayload_handle_event (GstRTPBaseDepayload * filter, ...@@ -561,7 +561,10 @@ gst_rtp_base_depayload_handle_event (GstRTPBaseDepayload * filter,
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_STOP: case GST_EVENT_FLUSH_STOP:
GST_OBJECT_LOCK (filter);
gst_segment_init (&filter->segment, GST_FORMAT_UNDEFINED); gst_segment_init (&filter->segment, GST_FORMAT_UNDEFINED);
GST_OBJECT_UNLOCK (filter);
filter->need_newsegment = TRUE; filter->need_newsegment = TRUE;
filter->priv->next_seqnum = -1; filter->priv->next_seqnum = -1;
gst_event_replace (&filter->priv->segment_event, NULL); gst_event_replace (&filter->priv->segment_event, NULL);
...@@ -578,7 +581,10 @@ gst_rtp_base_depayload_handle_event (GstRTPBaseDepayload * filter, ...@@ -578,7 +581,10 @@ gst_rtp_base_depayload_handle_event (GstRTPBaseDepayload * filter,
} }
case GST_EVENT_SEGMENT: case GST_EVENT_SEGMENT:
{ {
GST_OBJECT_LOCK (filter);
gst_event_copy_segment (event, &filter->segment); gst_event_copy_segment (event, &filter->segment);
GST_OBJECT_UNLOCK (filter);
/* don't pass the event downstream, we generate our own segment including /* don't pass the event downstream, we generate our own segment including
* the NTP time and other things we receive in caps */ * the NTP time and other things we receive in caps */
forward = FALSE; forward = FALSE;
...@@ -648,6 +654,10 @@ create_segment_event (GstRTPBaseDepayload * filter, guint rtptime, ...@@ -648,6 +654,10 @@ create_segment_event (GstRTPBaseDepayload * filter, guint rtptime,
priv = filter->priv; priv = filter->priv;
/* We don't need the object lock around - the segment
* can't change here while we're holding the STREAM_LOCK
*/
/* determining the start of the segment */ /* determining the start of the segment */
start = filter->segment.start; start = filter->segment.start;
if (priv->clock_base != -1 && position != -1) { if (priv->clock_base != -1 && position != -1) {
...@@ -897,16 +907,18 @@ gst_rtp_base_depayload_create_stats (GstRTPBaseDepayload * depayload) ...@@ -897,16 +907,18 @@ gst_rtp_base_depayload_create_stats (GstRTPBaseDepayload * depayload)
{ {
GstRTPBaseDepayloadPrivate *priv; GstRTPBaseDepayloadPrivate *priv;
GstStructure *s; GstStructure *s;
GstClockTime pts, dts; GstClockTime pts = GST_CLOCK_TIME_NONE, dts = GST_CLOCK_TIME_NONE;
priv = depayload->priv; priv = depayload->priv;
/* FIXME this isn't thread safe */ GST_OBJECT_LOCK (depayload);
if (depayload->segment.format != GST_FORMAT_UNDEFINED) {
pts = gst_segment_to_running_time (&depayload->segment, GST_FORMAT_TIME, pts = gst_segment_to_running_time (&depayload->segment, GST_FORMAT_TIME,
priv->pts); priv->pts);
dts = gst_segment_to_running_time (&depayload->segment, GST_FORMAT_TIME, dts = gst_segment_to_running_time (&depayload->segment, GST_FORMAT_TIME,
priv->dts); priv->dts);
}
GST_OBJECT_UNLOCK (depayload);
s = gst_structure_new ("application/x-rtp-depayload-stats", s = gst_structure_new ("application/x-rtp-depayload-stats",
"clock_rate", G_TYPE_UINT, depayload->clock_rate, "clock_rate", G_TYPE_UINT, depayload->clock_rate,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment