mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
media: match prepare with unprepare
Really unprepare when there were an equal amount of prepare calls.
This commit is contained in:
parent
ca26588c7e
commit
6beabf1ed4
1 changed files with 16 additions and 0 deletions
|
@ -47,6 +47,7 @@ struct _GstRTSPMediaPrivate
|
|||
GPtrArray *streams;
|
||||
GList *dynamic;
|
||||
GstRTSPMediaStatus status;
|
||||
gint prepare_count;
|
||||
gint n_active;
|
||||
gboolean adding;
|
||||
|
||||
|
@ -1345,6 +1346,8 @@ gst_rtsp_media_prepare (GstRTSPMedia * media)
|
|||
priv = media->priv;
|
||||
|
||||
g_rec_mutex_lock (&priv->state_lock);
|
||||
priv->prepare_count++;
|
||||
|
||||
if (priv->status == GST_RTSP_MEDIA_STATUS_PREPARED)
|
||||
goto was_prepared;
|
||||
|
||||
|
@ -1464,17 +1467,20 @@ was_prepared:
|
|||
not_unprepared:
|
||||
{
|
||||
GST_WARNING ("media %p was not unprepared", media);
|
||||
priv->prepare_count--;
|
||||
g_rec_mutex_unlock (&priv->state_lock);
|
||||
return FALSE;
|
||||
}
|
||||
is_reused:
|
||||
{
|
||||
priv->prepare_count--;
|
||||
g_rec_mutex_unlock (&priv->state_lock);
|
||||
GST_WARNING ("can not reuse media %p", media);
|
||||
return FALSE;
|
||||
}
|
||||
no_rtpbin:
|
||||
{
|
||||
priv->prepare_count--;
|
||||
g_rec_mutex_unlock (&priv->state_lock);
|
||||
GST_WARNING ("no rtpbin element");
|
||||
g_warning ("failed to create element 'rtpbin', check your installation");
|
||||
|
@ -1576,6 +1582,10 @@ gst_rtsp_media_unprepare (GstRTSPMedia * media)
|
|||
if (priv->status == GST_RTSP_MEDIA_STATUS_UNPREPARED)
|
||||
goto was_unprepared;
|
||||
|
||||
priv->prepare_count--;
|
||||
if (priv->prepare_count > 0)
|
||||
goto is_busy;
|
||||
|
||||
GST_INFO ("unprepare media %p", media);
|
||||
priv->target_state = GST_STATE_NULL;
|
||||
success = TRUE;
|
||||
|
@ -1599,6 +1609,12 @@ was_unprepared:
|
|||
GST_INFO ("media %p was already unprepared", media);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue