- /* We barfed -- exit nicely */
- module_Unneed( p_input->p_input_module );
- return( -1 );
- }
-
- p_input->pf_init( p_input );
-
- if( p_input->b_error )
- {
- /* We barfed -- exit nicely */
- CloseThread( p_input );
- module_Unneed( p_input->p_input_module );
- return( -1 );
- }
-
- *p_input->pi_status = THREAD_READY;
-
- return( 0 );
-}
-
-/*****************************************************************************
- * ErrorThread: RunThread() error loop
- *****************************************************************************
- * This function is called when an error occured during thread main's loop.
- *****************************************************************************/
-static void ErrorThread( input_thread_t *p_input )
-{
- while( !p_input->b_die )
- {
- /* Sleep a while */
- msleep( INPUT_IDLE_SLEEP );
- }
-}
-
-/*****************************************************************************
- * EndThread: end the input thread
- *****************************************************************************/
-static void EndThread( input_thread_t * p_input )
-{
- int * pi_status; /* thread status */
-
- /* Store status */
- pi_status = p_input->pi_status;
- *pi_status = THREAD_END;
-
- if( p_main->b_stats )
- {
-#ifdef HAVE_SYS_TIMES_H
- /* Display statistics */
- struct tms cpu_usage;
- times( &cpu_usage );
-
- intf_StatMsg( "input stats: %d loops consuming user: %d, system: %d",
- p_input->c_loops,
- cpu_usage.tms_utime, cpu_usage.tms_stime );
-#else
- intf_StatMsg( "input stats: %d loops", p_input->c_loops );
-#endif
-
- input_DumpStream( p_input );
- }
-
- /* Free all ES and destroy all decoder threads */
- input_EndStream( p_input );
-
- /* Free demultiplexer's data */
- p_input->pf_end( p_input );
-
- /* Close the input method */
- CloseThread( p_input );
-
- /* Release modules */
- module_Unneed( p_input->p_input_module );
-}
-
-/*****************************************************************************
- * CloseThread: close the target
- *****************************************************************************/
-static void CloseThread( input_thread_t * p_input )
-{
-#define f p_input->p_input_module->p_functions->input.functions.input
-
-#if !defined( SYS_BEOS ) && !defined( SYS_NTO )
- /* Close stream */
- if( ( strlen( p_input->p_source ) > 10
- && !strncasecmp( p_input->p_source, "udpstream:", 10 ) )
- || ( strlen( p_input->p_source ) > 4
- && !strncasecmp( p_input->p_source, "udp:", 4 ) ) )
- {
- NetworkClose( p_input );
- }
- else if( ( strlen( p_input->p_source ) > 5 )
- && !strncasecmp( p_input->p_source, "http:", 5 ) )
- {
- NetworkClose( p_input );
- }
- else
-#endif
- if( ( ( strlen( p_input->p_source ) > 4 )
- && !strncasecmp( p_input->p_source, "dvd:", 4 ) )
- || TestMethod( INPUT_METHOD_VAR, "dvd" ) )
- {
- f.pf_close( p_input );
- }
- else if( ( strlen( p_input->p_source ) > 4 )
- && !strncasecmp( p_input->p_source, "vlc:", 4 ) )
- {
- f.pf_close( p_input );