Commit 82eec5cd authored by Ilkka Ollakka's avatar Ilkka Ollakka

headphone: fix memory allocation

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

could Ref #10445
parent 168a83f7
...@@ -105,7 +105,7 @@ struct atomic_operation_t ...@@ -105,7 +105,7 @@ struct atomic_operation_t
struct filter_sys_t struct filter_sys_t
{ {
size_t i_overflow_buffer_size;/* in bytes */ size_t i_overflow_buffer_size;/* in bytes */
uint8_t * p_overflow_buffer; float * p_overflow_buffer;
unsigned int i_nb_atomic_operations; unsigned int i_nb_atomic_operations;
struct atomic_operation_t * p_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 ...@@ -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_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 ) if( p_data->p_overflow_buffer == NULL )
{ {
free( p_data->p_atomic_operations ); free( p_data->p_atomic_operations );
...@@ -337,9 +337,9 @@ static void DoWork( filter_t * p_filter, ...@@ -337,9 +337,9 @@ static void DoWork( filter_t * p_filter,
int i_output_nb = aout_FormatNbChannels( &p_filter->fmt_out.audio ); int i_output_nb = aout_FormatNbChannels( &p_filter->fmt_out.audio );
float * p_in = (float*) p_in_buf->p_buffer; float * p_in = (float*) p_in_buf->p_buffer;
uint8_t * p_out; float * p_out;
uint8_t * p_overflow; float * p_overflow;
uint8_t * p_slide; float * p_slide;
size_t i_overflow_size; /* in bytes */ size_t i_overflow_size; /* in bytes */
size_t i_out_size; /* in bytes */ size_t i_out_size; /* in bytes */
...@@ -351,10 +351,7 @@ static void DoWork( filter_t * p_filter, ...@@ -351,10 +351,7 @@ static void DoWork( filter_t * p_filter,
unsigned int i_delay; unsigned int i_delay;
double d_amplitude_factor; double d_amplitude_factor;
/* out buffer characterisitcs */ p_out = (float *)p_out_buf->p_buffer;
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;
i_out_size = p_out_buf->i_buffer; i_out_size = p_out_buf->i_buffer;
/* Slide the overflow buffer */ /* Slide the overflow buffer */
...@@ -506,9 +503,9 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block ) ...@@ -506,9 +503,9 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
return NULL; return NULL;
} }
size_t i_out_size = p_block->i_nb_samples * size_t i_out_size = p_block->i_buffer *
p_filter->fmt_out.audio.i_bitspersample/8 * aout_FormatNbChannels( &(p_filter->fmt_out.audio) ) /
aout_FormatNbChannels( &(p_filter->fmt_out.audio) ); aout_FormatNbChannels( &(p_filter->fmt_in.audio) );
block_t *p_out = block_Alloc( i_out_size ); block_t *p_out = block_Alloc( i_out_size );
if( !p_out ) if( !p_out )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment