From 1b025556e3277cc727d1e70c7c55a2a0192b4d1a Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Thu, 28 Aug 2008 14:30:02 +0200 Subject: [PATCH] Added a INPUT_CONTROL_RESTART_ES and use it in video_output. This removes the need for suxor_thread_t. --- include/vlc_es_out.h | 1 + include/vlc_input.h | 3 ++ include/vlc_plugin.h | 4 +- src/input/control.c | 5 +++ src/input/es_out.c | 74 ++++++++++++++++----------------- src/input/input.c | 8 +++- src/input/input_internal.h | 1 + src/video_output/video_output.c | 44 +------------------- 8 files changed, 56 insertions(+), 84 deletions(-) diff --git a/include/vlc_es_out.h b/include/vlc_es_out.h index bd654484a9..8fe2d4503f 100644 --- a/include/vlc_es_out.h +++ b/include/vlc_es_out.h @@ -55,6 +55,7 @@ enum es_out_query_e /* set ES selected for the es category (audio/video/spu) */ ES_OUT_SET_ES, /* arg1= es_out_id_t* */ + ES_OUT_RESTART_ES, /* arg1= es_out_id_t* */ /* set 'default' tag on ES (copied across from container) */ ES_OUT_SET_DEFAULT, /* arg1= es_out_id_t* */ diff --git a/include/vlc_input.h b/include/vlc_input.h index f9f56781f9..63debca1f0 100644 --- a/include/vlc_input.h +++ b/include/vlc_input.h @@ -529,6 +529,9 @@ enum input_query_e /* On the fly record while playing */ INPUT_SET_RECORD_STATE, /* arg1=bool res=can fail */ INPUT_GET_RECORD_STATE, /* arg1=bool* res=can fail */ + + /* ES */ + INPUT_RESTART_ES, /* arg1=int (-AUDIO/VIDEO/SPU_ES for the whole category) */ }; VLC_EXPORT( int, input_vaControl,( input_thread_t *, int i_query, va_list ) ); diff --git a/include/vlc_plugin.h b/include/vlc_plugin.h index 771241eedd..b32841c811 100644 --- a/include/vlc_plugin.h +++ b/include/vlc_plugin.h @@ -39,8 +39,8 @@ /** * Current plugin ABI version */ -# define MODULE_SYMBOL 1_0_0a -# define MODULE_SUFFIX "__1_0_0a" +# define MODULE_SYMBOL 1_0_0b +# define MODULE_SUFFIX "__1_0_0b" /***************************************************************************** * Add a few defines. You do not want to read this section. Really. diff --git a/src/input/control.c b/src/input/control.c index 1e286f8b41..ed3d12ec72 100644 --- a/src/input/control.c +++ b/src/input/control.c @@ -609,6 +609,11 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args ) *pb_bool = var_GetBool( p_input, "record" ); return VLC_SUCCESS; + case INPUT_RESTART_ES: + val.i_int = (int)va_arg( args, int ); + input_ControlPush( p_input, INPUT_CONTROL_RESTART_ES, &val ); + return VLC_SUCCESS; + default: msg_Err( p_input, "unknown query in input_vaControl" ); return VLC_EGENERIC; diff --git a/src/input/es_out.c b/src/input/es_out.c index fab5fafb84..b105356793 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -1769,50 +1769,26 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args ) return VLC_SUCCESS; case ES_OUT_SET_ES: + case ES_OUT_RESTART_ES: + { + int i_cat; + es = (es_out_id_t*) va_arg( args, es_out_id_t * ); - /* Special case NULL, NULL+i_cat */ + if( es == NULL ) - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( EsIsSelected( p_sys->es[i] ) ) - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } + i_cat = UNKNOWN_ES; else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) ) - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->fmt.i_cat == AUDIO_ES && - EsIsSelected( p_sys->es[i] ) ) - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } + i_cat = AUDIO_ES; else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) ) - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->fmt.i_cat == VIDEO_ES && - EsIsSelected( p_sys->es[i] ) ) - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } + i_cat = VIDEO_ES; else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) ) - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->fmt.i_cat == SPU_ES && - EsIsSelected( p_sys->es[i] ) ) - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } + i_cat = SPU_ES; else + i_cat = -1; + + for( i = 0; i < p_sys->i_es; i++ ) { - for( i = 0; i < p_sys->i_es; i++ ) + if( i_cat == -1 ) { if( es == p_sys->es[i] ) { @@ -1820,13 +1796,37 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args ) break; } } + else + { + if( i_cat == UNKNOWN_ES || p_sys->es[i]->fmt.i_cat == i_cat ) + { + if( EsIsSelected( p_sys->es[i] ) ) + { + if( i_query == ES_OUT_RESTART_ES ) + { + if( p_sys->es[i]->p_dec ) + { + EsDestroyDecoder( out, p_sys->es[i] ); + EsCreateDecoder( out, p_sys->es[i] ); + } + } + else + { + EsUnselect( out, p_sys->es[i], + p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); + } + } + } + } } + if( i_query == ES_OUT_SET_ES ) { vlc_event_t event; event.type = vlc_InputSelectedStreamChanged; vlc_event_send( &p_sys->p_input->p->event_manager, &event ); } return VLC_SUCCESS; + } case ES_OUT_SET_DEFAULT: { diff --git a/src/input/input.c b/src/input/input.c index f0d7e27f91..2ecc16021a 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -1747,8 +1747,12 @@ static bool Control( input_thread_t *p_input, int i_type, case INPUT_CONTROL_SET_ES: /* No need to force update, es_out does it if needed */ es_out_Control( p_input->p->p_es_out, ES_OUT_SET_ES, - input_EsOutGetFromID( p_input->p->p_es_out, - val.i_int ) ); + input_EsOutGetFromID( p_input->p->p_es_out, val.i_int ) ); + break; + + case INPUT_CONTROL_RESTART_ES: + es_out_Control( p_input->p->p_es_out, ES_OUT_RESTART_ES, + input_EsOutGetFromID( p_input->p->p_es_out, val.i_int ) ); break; case INPUT_CONTROL_SET_AUDIO_DELAY: diff --git a/src/input/input_internal.h b/src/input/input_internal.h index 69545ff0b1..b3e57165f5 100644 --- a/src/input/input_internal.h +++ b/src/input/input_internal.h @@ -189,6 +189,7 @@ enum input_control_e INPUT_CONTROL_SET_BOOKMARK, INPUT_CONTROL_SET_ES, + INPUT_CONTROL_RESTART_ES, INPUT_CONTROL_SET_AUDIO_DELAY, INPUT_CONTROL_SET_SPU_DELAY, diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index bb76692a61..6be98a6d3d 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -1370,35 +1370,6 @@ static void PictureHeapFixRgb( picture_heap_t *p_heap ) VideoFormatExportRgb( &fmt, p_heap ); } -/***************************************************************************** - * Helper thread for object variables callbacks. - * Only used to avoid deadlocks when using the video embedded mode. - *****************************************************************************/ -typedef struct suxor_thread_t -{ - VLC_COMMON_MEMBERS - input_thread_t *p_input; - -} suxor_thread_t; - -static void* SuxorRestartVideoES( vlc_object_t * p_vlc_t ) -{ - suxor_thread_t *p_this = (suxor_thread_t *) p_vlc_t; - int canc = vlc_savecancel (); - /* Now restart current video stream */ - int val = var_GetInteger( p_this->p_input, "video-es" ); - if( val >= 0 ) - { - var_SetInteger( p_this->p_input, "video-es", -VIDEO_ES ); - var_SetInteger( p_this->p_input, "video-es", val ); - } - - vlc_object_release( p_this->p_input ); - vlc_object_release( p_this ); - vlc_restorecancel (canc); - return NULL; -} - /***************************************************************************** * object variables callbacks: a bunch of object variables are used by the * interfaces to interact with the vout. @@ -1484,20 +1455,7 @@ static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd, var_Set( p_input, "vout-filter", val ); /* Now restart current video stream */ - var_Get( p_input, "video-es", &val ); - if( val.i_int >= 0 ) - { - static const char typename[] = "kludge"; - suxor_thread_t *p_suxor = - vlc_custom_create( p_vout, sizeof(suxor_thread_t), - VLC_OBJECT_GENERIC, typename ); - p_suxor->p_input = p_input; - p_vout->b_filter_change = true; - vlc_object_yield( p_input ); - vlc_thread_create( p_suxor, "suxor", SuxorRestartVideoES, - VLC_THREAD_PRIORITY_LOW, false ); - } - + input_Control( p_input, INPUT_RESTART_ES, -VIDEO_ES ); vlc_object_release( p_input ); return VLC_SUCCESS; -- 2.39.5