[vlc-commits] Remove aout_mixer_input_t.begin
Rémi Denis-Courmont
git at videolan.org
Tue Jun 7 19:49:26 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jun 7 20:43:50 2011 +0300| [6de1cefb1d3808a49938096612a4bfabd614d7a4] | committer: Rémi Denis-Courmont
Remove aout_mixer_input_t.begin
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6de1cefb1d3808a49938096612a4bfabd614d7a4
---
include/vlc_aout_mixer.h | 6 ------
src/audio_output/dec.c | 3 ---
src/audio_output/input.c | 5 -----
src/audio_output/mixer.c | 33 +++++++++++++++++----------------
4 files changed, 17 insertions(+), 30 deletions(-)
diff --git a/include/vlc_aout_mixer.h b/include/vlc_aout_mixer.h
index 92b5244..a38de40 100644
--- a/include/vlc_aout_mixer.h
+++ b/include/vlc_aout_mixer.h
@@ -44,12 +44,6 @@ typedef struct {
/* */
aout_fifo_t fifo;
- /* Pointer on the first byte of data to mix.
- *
- * It points in the first buffer of fifo
- */
- uint8_t *begin;
-
/* Software multiplier */
float multiplier;
} aout_mixer_input_t;
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 4bb6981..87962f1 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -283,10 +283,7 @@ void aout_DecChangePause( aout_instance_t *p_aout, aout_input_t *p_input, bool b
void aout_DecFlush( aout_instance_t *p_aout, aout_input_t *p_input )
{
aout_lock_input_fifos( p_aout );
-
aout_FifoSet( &p_input->mixer.fifo, 0 );
- p_input->mixer.begin = NULL;
-
aout_unlock_input_fifos( p_aout );
}
diff --git a/src/audio_output/input.c b/src/audio_output/input.c
index 2843a20..2e02b1b 100644
--- a/src/audio_output/input.c
+++ b/src/audio_output/input.c
@@ -83,7 +83,6 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input, const aout_
/* Prepare FIFO. */
aout_FifoInit( p_aout, &p_input->mixer.fifo, p_aout->mixer_format.i_rate );
- p_input->mixer.begin = NULL;
/* */
if( p_request_vout )
@@ -471,7 +470,6 @@ void aout_InputCheckAndRestart( aout_instance_t * p_aout, aout_input_t * p_input
/* A little trick to avoid loosing our input fifo and properties */
- uint8_t *p_first_byte_to_mix = p_input->mixer.begin;
aout_fifo_t fifo = p_input->mixer.fifo;
bool b_paused = p_input->b_paused;
mtime_t i_pause_date = p_input->i_pause_date;
@@ -481,7 +479,6 @@ void aout_InputCheckAndRestart( aout_instance_t * p_aout, aout_input_t * p_input
aout_InputDelete( p_aout, p_input );
aout_InputNew( p_aout, p_input, &p_input->request_vout );
- p_input->mixer.begin = p_first_byte_to_mix;
p_input->mixer.fifo = fifo;
p_input->b_paused = b_paused;
p_input->i_pause_date = i_pause_date;
@@ -561,7 +558,6 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
"clearing out", mdate() - start_date );
aout_lock_input_fifos( p_aout );
aout_FifoSet( &p_input->mixer.fifo, 0 );
- p_input->mixer.begin = NULL;
aout_unlock_input_fifos( p_aout );
if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
msg_Warn( p_aout, "timing screwed, stopping resampling" );
@@ -592,7 +588,6 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
start_date - p_buffer->i_pts );
aout_lock_input_fifos( p_aout );
aout_FifoSet( &p_input->mixer.fifo, 0 );
- p_input->mixer.begin = NULL;
aout_unlock_input_fifos( p_aout );
if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
msg_Warn( p_aout, "timing screwed, stopping resampling" );
diff --git a/src/audio_output/mixer.c b/src/audio_output/mixer.c
index 355838d..7f87083 100644
--- a/src/audio_output/mixer.c
+++ b/src/audio_output/mixer.c
@@ -136,7 +136,6 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
msg_Warn( p_mixer, "input PTS is out of range (%"PRId64"), "
"trashing", now - p_buffer->i_pts );
aout_BufferFree( aout_FifoPop( p_fifo ) );
- p_input->begin = NULL;
}
date_Set( &exact_start_date, p_buffer->i_pts );
@@ -164,7 +163,6 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
msg_Warn( p_mixer, "the mixer got a packet in the past (%"PRId64")",
start_date - prev_date );
aout_BufferFree( aout_FifoPop( p_fifo ) );
- p_input->begin = NULL;
p_buffer = p_fifo->p_first;
}
@@ -198,15 +196,11 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
const unsigned framesize = p_mixer->fmt.i_bytes_per_frame;
mtime_t i_buffer = (start_date - p_buffer->i_pts)
* framesize * p_mixer->fmt.i_rate / CLOCK_FREQ;
- if( p_input->begin == NULL )
- p_input->begin = p_buffer->p_buffer;
- ptrdiff_t bytes = p_input->begin - p_buffer->p_buffer;
- if( !((i_buffer + p_mixer->fmt.i_bytes_per_frame > bytes)
- && (i_buffer < p_mixer->fmt.i_bytes_per_frame + bytes)) )
+ if( !((i_buffer + framesize > 0) && (i_buffer < framesize)) )
{
msg_Warn( p_mixer, "mixer start is not output start (%"PRId64")",
- i_buffer - bytes );
+ i_buffer );
/* Round to the nearest multiple */
i_buffer /= p_mixer->fmt.i_bytes_per_frame;
@@ -220,7 +214,12 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
aout_unlock_output_fifo( p_aout );
goto giveup;
}
- p_input->begin = p_buffer->p_buffer + i_buffer;
+ p_buffer->p_buffer += i_buffer;
+ p_buffer->i_buffer -= i_buffer;
+ i_buffer /= framesize;
+ p_buffer->i_nb_samples -= i_buffer;
+ p_buffer->i_pts += i_buffer * CLOCK_FREQ / p_mixer->fmt.i_rate;
+ p_buffer->i_length -= i_buffer * CLOCK_FREQ / p_mixer->fmt.i_rate;
}
/* Build packet with adequate number of samples */
@@ -232,13 +231,10 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
goto giveup;
p_buffer->i_nb_samples = samples;
- uint8_t *p_in = p_input->begin;
- uint8_t *p_out = p_buffer->p_buffer;
-
- for( ;; )
+ for( uint8_t *p_out = p_buffer->p_buffer;; )
{
- size_t avail = p_fifo->p_first->i_nb_samples * framesize
- - (p_in - p_fifo->p_first->p_buffer);
+ uint8_t *p_in = p_fifo->p_first->p_buffer;
+ size_t avail = p_fifo->p_first->i_nb_samples * framesize;
if( avail < needed )
{
@@ -259,7 +255,12 @@ static int MixBuffer( aout_instance_t * p_aout, float volume )
else
{
vlc_memcpy( p_out, p_in, needed );
- p_input->begin = p_in + needed;
+ p_fifo->p_first->p_buffer += needed;
+ p_fifo->p_first->i_buffer -= needed;
+ needed /= framesize;
+ p_fifo->p_first->i_nb_samples -= needed;
+ p_fifo->p_first->i_pts += needed * CLOCK_FREQ / p_mixer->fmt.i_rate;
+ p_fifo->p_first->i_length -= needed * CLOCK_FREQ / p_mixer->fmt.i_rate;
break;
}
}
More information about the vlc-commits
mailing list