Commit 6beabf1e authored by Wim Taymans's avatar Wim Taymans

media: match prepare with unprepare

Really unprepare when there were an equal amount of prepare calls.
parent ca26588c
...@@ -47,6 +47,7 @@ struct _GstRTSPMediaPrivate ...@@ -47,6 +47,7 @@ struct _GstRTSPMediaPrivate
GPtrArray *streams; GPtrArray *streams;
GList *dynamic; GList *dynamic;
GstRTSPMediaStatus status; GstRTSPMediaStatus status;
gint prepare_count;
gint n_active; gint n_active;
gboolean adding; gboolean adding;
...@@ -1345,6 +1346,8 @@ gst_rtsp_media_prepare (GstRTSPMedia * media) ...@@ -1345,6 +1346,8 @@ gst_rtsp_media_prepare (GstRTSPMedia * media)
priv = media->priv; priv = media->priv;
g_rec_mutex_lock (&priv->state_lock); g_rec_mutex_lock (&priv->state_lock);
priv->prepare_count++;
if (priv->status == GST_RTSP_MEDIA_STATUS_PREPARED) if (priv->status == GST_RTSP_MEDIA_STATUS_PREPARED)
goto was_prepared; goto was_prepared;
...@@ -1464,17 +1467,20 @@ was_prepared: ...@@ -1464,17 +1467,20 @@ was_prepared:
not_unprepared: not_unprepared:
{ {
GST_WARNING ("media %p was not unprepared", media); GST_WARNING ("media %p was not unprepared", media);
priv->prepare_count--;
g_rec_mutex_unlock (&priv->state_lock); g_rec_mutex_unlock (&priv->state_lock);
return FALSE; return FALSE;
} }
is_reused: is_reused:
{ {
priv->prepare_count--;
g_rec_mutex_unlock (&priv->state_lock); g_rec_mutex_unlock (&priv->state_lock);
GST_WARNING ("can not reuse media %p", media); GST_WARNING ("can not reuse media %p", media);
return FALSE; return FALSE;
} }
no_rtpbin: no_rtpbin:
{ {
priv->prepare_count--;
g_rec_mutex_unlock (&priv->state_lock); g_rec_mutex_unlock (&priv->state_lock);
GST_WARNING ("no rtpbin element"); GST_WARNING ("no rtpbin element");
g_warning ("failed to create element 'rtpbin', check your installation"); g_warning ("failed to create element 'rtpbin', check your installation");
...@@ -1576,6 +1582,10 @@ gst_rtsp_media_unprepare (GstRTSPMedia * media) ...@@ -1576,6 +1582,10 @@ gst_rtsp_media_unprepare (GstRTSPMedia * media)
if (priv->status == GST_RTSP_MEDIA_STATUS_UNPREPARED) if (priv->status == GST_RTSP_MEDIA_STATUS_UNPREPARED)
goto was_unprepared; goto was_unprepared;
priv->prepare_count--;
if (priv->prepare_count > 0)
goto is_busy;
GST_INFO ("unprepare media %p", media); GST_INFO ("unprepare media %p", media);
priv->target_state = GST_STATE_NULL; priv->target_state = GST_STATE_NULL;
success = TRUE; success = TRUE;
...@@ -1599,6 +1609,12 @@ was_unprepared: ...@@ -1599,6 +1609,12 @@ was_unprepared:
GST_INFO ("media %p was already unprepared", media); GST_INFO ("media %p was already unprepared", media);
return TRUE; return TRUE;
} }
is_busy:
{
GST_INFO ("media %p still prepared %d times", media, priv->prepare_count);
g_rec_mutex_unlock (&priv->state_lock);
return TRUE;
}
} }
/** /**
......
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