From 81f0e7f96af02985155dbbecf0059613203cf707 Mon Sep 17 00:00:00 2001 From: Christophe Massiot Date: Fri, 1 Oct 1999 22:05:33 +0000 Subject: [PATCH] =?UTF-8?q?*=20L'input=20devrait=20=EF=BF=BDtre=20capable?= =?UTF-8?q?=20de=20se=20fermer=20correctement=20apr=EF=BF=BDs=20une=20=20?= =?UTF-8?q?=20erreur=20(j'ai=20dit=20=5Fcapable=5F,=20hein,=20j'ai=20pas?= =?UTF-8?q?=20dit=20qu'elle=20le=20faisait)=20;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --Meuuh --- src/input/input.c | 103 ++++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 45 deletions(-) diff --git a/src/input/input.c b/src/input/input.c index 489892ac1f..3c704bb0b4 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -49,6 +49,7 @@ * Local prototypes ******************************************************************************/ static void input_Thread( input_thread_t *p_input ); +static void EndThread( input_thread_t *p_input ); static __inline__ int input_ReadPacket( input_thread_t *p_input ); static __inline__ void input_SortPacket( input_thread_t *p_input, ts_packet_t *ts_packet ); @@ -217,50 +218,11 @@ input_thread_t *input_CreateThread( input_cfg_t *p_cfg ) ******************************************************************************/ void input_DestroyThread( input_thread_t *p_input ) { - int i_es_loop; - intf_DbgMsg("input debug: requesting termination of input thread\n"); p_input->b_die = 1; /* ask thread to kill itself */ - pthread_join( p_input->thread_id, NULL ); /* wait until it's done */ - - (*p_input->p_clean)( p_input ); /* close input method */ - - /* Destroy all decoder threads. */ - for( i_es_loop = 0; i_es_loop < INPUT_MAX_ES; i_es_loop++ ) - { - if( p_input->pp_selected_es[i_es_loop] ) - { - switch( p_input->pp_selected_es[i_es_loop]->i_type ) - { - case MPEG1_VIDEO_ES: - case MPEG2_VIDEO_ES: - vdec_DestroyThread( (vdec_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) /*, NULL */ ); - break; - case MPEG1_AUDIO_ES: - case MPEG2_AUDIO_ES: - adec_DestroyThread( (adec_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) ); - break; - default: -#ifdef DEBUG - /* This should never happen. */ - intf_DbgMsg("input debug: unknown stream type ! (%d, %d)\n", - p_input->pp_selected_es[i_es_loop]->i_id, - p_input->pp_selected_es[i_es_loop]->i_type); -#endif - break; - } - } - else - { - /* pp_selected_es should not contain any hole. */ - break; - } - } - input_NetlistClean( p_input ); /* clean netlist */ - input_PsiClean( p_input ); /* clean PSI information */ - input_PcrClean( p_input ); /* clean PCR information */ - free( p_input ); /* free input_thread structure */ + /* Remove this as soon as the "status" flag is implemented */ + pthread_join( p_input->thread_id, NULL ); /* wait until it's done */ } #if 0 @@ -333,10 +295,61 @@ static void input_Thread( input_thread_t *p_input ) } /* Ohoh, we have to die as soon as possible. */ + EndThread( p_input ); + intf_DbgMsg("input debug: thread %p destroyed\n", p_input); pthread_exit( 0 ); } +/******************************************************************************* + * EndThread: end the input thread + *******************************************************************************/ +static void EndThread( input_thread_t *p_input ) +{ + int i_es_loop; + + (*p_input->p_clean)( p_input ); /* close input method */ + + /* Destroy all decoder threads. */ + for( i_es_loop = 0; i_es_loop < INPUT_MAX_ES; i_es_loop++ ) + { + if( p_input->pp_selected_es[i_es_loop] ) + { + switch( p_input->pp_selected_es[i_es_loop]->i_type ) + { + case MPEG1_VIDEO_ES: + case MPEG2_VIDEO_ES: + vdec_DestroyThread( (vdec_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) /*, NULL */ ); + break; + case MPEG1_AUDIO_ES: + case MPEG2_AUDIO_ES: + adec_DestroyThread( (adec_thread_t*)(p_input->pp_selected_es[i_es_loop]->p_dec) ); + break; + default: +#ifdef DEBUG + /* This should never happen. */ + intf_DbgMsg("input debug: unknown stream type ! (%d, %d)\n", + p_input->pp_selected_es[i_es_loop]->i_id, + p_input->pp_selected_es[i_es_loop]->i_type); +#endif + break; + } + } + else + { + /* pp_selected_es should not contain any hole. */ + break; + } + } + + input_NetlistClean( p_input ); /* clean netlist */ + input_PsiClean( p_input ); /* clean PSI information */ + input_PcrClean( p_input ); /* clean PCR information */ + free( p_input ); /* free input_thread structure */ + + intf_DbgMsg("input debug: EndThread(%p)\n", p_input); +} + /******************************************************************************* * input_ReadPacket: reads a packet from the network or the file *******************************************************************************/ @@ -392,10 +405,10 @@ static __inline__ int input_ReadPacket( input_thread_t *p_input ) INPUT_TS_READ_ONCE ); if( i_packet_size == (-1) ) { - intf_DbgMsg("Read packet %d %p %d %d\n", i_base_index, - &p_input->netlist.p_ts_free[i_base_index], - p_input->netlist.i_ts_start, - p_input->netlist.i_ts_end); +// intf_DbgMsg("Read packet %d %p %d %d\n", i_base_index, +// &p_input->netlist.p_ts_free[i_base_index], +// p_input->netlist.i_ts_start, +// p_input->netlist.i_ts_end); intf_ErrMsg("input error: readv() failed (%s)\n", strerror(errno)); return( -1 ); } -- GitLab