[vlc-commits] decoder: allocate decoder audio buffers directly
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:24:53 2011 +0300| [e83cd1767d13718762b805a33c14efb04ee6ff3f] | committer: Rémi Denis-Courmont
decoder: allocate decoder audio buffers directly
Do not convert from samples to duration and back to samples.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e83cd1767d13718762b805a33c14efb04ee6ff3f
---
src/audio_output/dec.c | 26 +++++++++++---------------
1 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 0cb9bfc..50ac040 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -221,8 +221,8 @@ int aout_DecDelete( aout_instance_t * p_aout, aout_input_t * p_input )
aout_buffer_t * aout_DecNewBuffer( aout_input_t * p_input,
size_t i_nb_samples )
{
- aout_buffer_t * p_buffer;
- mtime_t duration;
+ block_t *block;
+ size_t length;
aout_lock_input( NULL, p_input );
@@ -232,25 +232,21 @@ aout_buffer_t * aout_DecNewBuffer( aout_input_t * p_input,
return NULL;
}
- duration = (1000000 * (mtime_t)i_nb_samples) / p_input->input.i_rate;
-
- /* This necessarily allocates in the heap. */
- p_buffer = aout_BufferAlloc( &p_input->input_alloc, duration, NULL );
- if( p_buffer != NULL )
- p_buffer->i_buffer = i_nb_samples * p_input->input.i_bytes_per_frame
- / p_input->input.i_frame_length;
+ length = i_nb_samples * p_input->input.i_bytes_per_frame
+ / 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( p_buffer == NULL )
- return NULL;
-
- p_buffer->i_nb_samples = i_nb_samples;
- p_buffer->i_pts = p_buffer->i_length = 0;
- return p_buffer;
+ if( likely(block != NULL) )
+ {
+ block->i_nb_samples = i_nb_samples;
+ block->i_pts = block->i_length = 0;
+ }
+ return block;
}
/*****************************************************************************
More information about the vlc-commits
mailing list