[vlc-commits] headphone: fix memory allocation

Ilkka Ollakka git at videolan.org
Sat Mar 22 12:57:14 CET 2014


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sat Mar 22 13:51:56 2014 +0200| [82eec5cdb80397a80f694850c4891087db515b2a] | committer: Ilkka Ollakka

headphone: fix memory allocation

Don't just set i_buffer to higher than it was with allocation.

could Ref #10445

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

 modules/audio_filter/channel_mixer/headphone.c |   21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/modules/audio_filter/channel_mixer/headphone.c b/modules/audio_filter/channel_mixer/headphone.c
index 92c1a3b..73180dd 100644
--- a/modules/audio_filter/channel_mixer/headphone.c
+++ b/modules/audio_filter/channel_mixer/headphone.c
@@ -105,7 +105,7 @@ struct atomic_operation_t
 struct filter_sys_t
 {
     size_t i_overflow_buffer_size;/* in bytes */
-    uint8_t * p_overflow_buffer;
+    float * p_overflow_buffer;
     unsigned int i_nb_atomic_operations;
     struct atomic_operation_t * p_atomic_operations;
 };
@@ -315,7 +315,7 @@ static int Init( vlc_object_t *p_this, struct filter_sys_t * p_data
                 = p_data->p_atomic_operations[i].i_delay * 2 * sizeof (float);
         }
     }
-    p_data->p_overflow_buffer = malloc( p_data->i_overflow_buffer_size );
+    p_data->p_overflow_buffer = (float *)malloc( p_data->i_overflow_buffer_size );
     if( p_data->p_overflow_buffer == NULL )
     {
         free( p_data->p_atomic_operations );
@@ -337,9 +337,9 @@ static void DoWork( filter_t * p_filter,
     int i_output_nb = aout_FormatNbChannels( &p_filter->fmt_out.audio );
 
     float * p_in = (float*) p_in_buf->p_buffer;
-    uint8_t * p_out;
-    uint8_t * p_overflow;
-    uint8_t * p_slide;
+    float * p_out;
+    float * p_overflow;
+    float * p_slide;
 
     size_t i_overflow_size;     /* in bytes */
     size_t i_out_size;          /* in bytes */
@@ -351,10 +351,7 @@ static void DoWork( filter_t * p_filter,
     unsigned int i_delay;
     double d_amplitude_factor;
 
-    /* out buffer characterisitcs */
-    p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
-    p_out_buf->i_buffer = p_in_buf->i_buffer * i_output_nb / i_input_nb;
-    p_out = p_out_buf->p_buffer;
+    p_out = (float *)p_out_buf->p_buffer;
     i_out_size = p_out_buf->i_buffer;
 
     /* Slide the overflow buffer */
@@ -506,9 +503,9 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
         return NULL;
     }
 
-    size_t i_out_size = p_block->i_nb_samples *
-      p_filter->fmt_out.audio.i_bitspersample/8 *
-        aout_FormatNbChannels( &(p_filter->fmt_out.audio) );
+    size_t i_out_size = p_block->i_buffer *
+        aout_FormatNbChannels( &(p_filter->fmt_out.audio) ) /
+        aout_FormatNbChannels( &(p_filter->fmt_in.audio) );
 
     block_t *p_out = block_Alloc( i_out_size );
     if( !p_out )



More information about the vlc-commits mailing list