X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finput%2Fvar.c;h=781ce7c10287a12f2b16ce3517c067f04cba4e98;hb=6ff5a488a41ed665a285276dde65e28d751aa4e7;hp=3b67f6c1d410204acbbecb554c236862f7490240;hpb=584da504599d99acd7afe548b8b6ce9b9e2b1edb;p=vlc diff --git a/src/input/var.c b/src/input/var.c index 3b67f6c1d4..781ce7c102 100644 --- a/src/input/var.c +++ b/src/input/var.c @@ -132,12 +132,12 @@ void input_ControlVarInit ( input_thread_t *p_input ) /* State */ var_Create( p_input, "state", VLC_VAR_INTEGER ); - val.i_int = p_input->i_state; + val.i_int = p_input->p->i_state; var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL ); /* Rate */ - var_Create( p_input, "rate", VLC_VAR_INTEGER ); - val.i_int = p_input->p->i_rate; + var_Create( p_input, "rate", VLC_VAR_FLOAT ); + val.f_float = (float)INPUT_RATE_DEFAULT / (float)p_input->p->i_rate; var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL ); var_Create( p_input, "rate-slower", VLC_VAR_VOID ); @@ -216,6 +216,8 @@ void input_ControlVarInit ( input_thread_t *p_input ) text.psz_string = _("Subtitles Track"); var_Change( p_input, "spu-es", VLC_VAR_SETTEXT, &text, NULL ); + var_Create( p_input, "sub-margin", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + /* Special read only objects variables for intf */ var_Create( p_input, "bookmarks", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); @@ -223,6 +225,9 @@ void input_ControlVarInit ( input_thread_t *p_input ) val.i_time = 0; var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL ); + var_Create( p_input, "bit-rate", VLC_VAR_INTEGER ); + var_Create( p_input, "sample-rate", VLC_VAR_INTEGER ); + if( !p_input->b_preparsing ) { /* Special "intf-event" variable. */ @@ -241,7 +246,8 @@ void input_ControlVarInit ( input_thread_t *p_input ) *****************************************************************************/ void input_ControlVarStop( input_thread_t *p_input ) { - InputDelCallbacks( p_input, p_input_callbacks ); + if( !p_input->b_preparsing ) + InputDelCallbacks( p_input, p_input_callbacks ); if( p_input->p->i_title > 0 ) { @@ -353,7 +359,7 @@ void input_ControlVarNavigation( input_thread_t *p_input ) void input_ControlVarTitle( input_thread_t *p_input, int i_title ) { input_title_t *t = p_input->p->title[i_title]; - vlc_value_t val, text; + vlc_value_t text; int i; /* Create/Destroy command variables */ @@ -362,7 +368,7 @@ void input_ControlVarTitle( input_thread_t *p_input, int i_title ) var_Destroy( p_input, "next-chapter" ); var_Destroy( p_input, "prev-chapter" ); } - else if( var_Get( p_input, "next-chapter", &val ) != VLC_SUCCESS ) + else if( var_Type( p_input, "next-chapter" ) == 0 ) { var_Create( p_input, "next-chapter", VLC_VAR_VOID ); text.psz_string = _("Next chapter"); @@ -379,6 +385,7 @@ void input_ControlVarTitle( input_thread_t *p_input, int i_title ) var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL ); for( i = 0; i < t->i_seekpoint; i++ ) { + vlc_value_t val; val.i_int = i; if( t->seekpoint[i]->psz_name == NULL || @@ -443,9 +450,10 @@ void input_ConfigVarInit ( input_thread_t *p_input ) var_Create( p_input, "input-repeat", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - var_Create( p_input, "start-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - var_Create( p_input, "stop-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - var_Create( p_input, "run-time", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); + var_Create( p_input, "start-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT ); + var_Create( p_input, "stop-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT ); + var_Create( p_input, "run-time", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT ); + var_Create( p_input, "input-fast-seek", VLC_VAR_BOOL|VLC_VAR_DOINHERIT ); var_Create( p_input, "input-slave", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); @@ -485,6 +493,9 @@ void input_ConfigVarInit ( input_thread_t *p_input ) var_Create( p_input, "signal-strength", VLC_VAR_FLOAT ); var_SetFloat( p_input, "signal-strength", -1 ); + var_Create( p_input, "program-scrambled", VLC_VAR_BOOL ); + var_SetBool( p_input, "program-scrambled", false ); + var_Create( p_input, "cache", VLC_VAR_FLOAT ); var_SetFloat( p_input, "cache", 0.0 ); @@ -492,7 +503,6 @@ void input_ConfigVarInit ( input_thread_t *p_input ) var_Create( p_input, "input-record-native", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); /* */ - var_Create( p_input, "access-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "access", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "demux", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "stream-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); @@ -556,7 +566,9 @@ static int RateCallback( vlc_object_t *p_this, char const *psz_cmd, input_thread_t *p_input = (input_thread_t*)p_this; VLC_UNUSED(oldval); VLC_UNUSED(p_data); - /* Problem with this way: the "rate" variable is update after the input thread do the change */ + /* Problem with this way: the "rate" variable is updated after the + * input thread did the change */ + if( !strcmp( psz_cmd, "rate-slower" ) ) { input_ControlPush( p_input, INPUT_CONTROL_SET_RATE_SLOWER, NULL ); @@ -567,6 +579,7 @@ static int RateCallback( vlc_object_t *p_this, char const *psz_cmd, } else { + newval.i_int = INPUT_RATE_DEFAULT / newval.f_float; input_ControlPush( p_input, INPUT_CONTROL_SET_RATE, &newval ); } return VLC_SUCCESS; @@ -577,32 +590,32 @@ static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd, void *p_data ) { input_thread_t *p_input = (input_thread_t*)p_this; - vlc_value_t val, length; VLC_UNUSED(oldval); VLC_UNUSED(p_data); if( !strcmp( psz_cmd, "position-offset" ) ) { - input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION_OFFSET, &newval ); - - val.f_float = var_GetFloat( p_input, "position" ) + newval.f_float; - if( val.f_float < 0.0 ) val.f_float = 0.0; - if( val.f_float > 1.0 ) val.f_float = 1.0; - var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL ); + float f_position = var_GetFloat( p_input, "position" ) + newval.f_float; + if( f_position < 0.0 ) + f_position = 0.0; + else if( f_position > 1.0 ) + f_position = 1.0; + var_SetFloat( p_this, "position", f_position ); } else { - val.f_float = newval.f_float; - input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &newval ); - } + /* Update "length" for better intf behavour */ + const mtime_t i_length = var_GetTime( p_input, "length" ); + if( i_length > 0 && newval.f_float >= 0.0 && newval.f_float <= 1.0 ) + { + vlc_value_t val; - /* Update "position" for better intf behavour */ - var_Get( p_input, "length", &length ); - if( length.i_time > 0 && val.f_float >= 0.0 && val.f_float <= 1.0 ) - { - val.i_time = length.i_time * val.f_float; - var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL ); - } + val.i_time = i_length * newval.f_float; + var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL ); + } + /* */ + input_ControlPush( p_input, INPUT_CONTROL_SET_POSITION, &newval ); + } return VLC_SUCCESS; } @@ -610,31 +623,30 @@ static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { input_thread_t *p_input = (input_thread_t*)p_this; - vlc_value_t val, length; VLC_UNUSED(oldval); VLC_UNUSED(p_data); if( !strcmp( psz_cmd, "time-offset" ) ) { - input_ControlPush( p_input, INPUT_CONTROL_SET_TIME_OFFSET, &newval ); - val.i_time = var_GetTime( p_input, "time" ) + newval.i_time; - if( val.i_time < 0 ) val.i_time = 0; - /* TODO maybe test against i_length ? */ - var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL ); + mtime_t i_time = var_GetTime( p_input, "time" ) + newval.i_time; + if( i_time < 0 ) + i_time = 0; + var_SetTime( p_this, "time", i_time ); } else { - val.i_time = newval.i_time; - input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval ); - } + /* Update "position" for better intf behavour */ + const mtime_t i_length = var_GetTime( p_input, "length" ); + if( i_length > 0 && newval.i_time >= 0 && newval.i_time <= i_length ) + { + vlc_value_t val; - /* Update "position" for better intf behavour */ - var_Get( p_input, "length", &length ); - if( length.i_time > 0 && val.i_time >= 0 && val.i_time <= length.i_time ) - { - val.f_float = (double)val.i_time/(double)length.i_time; - var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL ); - } + val.f_float = (double)newval.i_time/(double)i_length; + var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL ); + } + /* */ + input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval ); + } return VLC_SUCCESS; } @@ -775,11 +787,6 @@ static int EsDelayCallback ( vlc_object_t *p_this, char const *psz_cmd, if( !strcmp( psz_cmd, "audio-delay" ) ) { - /* Change i_pts_delay to make sure es are decoded in time */ - if( newval.i_int < 0 || oldval.i_int < 0 ) - { - p_input->i_pts_delay -= newval.i_int - oldval.i_int; - } input_ControlPush( p_input, INPUT_CONTROL_SET_AUDIO_DELAY, &newval ); } else if( !strcmp( psz_cmd, "spu-delay" ) )