Commit 095526d1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

trivial mixer: support all linear formats

parent a822a430
...@@ -60,8 +60,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -60,8 +60,7 @@ static int Create( vlc_object_t *p_this )
{ {
aout_mixer_t *p_mixer = (aout_mixer_t *)p_this; aout_mixer_t *p_mixer = (aout_mixer_t *)p_this;
if ( p_mixer->fmt.i_format != VLC_CODEC_FL32 if( AOUT_FMT_NON_LINEAR( &p_mixer->fmt ) )
&& p_mixer->fmt.i_format != VLC_CODEC_FI32 )
return -1; return -1;
p_mixer->mix = DoWork; p_mixer->mix = DoWork;
...@@ -75,9 +74,10 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples, ...@@ -75,9 +74,10 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples,
float multiplier ) float multiplier )
{ {
aout_mixer_input_t *p_input = p_mixer->input; aout_mixer_input_t *p_input = p_mixer->input;
int i_nb_channels = aout_FormatNbChannels( &p_mixer->fmt ); unsigned framesize = aout_FormatNbChannels( &p_mixer->fmt )
ssize_t i_buffer = samples * i_nb_channels * sizeof(int32_t); * (p_mixer->fmt.i_bitspersample / 8);
aout_buffer_t *p_buffer = block_Alloc( i_buffer ); size_t needed = samples * framesize;
aout_buffer_t *p_buffer = block_Alloc( needed );
if( unlikely(p_buffer == NULL) ) if( unlikely(p_buffer == NULL) )
return NULL; return NULL;
...@@ -88,22 +88,17 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples, ...@@ -88,22 +88,17 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples,
for ( ; ; ) for ( ; ; )
{ {
ptrdiff_t i_available_bytes = (p_input->fifo.p_first->p_buffer size_t avail = p_input->fifo.p_first->i_nb_samples * framesize
- p_in) - (p_in - p_input->fifo.p_first->p_buffer);
+ p_input->fifo.p_first->i_nb_samples
* sizeof(int32_t)
* i_nb_channels;
if ( i_available_bytes < i_buffer ) if ( avail < needed )
{ {
aout_buffer_t * p_old_buffer; vlc_memcpy( p_out, p_in, avail );
needed -= avail;
vlc_memcpy( p_out, p_in, i_available_bytes ); p_out += avail;
i_buffer -= i_available_bytes;
p_out += i_available_bytes;
/* Next buffer */ /* Next buffer */
p_old_buffer = aout_FifoPop( NULL, &p_input->fifo ); aout_buffer_t *p_old_buffer = aout_FifoPop( NULL, &p_input->fifo );
aout_BufferFree( p_old_buffer ); aout_BufferFree( p_old_buffer );
if ( p_input->fifo.p_first == NULL ) if ( p_input->fifo.p_first == NULL )
{ {
...@@ -114,8 +109,8 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples, ...@@ -114,8 +109,8 @@ static aout_buffer_t *DoWork( aout_mixer_t *p_mixer, unsigned samples,
} }
else else
{ {
vlc_memcpy( p_out, p_in, i_buffer ); vlc_memcpy( p_out, p_in, needed );
p_input->begin = p_in + i_buffer; p_input->begin = p_in + needed;
break; break;
} }
} }
......
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