]> git.sesse.net Git - vlc/commitdiff
fixed huge memory leak affecting #rtp stream output
authorMarian Durkovic <md@videolan.org>
Thu, 27 Oct 2005 07:31:15 +0000 (07:31 +0000)
committerMarian Durkovic <md@videolan.org>
Thu, 27 Oct 2005 07:31:15 +0000 (07:31 +0000)
modules/access_output/udp.c

index 1e50eaee1be0c5396467aa5c050d0a8b93921250..ce7cc7b385a1395dd593c2b970e6598e55e1e810 100644 (file)
@@ -447,6 +447,20 @@ static int Write( sout_access_out_t *p_access, block_t *p_buffer )
 static int WriteRaw( sout_access_out_t *p_access, block_t *p_buffer )
 {
     sout_access_out_sys_t   *p_sys = p_access->p_sys;
+    block_t *p_buf;
+
+    vlc_mutex_lock( &p_sys->p_thread->blocks_lock );
+    while ( p_sys->p_thread->i_empty_depth >= MAX_EMPTY_BLOCKS )
+    {
+        p_buf = p_sys->p_thread->p_empty_blocks;
+        p_sys->p_thread->p_empty_blocks =
+                    p_sys->p_thread->p_empty_blocks->p_next;
+        p_sys->p_thread->i_empty_depth--;
+        vlc_mutex_unlock( &p_sys->p_thread->blocks_lock );
+        block_Release( p_buf );
+        vlc_mutex_lock( &p_sys->p_thread->blocks_lock );
+    }
+    vlc_mutex_unlock( &p_sys->p_thread->blocks_lock );
 
     block_FifoPut( p_sys->p_thread->p_fifo, p_buffer );