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:
Wim Taymans 2009-04-03 22:46:22 +02:00 committed by Wim Taymans
parent 0c1df5e023
commit 35a5a709d3

View file

@ -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);