Commit 6de1cefb authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove aout_mixer_input_t.begin

parent 402c5320
......@@ -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;
......
......@@ -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 );
}
......@@ -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" );
......
......@@ -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;
}
}
......
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