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

aout: recycle output and pipeline if possible

The decoder thread drains the output at end of stream. So there is
always an underflow between consequent audio inputs.
Thus this does not provide gap-less audio as is.
parent 92ed0b95
...@@ -206,6 +206,7 @@ bool aout_DecIsEmpty(audio_output_t *); ...@@ -206,6 +206,7 @@ bool aout_DecIsEmpty(audio_output_t *);
void aout_InputRequestRestart(audio_output_t *); void aout_InputRequestRestart(audio_output_t *);
void aout_RequestRestart(audio_output_t *); void aout_RequestRestart(audio_output_t *);
void aout_Shutdown (audio_output_t *);
/* Audio output locking */ /* Audio output locking */
......
...@@ -170,6 +170,10 @@ audio_output_t *aout_New( vlc_object_t * p_parent ) ...@@ -170,6 +170,10 @@ audio_output_t *aout_New( vlc_object_t * p_parent )
void aout_Destroy (audio_output_t *aout) void aout_Destroy (audio_output_t *aout)
{ {
aout_owner_t *owner = aout_owner (aout);
if (owner->module != NULL)
aout_Shutdown (aout);
vlc_object_release (aout); vlc_object_release (aout);
} }
......
...@@ -81,9 +81,27 @@ int aout_DecNew( audio_output_t *p_aout, ...@@ -81,9 +81,27 @@ int aout_DecNew( audio_output_t *p_aout,
} }
aout_owner_t *owner = aout_owner(p_aout); aout_owner_t *owner = aout_owner(p_aout);
/* Calling decoder is responsible for serializing aout_DecNew() and
* aout_DecDelete(). So no need to lock to _read_ those properties. */
if (owner->module != NULL) /* <- output exists */
{ /* Check if we can recycle the existing output and pipelines */
if (AOUT_FMTS_IDENTICAL(&owner->input_format, p_format))
return 0;
/* TODO? If the new input format is closer to the output format than
* the old input format was, then the output could be recycled. The
* input pipeline however would need to be restarted. */
/* No recycling: delete everything and restart from scratch */
aout_Shutdown (p_aout);
}
int ret = -1; int ret = -1;
/* TODO: reduce lock scope depending on decoder's real need */
aout_lock( p_aout ); aout_lock( p_aout );
assert (owner->module == NULL);
/* Create the audio output stream */ /* Create the audio output stream */
var_Destroy( p_aout, "audio-device" ); var_Destroy( p_aout, "audio-device" );
...@@ -119,10 +137,10 @@ error: ...@@ -119,10 +137,10 @@ error:
return ret; return ret;
} }
/***************************************************************************** /**
* aout_DecDelete : delete a decoder * Stops all plugins involved in the audio output.
*****************************************************************************/ */
void aout_DecDelete( audio_output_t * p_aout ) void aout_Shutdown (audio_output_t *p_aout)
{ {
aout_owner_t *owner = aout_owner (p_aout); aout_owner_t *owner = aout_owner (p_aout);
aout_input_t *input; aout_input_t *input;
...@@ -150,6 +168,18 @@ void aout_DecDelete( audio_output_t * p_aout ) ...@@ -150,6 +168,18 @@ void aout_DecDelete( audio_output_t * p_aout )
free (input); free (input);
} }
/**
* Stops the decoded audio input.
* @note Due to output recycling, this function is esssentially a stub.
*/
void aout_DecDelete (audio_output_t *aout)
{
aout_owner_t *owner = aout_owner (aout);
assert (owner->module != NULL);
(void) owner;
}
#define AOUT_RESTART_OUTPUT 1 #define AOUT_RESTART_OUTPUT 1
#define AOUT_RESTART_INPUT 2 #define AOUT_RESTART_INPUT 2
static void aout_CheckRestart (audio_output_t *aout) static void aout_CheckRestart (audio_output_t *aout)
......
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