media: check state

Make sure we are in the right state when collecting the position and duration.
Only make ourselves PREPARED when we were previously PREPARING.
This commit is contained in:
Wim Taymans 2012-11-30 12:53:02 +01:00
parent edf2ef4f0b
commit 241baba20a

View file

@ -309,6 +309,10 @@ collect_media_stats (GstRTSPMedia * media)
GstRTSPMediaPrivate *priv = media->priv; GstRTSPMediaPrivate *priv = media->priv;
gint64 position, duration; gint64 position, duration;
if (priv->status != GST_RTSP_MEDIA_STATUS_PREPARED &&
priv->status != GST_RTSP_MEDIA_STATUS_PREPARING)
return;
priv->range.unit = GST_RTSP_RANGE_NPT; priv->range.unit = GST_RTSP_RANGE_NPT;
GST_INFO ("collect media stats"); GST_INFO ("collect media stats");
@ -1092,9 +1096,7 @@ gst_rtsp_media_set_status (GstRTSPMedia * media, GstRTSPMediaStatus status)
GstRTSPMediaPrivate *priv = media->priv; GstRTSPMediaPrivate *priv = media->priv;
g_mutex_lock (&priv->lock); g_mutex_lock (&priv->lock);
/* never overwrite the error status */ priv->status = status;
if (priv->status != GST_RTSP_MEDIA_STATUS_ERROR)
priv->status = status;
GST_DEBUG ("setting new status to %d", status); GST_DEBUG ("setting new status to %d", status);
g_cond_broadcast (&priv->cond); g_cond_broadcast (&priv->cond);
g_mutex_unlock (&priv->lock); g_mutex_unlock (&priv->lock);
@ -1222,7 +1224,8 @@ default_handle_message (GstRTSPMedia * media, GstMessage * message)
GST_INFO ("%p: got ASYNC_DONE", media); GST_INFO ("%p: got ASYNC_DONE", media);
collect_media_stats (media); collect_media_stats (media);
gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_PREPARED); if (priv->status == GST_RTSP_MEDIA_STATUS_PREPARING)
gst_rtsp_media_set_status (media, GST_RTSP_MEDIA_STATUS_PREPARED);
} else { } else {
GST_INFO ("%p: ignoring ASYNC_DONE", media); GST_INFO ("%p: ignoring ASYNC_DONE", media);
} }