Commit 4c68266d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout_InputPlay: keep the input FIFO lock

This avoids racing with the audio output thread (if it exists) on the
end date of the mixer input FIFO.
parent cbb3e109
...@@ -542,14 +542,14 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -542,14 +542,14 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
p_input->i_last_input_rate = i_input_rate; p_input->i_last_input_rate = i_input_rate;
} }
mtime_t now = mdate();
/* We don't care if someone changes the start date behind our back after /* We don't care if someone changes the start date behind our back after
* this. We'll deal with that when pushing the buffer, and compensate * this. We'll deal with that when pushing the buffer, and compensate
* with the next incoming buffer. */ * with the next incoming buffer. */
aout_lock_input_fifos( p_aout ); aout_lock_input_fifos( p_aout );
start_date = aout_FifoNextStart( &p_input->mixer.fifo ); start_date = aout_FifoNextStart( &p_input->mixer.fifo );
aout_unlock_input_fifos( p_aout );
mtime_t now = mdate();
if ( start_date != 0 && start_date < now ) if ( start_date != 0 && start_date < now )
{ {
/* The decoder is _very_ late. This can only happen if the user /* The decoder is _very_ late. This can only happen if the user
...@@ -573,10 +573,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -573,10 +573,9 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
* can't present it anyway, so drop the buffer. */ * can't present it anyway, so drop the buffer. */
msg_Warn( p_aout, "PTS is out of range (%"PRId64"), dropping buffer", msg_Warn( p_aout, "PTS is out of range (%"PRId64"), dropping buffer",
now - p_buffer->i_pts ); now - p_buffer->i_pts );
inputDrop( p_input, p_buffer ); inputDrop( p_input, p_buffer );
inputResamplingStop( p_input ); inputResamplingStop( p_input );
return 0; goto out;
} }
/* If the audio drift is too big then it's not worth trying to resample /* If the audio drift is too big then it's not worth trying to resample
...@@ -592,9 +591,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -592,9 +591,7 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
{ {
msg_Warn( p_aout, "buffer way too early (%"PRId64"), clearing queue", msg_Warn( p_aout, "buffer way too early (%"PRId64"), clearing queue",
drift ); drift );
aout_lock_input_fifos( p_aout );
aout_FifoSet( &p_input->mixer.fifo, 0 ); aout_FifoSet( &p_input->mixer.fifo, 0 );
aout_unlock_input_fifos( p_aout );
if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE ) if ( p_input->i_resampling_type != AOUT_RESAMPLING_NONE )
msg_Warn( p_aout, "timing screwed, stopping resampling" ); msg_Warn( p_aout, "timing screwed, stopping resampling" );
inputResamplingStop( p_input ); inputResamplingStop( p_input );
...@@ -607,14 +604,14 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -607,14 +604,14 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
msg_Warn( p_aout, "buffer way too late (%"PRId64"), dropping buffer", msg_Warn( p_aout, "buffer way too late (%"PRId64"), dropping buffer",
drift ); drift );
inputDrop( p_input, p_buffer ); inputDrop( p_input, p_buffer );
return 0; goto out;
} }
#ifndef AOUT_PROCESS_BEFORE_CHEKS #ifndef AOUT_PROCESS_BEFORE_CHEKS
/* Run pre-filters. */ /* Run pre-filters. */
aout_FiltersPlay( p_input->pp_filters, p_input->i_nb_filters, &p_buffer ); aout_FiltersPlay( p_input->pp_filters, p_input->i_nb_filters, &p_buffer );
if( !p_buffer ) if( !p_buffer )
return 0; goto out;
#endif #endif
/* Run the resampler if needed. /* Run the resampler if needed.
...@@ -696,19 +693,18 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -696,19 +693,18 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
} }
if( !p_buffer ) if( !p_buffer )
return 0; goto out;
if( p_buffer->i_nb_samples <= 0 ) if( p_buffer->i_nb_samples <= 0 )
{ {
block_Release( p_buffer ); block_Release( p_buffer );
return 0; goto out;
} }
#endif #endif
/* Adding the start date will be managed by aout_FifoPush(). */ /* Adding the start date will be managed by aout_FifoPush(). */
p_buffer->i_pts = start_date; p_buffer->i_pts = start_date;
aout_lock_input_fifos( p_aout );
aout_FifoPush( &p_input->mixer.fifo, p_buffer ); aout_FifoPush( &p_input->mixer.fifo, p_buffer );
out:
aout_unlock_input_fifos( p_aout ); aout_unlock_input_fifos( p_aout );
return 0; return 0;
} }
......
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