[vlc-commits] livehttp: use ChainLastAppend and remove ChainGather to gain speed

Ilkka Ollakka git at videolan.org
Sat Oct 10 18:06:24 CEST 2015


vlc/vlc-2.2 | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Fri Oct  9 20:48:17 2015 +0300| [5a71de0e1c308a024cab89abd2445f1b05da1006] | committer: Ilkka Ollakka

livehttp: use ChainLastAppend and remove ChainGather to gain speed

ChainGather in this case would make high amount of small memcopies which
kill performance quite nicely. Also ChainAppend would seek long list of
blocks everytime.

This basicly reverts 609a5fe2b4cdd2cca8bdd99e917ddd4d377bc6e6 and adds
ChainLastAppend. Overall speeding up livehttp-output quite a lot.

Reported-by: JEEB
(cherry picked from commit 9bd13e067daa2c938faed1504006d4f5654a8687)
Signed-off-by: Ilkka Ollakka <ileoo at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=5a71de0e1c308a024cab89abd2445f1b05da1006
---

 modules/access_output/livehttp.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/access_output/livehttp.c b/modules/access_output/livehttp.c
index 0563f8d..0ff6ab9 100644
--- a/modules/access_output/livehttp.c
+++ b/modules/access_output/livehttp.c
@@ -188,6 +188,7 @@ struct sout_access_out_sys_t
     size_t  i_seglen;
     float   f_seglen;
     block_t *block_buffer;
+    block_t **last_block_buffer;
     int i_handle;
     unsigned i_numsegs;
     unsigned i_initial_segment;
@@ -234,6 +235,7 @@ static int Open( vlc_object_t *p_this )
     /* Try to get within asked segment length */
     p_sys->i_seglenm = CLOCK_FREQ * p_sys->i_seglen;
     p_sys->block_buffer = NULL;
+    p_sys->last_block_buffer = &p_sys->block_buffer;
 
     p_sys->i_numsegs = var_GetInteger( p_access, SOUT_CFG_PREFIX "numsegs" );
     p_sys->i_initial_segment = var_GetInteger( p_access, SOUT_CFG_PREFIX "initial-segment-number" );
@@ -758,6 +760,7 @@ static void Close( vlc_object_t * p_this )
     sout_access_out_sys_t *p_sys = p_access->p_sys;
     block_t *output_block = p_sys->block_buffer;
     p_sys->block_buffer = NULL;
+    p_sys->last_block_buffer = &p_sys->block_buffer;
 
     while( output_block )
     {
@@ -792,6 +795,7 @@ static void Close( vlc_object_t * p_this )
     {
         block_ChainRelease( p_sys->block_buffer );
         p_sys->block_buffer = NULL;
+        p_sys->last_block_buffer = &p_sys->block_buffer;
     }
 
     closeCurrentSegment( p_access, p_sys, true );
@@ -946,8 +950,9 @@ static int CheckSegmentChange( sout_access_out_t *p_access, block_t *p_buffer )
 static ssize_t writeSegment( sout_access_out_t *p_access )
 {
     sout_access_out_sys_t *p_sys = p_access->p_sys;
-    block_t *output = p_sys->block_buffer ? block_ChainGather( p_sys->block_buffer ) : NULL;
+    block_t *output = p_sys->block_buffer;
     p_sys->block_buffer = NULL;
+    p_sys->last_block_buffer = &p_sys->block_buffer;
     ssize_t i_write=0;
     bool crypted = false;
     while( output )
@@ -1041,7 +1046,7 @@ static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
 
         p_temp = p_buffer->p_next;
         p_buffer->p_next = NULL;
-        block_ChainAppend( &p_sys->block_buffer, p_buffer );
+        block_ChainLastAppend( &p_sys->last_block_buffer, p_buffer );
         p_buffer = p_temp;
     }
 



More information about the vlc-commits mailing list