[vlc-commits] decoder: do not reallocate audio buffer on interface changes

Rémi Denis-Courmont git at videolan.org
Sat Apr 9 17:39:48 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Apr  9 18:28:14 2011 +0300| [f7d12502678cde571344a31ad11ce33686da45dc] | committer: Rémi Denis-Courmont

decoder: do not reallocate audio buffer on interface changes

This has no effect other than wasting CPU and memory. Audio filters are
supposed to reallocate their buffers as needed.

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

 src/audio_output/aout_internal.h |    3 ---
 src/audio_output/dec.c           |   23 -----------------------
 src/audio_output/intf.c          |    1 -
 3 files changed, 0 insertions(+), 27 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 004eed3..5282623 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -74,9 +74,6 @@ struct aout_input_t
     /* If b_error == 1, there is no input pipeline. */
     bool              b_error;
 
-    /* Did we just change the output format? (expect buffer inconsistencies) */
-    bool              b_changed;
-
     /* last rate from input */
     int               i_last_input_rate;
 
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 50ac040..ecf81b8 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -90,7 +90,6 @@ aout_input_t *aout_DecNew( aout_instance_t *p_aout,
 
     vlc_mutex_init( &p_input->lock );
 
-    p_input->b_changed = false;
     p_input->b_error = true;
     p_input->b_paused = false;
     p_input->i_pause_date = 0;
@@ -236,9 +235,6 @@ aout_buffer_t * aout_DecNewBuffer( aout_input_t * p_input,
                           / p_input->input.i_frame_length;
     block = block_Alloc( length );
 
-    /* Suppose the decoder doesn't have more than one buffered buffer */
-    p_input->b_changed = false;
-
     aout_unlock_input( NULL, p_input );
 
     if( likely(block != NULL) )
@@ -285,25 +281,6 @@ int aout_DecPlay( aout_instance_t * p_aout, aout_input_t * p_input,
         return -1;
     }
 
-    if( p_input->b_changed )
-    {
-        /* Maybe the allocation size has changed. Re-allocate a buffer. */
-        aout_buffer_t * p_new_buffer;
-        mtime_t duration = (1000000 * (mtime_t)p_buffer->i_nb_samples)
-                            / p_input->input.i_rate;
-
-        p_new_buffer = aout_BufferAlloc( &p_input->input_alloc, duration, NULL);
-        vlc_memcpy( p_new_buffer->p_buffer, p_buffer->p_buffer,
-                    p_buffer->i_buffer );
-        p_new_buffer->i_nb_samples = p_buffer->i_nb_samples;
-        p_new_buffer->i_buffer = p_buffer->i_buffer;
-        p_new_buffer->i_pts = p_buffer->i_pts;
-        p_new_buffer->i_length = p_buffer->i_length;
-        aout_BufferFree( p_buffer );
-        p_buffer = p_new_buffer;
-        p_input->b_changed = false;
-    }
-
     aout_InputCheckAndRestart( p_aout, p_input );
     aout_unlock_mixer( p_aout );
 
diff --git a/src/audio_output/intf.c b/src/audio_output/intf.c
index ae8eb84..d21c1e1 100644
--- a/src/audio_output/intf.c
+++ b/src/audio_output/intf.c
@@ -347,7 +347,6 @@ static int aout_Restart( aout_instance_t * p_aout )
     {
         aout_input_t * p_input = p_aout->pp_inputs[i];
         b_error |= aout_InputNew( p_aout, p_input, &p_input->request_vout );
-        p_input->b_changed = 1;
         aout_unlock_input( p_aout, p_input );
     }
 



More information about the vlc-commits mailing list