+ MainLoop( p_input );
+
+ if( !p_input->b_eof && !p_input->b_error && p_input->input.b_eof )
+ {
+ /* We have finish to demux data but not to play them */
+ while( !p_input->b_die )
+ {
+ if( input_EsOutDecodersEmpty( p_input->p_es_out ) )
+ break;
+
+ msg_Dbg( p_input, "waiting decoder fifos to empty" );
+
+ msleep( INPUT_IDLE_SLEEP );
+ }
+
+ /* We have finished */
+ p_input->b_eof = VLC_TRUE;
+ }
+
+ /* Wait we are asked to die */
+ if( !p_input->b_die )
+ {
+ Error( p_input );
+ }
+
+ /* Clean up */
+ End( p_input );
+
+ return 0;
+}
+
+/*****************************************************************************
+ * RunAndClean: main thread loop
+ * This is the "just forget me" thread that spawns the input processing chain,
+ * reads the stream, cleans up and releases memory
+ *****************************************************************************/
+static int RunAndClean( input_thread_t *p_input )
+{
+ /* Signal that the thread is launched */
+ vlc_thread_ready( p_input );
+
+ if( Init( p_input, VLC_FALSE ) )
+ {
+ /* If we failed, just exit */
+ return 0;
+ }
+
+ MainLoop( p_input );
+
+ if( !p_input->b_eof && !p_input->b_error && p_input->input.b_eof )
+ {
+ /* We have finish to demux data but not to play them */
+ while( !p_input->b_die )
+ {
+ if( input_EsOutDecodersEmpty( p_input->p_es_out ) )
+ break;
+
+ msg_Dbg( p_input, "waiting decoder fifos to empty" );
+
+ msleep( INPUT_IDLE_SLEEP );
+ }
+ /* We have finished */
+ p_input->b_eof = VLC_TRUE;
+ }
+
+ /* Clean up */
+ End( p_input );
+
+ /* Release memory */
+ vlc_object_detach( p_input );
+ vlc_object_destroy( p_input );
+
+ return 0;
+}
+
+
+/*****************************************************************************
+ * Main loop: Fill buffers from access, and demux
+ *****************************************************************************/
+static void MainLoop( input_thread_t *p_input )
+{
+ int64_t i_intf_update = 0;