return NULL;
p_input->b_error = true;
- p_input->b_paused = false;
- p_input->i_pause_date = 0;
aout_FormatPrepare( p_format );
/* We can only be called by the decoder, so no need to lock
* p_input->lock. */
+ aout_owner_t *owner = aout_owner(p_aout);
aout_lock( p_aout );
- assert( p_aout->p_input == NULL );
- p_aout->p_input = p_input;
+ assert (owner->input == NULL);
var_Destroy( p_aout, "audio-device" );
var_Destroy( p_aout, "audio-channels" );
/* Recreate the output using the new format. */
if( aout_OutputNew( p_aout, p_format ) < 0 )
-#warning Input without output and mixer = bad idea.
- goto out;
+ goto error;
- assert( p_aout->p_mixer == NULL );
- if( aout_MixerNew( p_aout ) == -1 )
+ assert (owner->volume.mixer == NULL);
+ owner->volume.mixer = aout_MixerNew (p_aout, owner->mixer_format.i_format);
+ if (owner->volume.mixer == NULL)
{
aout_OutputDelete( p_aout );
-#warning Memory leak.
- p_input = NULL;
- goto out;
+ goto error;
}
+ owner->input = p_input;
aout_InputNew( p_aout, p_input, p_request_vout );
-out:
aout_unlock( p_aout );
return p_input;
+error:
+ aout_unlock( p_aout );
+ free( p_input );
+ return NULL;
}
/*****************************************************************************
*****************************************************************************/
void aout_DecDelete( audio_output_t * p_aout, aout_input_t * p_input )
{
+ aout_owner_t *owner = aout_owner (p_aout);
+ struct audio_mixer *mixer;
+
aout_lock( p_aout );
/* Remove the input. */
- assert( p_input == p_aout->p_input ); /* buggy decoder? */
- p_aout->p_input = NULL;
+ assert (owner->input == p_input); /* buggy decoder? */
+ owner->input = NULL;
aout_InputDelete( p_aout, p_input );
aout_OutputDelete( p_aout );
- aout_MixerDelete( p_aout );
+ mixer = owner->volume.mixer;
+ owner->volume.mixer = NULL;
var_Destroy( p_aout, "audio-device" );
var_Destroy( p_aout, "audio-channels" );
aout_unlock( p_aout );
+
+ aout_MixerDelete (mixer);
free( p_input );
}
int aout_DecPlay( audio_output_t * p_aout, aout_input_t * p_input,
aout_buffer_t * p_buffer, int i_input_rate )
{
+ aout_owner_t *owner = aout_owner (p_aout);
assert( i_input_rate >= INPUT_RATE_DEFAULT / AOUT_MAX_INPUT_RATE &&
i_input_rate <= INPUT_RATE_DEFAULT * AOUT_MAX_INPUT_RATE );
-
assert( p_buffer->i_pts > 0 );
p_buffer->i_length = (mtime_t)p_buffer->i_nb_samples * 1000000
return -1;
}
+ /* Input */
aout_InputCheckAndRestart( p_aout, p_input );
- aout_InputPlay( p_aout, p_input, p_buffer, i_input_rate );
- /* Run the mixer if it is able to run. */
- aout_MixerRun( p_aout, p_aout->mixer_multiplier );
+ p_buffer = aout_InputPlay( p_aout, p_input, p_buffer, i_input_rate );
+
+ if( p_buffer != NULL )
+ {
+ /* Mixer */
+ float amp = owner->volume.multiplier * p_input->multiplier;
+ aout_MixerRun (owner->volume.mixer, p_buffer, amp);
+
+ /* Output */
+ aout_OutputPlay( p_aout, p_buffer );
+ }
+
aout_unlock( p_aout );
return 0;
}
void aout_DecChangePause( audio_output_t *p_aout, aout_input_t *p_input, bool b_paused, mtime_t i_date )
{
- mtime_t i_duration = 0;
+ aout_owner_t *owner = aout_owner (p_aout);
aout_lock( p_aout );
- assert( p_aout->p_input == p_input );
- assert( !p_input->b_paused || !b_paused );
- if( p_input->b_paused )
- {
- i_duration = i_date - p_input->i_pause_date;
- }
- p_input->b_paused = b_paused;
- p_input->i_pause_date = i_date;
+ assert (owner->input == p_input);
- if( i_duration != 0 )
- {
- for( aout_buffer_t *p = p_input->mixer.fifo.p_first; p != NULL; p = p->p_next )
- {
- p->i_pts += i_duration;
- }
- }
+ /* XXX: Should the input date be offset by the pause duration instead? */
+ date_Set (&p_input->date, VLC_TS_INVALID);
aout_OutputPause( p_aout, b_paused, i_date );
aout_unlock( p_aout );
}
void aout_DecFlush( audio_output_t *p_aout, aout_input_t *p_input )
{
aout_lock( p_aout );
- aout_FifoSet( &p_input->mixer.fifo, 0 );
+ date_Set (&p_input->date, VLC_TS_INVALID);
+ aout_OutputFlush( p_aout, false );
aout_unlock( p_aout );
}
mtime_t end_date;
aout_lock( p_aout );
- end_date = aout_FifoNextStart( &p_input->mixer.fifo );
+ /* FIXME: tell output to drain */
+ end_date = date_Get (&p_input->date);
aout_unlock( p_aout );
- return end_date <= mdate();
+ return end_date == VLC_TS_INVALID || end_date <= mdate();
}