mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pinossink: clear the cache
Now that we don't destroy the cache anymore when suspending, we need to manually clear the buffers in the cache.
This commit is contained in:
		
							parent
							
								
									5c7447fb4d
								
							
						
					
					
						commit
						76afc1e330
					
				
					 3 changed files with 25 additions and 4 deletions
				
			
		| 
						 | 
					@ -174,6 +174,7 @@ gst_burst_cache_init (GstBurstCache * this)
 | 
				
			||||||
  this->recover = DEFAULT_RECOVER;
 | 
					  this->recover = DEFAULT_RECOVER;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
gst_burst_cache_finalize (GObject * object)
 | 
					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
 | 
					 * @cache: a #GstBurstCache
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Remove all readers from @cache.
 | 
					 * Remove all readers from @cache.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
gst_burst_cache_clear_readers (GstBurstCache * cache)
 | 
					gst_burst_cache_remove_readers (GstBurstCache * cache)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  g_return_if_fail (GST_IS_BURST_CACHE (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);
 | 
					  CACHE_LOCK (cache);
 | 
				
			||||||
  g_hook_list_marshal_check (&cache->readers, TRUE, (GHookCheckMarshaller)
 | 
					  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);
 | 
					  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:
 | 
					 * gst_burst_cache_get_buffer:
 | 
				
			||||||
 * @cache: a #GstBurstCache
 | 
					 * @cache: a #GstBurstCache
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -272,6 +272,7 @@ void                    gst_burst_cache_get_limits       (GstBurstCache *cache,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void                    gst_burst_cache_queue_buffer     (GstBurstCache *cache,
 | 
					void                    gst_burst_cache_queue_buffer     (GstBurstCache *cache,
 | 
				
			||||||
                                                          GstBuffer *buffer);
 | 
					                                                          GstBuffer *buffer);
 | 
				
			||||||
 | 
					void                    gst_burst_cache_remove_buffers   (GstBurstCache *cache);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GstBurstCacheReader *   gst_burst_cache_reader_new       (GstBurstCache *cache,
 | 
					GstBurstCacheReader *   gst_burst_cache_reader_new       (GstBurstCache *cache,
 | 
				
			||||||
                                                          GstBurstCacheReaderCallback callback,
 | 
					                                                          GstBurstCacheReaderCallback callback,
 | 
				
			||||||
| 
						 | 
					@ -292,7 +293,7 @@ gboolean                gst_burst_cache_error_reader     (GstBurstCache *cache,
 | 
				
			||||||
                                                          GstBurstCacheReader *reader,
 | 
					                                                          GstBurstCacheReader *reader,
 | 
				
			||||||
                                                          GError *error);
 | 
					                                                          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,
 | 
					GstBurstCacheResult     gst_burst_cache_get_buffer       (GstBurstCache *cache,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -444,6 +444,8 @@ thread_error:
 | 
				
			||||||
static gboolean
 | 
					static gboolean
 | 
				
			||||||
gst_pinos_socket_sink_close (GstPinosSocketSink * this)
 | 
					gst_pinos_socket_sink_close (GstPinosSocketSink * this)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  gst_burst_cache_remove_buffers (this->cache);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  GST_DEBUG ("context %p, loop %p", this->context, this->loop);
 | 
					  GST_DEBUG ("context %p, loop %p", this->context, this->loop);
 | 
				
			||||||
  g_main_loop_quit (this->loop);
 | 
					  g_main_loop_quit (this->loop);
 | 
				
			||||||
  g_thread_join (this->thread);
 | 
					  g_thread_join (this->thread);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue