rtsp-media: Do not prepare media after media times out

Deferred calls to start_prepare() can be deferred past the point until
which wait_preroll() and by proxy gst_rtsp_media_get_status() is
prepared to wait. Previously there was no lock and no check for this
situation. This meant that a media could be prepared and unprepared
simultaneously by two different threads. Now a lock is in place and a
suitable check is done.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=759773
This commit is contained in:
Sebastian Rasmussen 2015-12-22 12:08:02 +01:00 committed by Sebastian Dröge
parent c8f179948e
commit b2abb97043

View file

@ -2555,6 +2555,10 @@ start_prepare (GstRTSPMedia * media)
guint i;
GList *walk;
g_rec_mutex_lock (&priv->state_lock);
if (priv->status != GST_RTSP_MEDIA_STATUS_PREPARING)
goto no_longer_preparing;
/* link streams we already have, other streams might appear when we have
* dynamic elements */
for (i = 0; i < priv->streams->len; i++) {
@ -2603,18 +2607,28 @@ start_prepare (GstRTSPMedia * media)
if (!start_preroll (media))
goto preroll_failed;
g_rec_mutex_unlock (&priv->state_lock);
return FALSE;
no_longer_preparing:
{
GST_INFO ("media is no longer preparing");
g_rec_mutex_unlock (&priv->state_lock);
return FALSE;
}
join_bin_failed:
{
GST_WARNING ("failed to join bin element");
gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_ERROR);
g_rec_mutex_unlock (&priv->state_lock);
return FALSE;
}
preroll_failed:
{
GST_WARNING ("failed to preroll pipeline");
gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_ERROR);
g_rec_mutex_unlock (&priv->state_lock);
return FALSE;
}
}