Commit 1b025556 authored by Laurent Aimar's avatar Laurent Aimar

Added a INPUT_CONTROL_RESTART_ES and use it in video_output.

This removes the need for suxor_thread_t.
parent f259d0a2
......@@ -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* */
......
......@@ -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 ) );
......
......@@ -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.
......
......@@ -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;
......
......@@ -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:
{
......
......@@ -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:
......
......@@ -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,
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment