Commit 72ab2078 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

input: split time and time-offset callbacks

There was no common code.
parent a30f9045
...@@ -47,6 +47,8 @@ static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -47,6 +47,8 @@ static int PositionCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void * ); vlc_value_t oldval, vlc_value_t newval, void * );
static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd, static int TimeCallback ( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void * ); vlc_value_t oldval, vlc_value_t newval, void * );
static int TimeOffsetCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void * );
static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd, static int ProgramCallback ( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void * ); vlc_value_t oldval, vlc_value_t newval, void * );
static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd, static int TitleCallback ( vlc_object_t *p_this, char const *psz_cmd,
...@@ -91,7 +93,7 @@ static const vlc_input_callback_t p_input_callbacks[] = ...@@ -91,7 +93,7 @@ static const vlc_input_callback_t p_input_callbacks[] =
CALLBACK( "position", PositionCallback ), CALLBACK( "position", PositionCallback ),
CALLBACK( "position-offset", PositionCallback ), CALLBACK( "position-offset", PositionCallback ),
CALLBACK( "time", TimeCallback ), CALLBACK( "time", TimeCallback ),
CALLBACK( "time-offset", TimeCallback ), CALLBACK( "time-offset", TimeOffsetCallback ),
CALLBACK( "bookmark", BookmarkCallback ), CALLBACK( "bookmark", BookmarkCallback ),
CALLBACK( "program", ProgramCallback ), CALLBACK( "program", ProgramCallback ),
CALLBACK( "title", TitleCallback ), CALLBACK( "title", TitleCallback ),
...@@ -611,17 +613,8 @@ static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -611,17 +613,8 @@ static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval, void *p_data )
{ {
input_thread_t *p_input = (input_thread_t*)p_this; input_thread_t *p_input = (input_thread_t*)p_this;
VLC_UNUSED(oldval); VLC_UNUSED(p_data); VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
if( !strcmp( psz_cmd, "time-offset" ) )
{
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
{
/* Update "position" for better intf behavour */ /* Update "position" for better intf behavour */
const mtime_t i_length = var_GetTime( p_input, "length" ); const mtime_t i_length = var_GetTime( p_input, "length" );
if( i_length > 0 && newval.i_time >= 0 && newval.i_time <= i_length ) if( i_length > 0 && newval.i_time >= 0 && newval.i_time <= i_length )
...@@ -637,9 +630,19 @@ static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -637,9 +630,19 @@ static int TimeCallback( vlc_object_t *p_this, char const *psz_cmd,
var_SetInteger( p_input, "intf-event", INPUT_EVENT_POSITION ); var_SetInteger( p_input, "intf-event", INPUT_EVENT_POSITION );
} }
/* */
input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval ); input_ControlPush( p_input, INPUT_CONTROL_SET_TIME, &newval );
} return VLC_SUCCESS;
}
static int TimeOffsetCallback( vlc_object_t *obj, char const *varname,
vlc_value_t prev, vlc_value_t cur, void *data )
{
VLC_UNUSED(varname); VLC_UNUSED(prev); VLC_UNUSED(data);
mtime_t i_time = var_GetTime( obj, "time" ) + cur.i_time;
if( i_time < 0 )
i_time = 0;
var_SetTime( obj, "time", i_time );
return VLC_SUCCESS; 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