mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +00:00
factory: connect to the unprepare signal
Connect to the unprepare signal for non-reusable media so that we can remove them from the cache.
This commit is contained in:
parent
0c1df5e023
commit
35a5a709d3
1 changed files with 21 additions and 0 deletions
|
@ -250,6 +250,21 @@ gst_rtsp_media_factory_is_shared (GstRTSPMediaFactory *factory)
|
|||
return result;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
compare_media (gpointer key, GstRTSPMedia *media1, GstRTSPMedia *media2)
|
||||
{
|
||||
return (media1 == media2);
|
||||
}
|
||||
|
||||
static void
|
||||
media_unprepared (GstRTSPMedia *media, GstRTSPMediaFactory *factory)
|
||||
{
|
||||
g_mutex_lock (factory->medias_lock);
|
||||
g_hash_table_foreach_remove (factory->medias, (GHRFunc) compare_media,
|
||||
media);
|
||||
g_mutex_unlock (factory->medias_lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_media_factory_construct:
|
||||
* @factory: a #GstRTSPMediaFactory
|
||||
|
@ -310,6 +325,12 @@ gst_rtsp_media_factory_construct (GstRTSPMediaFactory *factory, const GstRTSPUrl
|
|||
g_hash_table_insert (factory->medias, key, media);
|
||||
key = NULL;
|
||||
}
|
||||
if (!gst_rtsp_media_is_reusable (media)) {
|
||||
/* when not reusable, connect to the unprepare signal to remove the item
|
||||
* from our cache when it gets unprepared */
|
||||
g_signal_connect (media, "unprepared", (GCallback) media_unprepared,
|
||||
factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
g_mutex_unlock (factory->medias_lock);
|
||||
|
|
Loading…
Reference in a new issue