-/*****************************************************************************
- * aout_Restart : re-open the output device and rebuild the input and output
- * pipelines
- *****************************************************************************
- * This function is used whenever the parameters of the output plug-in are
- * changed (eg. selecting S/PDIF or PCM).
- *****************************************************************************/
-static int aout_Restart( aout_instance_t * p_aout )
-{
- bool b_error = 0;
-
- aout_lock_mixer( p_aout );
-
- if( p_aout->p_input == NULL )
- {
- aout_unlock_mixer( p_aout );
- msg_Err( p_aout, "no decoder thread" );
- return -1;
- }
-
- aout_lock_input( p_aout, p_aout->p_input );
- aout_lock_input_fifos( p_aout );
- aout_InputDelete( p_aout, p_aout->p_input );
- aout_unlock_input_fifos( p_aout );
-
- /* Lock all inputs. */
- aout_lock_input_fifos( p_aout );
- aout_MixerDelete( p_aout );
-
- /* Re-open the output plug-in. */
- aout_OutputDelete( p_aout );
-
- /* FIXME: This function is notoriously dangerous/unsafe.
- * By the way, if OutputNew or MixerNew fails, we are totally screwed. */
- if ( aout_OutputNew( p_aout, &p_aout->p_input->input ) == -1 )
- {
- /* Release all locks and report the error. */
- vlc_mutex_unlock( &p_aout->p_input->lock );
- aout_unlock_input_fifos( p_aout );
- aout_unlock_mixer( p_aout );
- return -1;
- }
-
- if ( aout_MixerNew( p_aout ) == -1 )
- {
- aout_OutputDelete( p_aout );
- vlc_mutex_unlock( &p_aout->p_input->lock );
- aout_unlock_input_fifos( p_aout );
- aout_unlock_mixer( p_aout );
- return -1;
- }
-
- /* Re-open the input. */
- aout_input_t * p_input = p_aout->p_input;
- b_error |= aout_InputNew( p_aout, p_input, &p_input->request_vout );
- aout_unlock_input( p_aout, p_input );
-
- aout_unlock_input_fifos( p_aout );
- aout_unlock_mixer( p_aout );
-
- return b_error;
-}
-