diff --git a/pinos/gst/gstburstcache.c b/pinos/gst/gstburstcache.c index 02dcfd90c..ac6444a22 100644 --- a/pinos/gst/gstburstcache.c +++ b/pinos/gst/gstburstcache.c @@ -174,6 +174,7 @@ gst_burst_cache_init (GstBurstCache * this) this->recover = DEFAULT_RECOVER; } + static void gst_burst_cache_finalize (GObject * object) { @@ -1061,17 +1062,17 @@ remove_hook (GstBurstCacheReader * reader, GstBurstCache * cache) } /** - * gst_burst_cache_clear_readers: + * gst_burst_cache_remove_readers: * @cache: a #GstBurstCache * * Remove all readers from @cache. */ void -gst_burst_cache_clear_readers (GstBurstCache * cache) +gst_burst_cache_remove_readers (GstBurstCache * cache) { g_return_if_fail (GST_IS_BURST_CACHE (cache)); - GST_DEBUG_OBJECT (cache, "clearing all readers"); + GST_DEBUG_OBJECT (cache, "removing all readers"); CACHE_LOCK (cache); g_hook_list_marshal_check (&cache->readers, TRUE, (GHookCheckMarshaller) @@ -1337,6 +1338,23 @@ gst_burst_cache_queue_buffer (GstBurstCache * cache, GstBuffer * buffer) CACHE_UNLOCK (cache); } +/** + * gst_burst_cache_remove_buffers: + * @cache: a #GstBurstCache + * + * Remove all buffers from @cache. + */ +void +gst_burst_cache_remove_buffers (GstBurstCache * cache) +{ + g_return_if_fail (GST_IS_BURST_CACHE (cache)); + + CACHE_LOCK (cache); + g_ptr_array_foreach (cache->bufqueue, (GFunc) gst_buffer_unref, NULL); + g_ptr_array_set_size (cache->bufqueue, 0); + CACHE_UNLOCK (cache); +} + /** * gst_burst_cache_get_buffer: * @cache: a #GstBurstCache diff --git a/pinos/gst/gstburstcache.h b/pinos/gst/gstburstcache.h index 6d656f726..c03ac11c6 100644 --- a/pinos/gst/gstburstcache.h +++ b/pinos/gst/gstburstcache.h @@ -272,6 +272,7 @@ void gst_burst_cache_get_limits (GstBurstCache *cache, void gst_burst_cache_queue_buffer (GstBurstCache *cache, GstBuffer *buffer); +void gst_burst_cache_remove_buffers (GstBurstCache *cache); GstBurstCacheReader * gst_burst_cache_reader_new (GstBurstCache *cache, GstBurstCacheReaderCallback callback, @@ -292,7 +293,7 @@ gboolean gst_burst_cache_error_reader (GstBurstCache *cache, GstBurstCacheReader *reader, GError *error); -void gst_burst_cache_clear_readers (GstBurstCache * cache); +void gst_burst_cache_remove_readers (GstBurstCache * cache); GstBurstCacheResult gst_burst_cache_get_buffer (GstBurstCache *cache, diff --git a/pinos/gst/gstpinossocketsink.c b/pinos/gst/gstpinossocketsink.c index 73e036994..0e8cb53a6 100644 --- a/pinos/gst/gstpinossocketsink.c +++ b/pinos/gst/gstpinossocketsink.c @@ -444,6 +444,8 @@ thread_error: static gboolean gst_pinos_socket_sink_close (GstPinosSocketSink * this) { + gst_burst_cache_remove_buffers (this->cache); + GST_DEBUG ("context %p, loop %p", this->context, this->loop); g_main_loop_quit (this->loop); g_thread_join (this->thread);