Commit 926aa46c authored by Gildas Bazin's avatar Gildas Bazin

* src/input/input.c:

  + fixed typo in INPUT_CONTROL_SET_SEEKPOINT_NEXT.
  + a few coding style changes.
* input/var.c:
  + use the descriptive name for titles/chapters if available.
parent d70d3a22
...@@ -366,7 +366,8 @@ static int Run( input_thread_t *p_input ) ...@@ -366,7 +366,8 @@ static int Run( input_thread_t *p_input )
} }
else else
{ {
msg_Dbg( p_input, "repeating the same input (%d)", repeat.i_int ); msg_Dbg( p_input, "repeating the same input (%d)",
repeat.i_int );
if( repeat.i_int > 0 ) if( repeat.i_int > 0 )
{ {
repeat.i_int--; repeat.i_int--;
...@@ -424,18 +425,21 @@ static int Run( input_thread_t *p_input ) ...@@ -424,18 +425,21 @@ static int Run( input_thread_t *p_input )
double f_pos; double f_pos;
int64_t i_time, i_length; int64_t i_time, i_length;
/* update input status variables */ /* update input status variables */
if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_POSITION, &f_pos ) ) if( !demux2_Control( p_input->input.p_demux,
DEMUX_GET_POSITION, &f_pos ) )
{ {
val.f_float = (float)f_pos; val.f_float = (float)f_pos;
var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
} }
if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_TIME, &i_time ) ) if( !demux2_Control( p_input->input.p_demux,
DEMUX_GET_TIME, &i_time ) )
{ {
p_input->i_time = i_time; p_input->i_time = i_time;
val.i_time = i_time; val.i_time = i_time;
var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
} }
if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_LENGTH, &i_length ) ) if( !demux2_Control( p_input->input.p_demux,
DEMUX_GET_LENGTH, &i_length ) )
{ {
vlc_value_t old_val; vlc_value_t old_val;
var_Get( p_input, "length", &old_val ); var_Get( p_input, "length", &old_val );
...@@ -570,7 +574,8 @@ static int Init( input_thread_t * p_input ) ...@@ -570,7 +574,8 @@ static int Init( input_thread_t * p_input )
/* Load master infos */ /* Load master infos */
/* Init length */ /* Init length */
if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_LENGTH, &val.i_time ) && val.i_time > 0 ) if( !demux2_Control( p_input->input.p_demux, DEMUX_GET_LENGTH,
&val.i_time ) && val.i_time > 0 )
{ {
var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL ); var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
/* TODO update playlist meta data */ /* TODO update playlist meta data */
...@@ -646,7 +651,8 @@ static int Init( input_thread_t * p_input ) ...@@ -646,7 +651,8 @@ static int Init( input_thread_t * p_input )
if( count.i_int < list.p_list->i_count ) if( count.i_int < list.p_list->i_count )
{ {
input_ControlPush( p_input, INPUT_CONTROL_SET_ES, &list.p_list->p_values[count.i_int] ); input_ControlPush( p_input, INPUT_CONTROL_SET_ES,
&list.p_list->p_values[count.i_int] );
} }
var_Change( p_input, "spu-es", VLC_VAR_FREELIST, &list, NULL ); var_Change( p_input, "spu-es", VLC_VAR_FREELIST, &list, NULL );
} }
...@@ -931,7 +937,8 @@ error: ...@@ -931,7 +937,8 @@ error:
{ {
subtitle_demux_t *p_sub; subtitle_demux_t *p_sub;
int i; int i;
char **tmp = subtitles_Detect( p_input, val1.psz_string, p_input->psz_name ); char **tmp = subtitles_Detect( p_input, val1.psz_string,
p_input->psz_name );
char **tmp2 = tmp; char **tmp2 = tmp;
for( i = 0; *tmp2 != NULL; i++ ) for( i = 0; *tmp2 != NULL; i++ )
{ {
...@@ -1081,7 +1088,8 @@ static void ControlReduce( input_thread_t *p_input ) ...@@ -1081,7 +1088,8 @@ static void ControlReduce( input_thread_t *p_input )
const int i_ct = p_input->control[i].i_type; const int i_ct = p_input->control[i].i_type;
/* XXX We can't merge INPUT_CONTROL_SET_ES */ /* XXX We can't merge INPUT_CONTROL_SET_ES */
msg_Dbg( p_input, "[%d/%d] l=%d c=%d", i, p_input->i_control, i_lt, i_ct ); msg_Dbg( p_input, "[%d/%d] l=%d c=%d", i, p_input->i_control,
i_lt, i_ct );
if( i_lt == i_ct && if( i_lt == i_ct &&
( i_ct == INPUT_CONTROL_SET_STATE || ( i_ct == INPUT_CONTROL_SET_STATE ||
i_ct == INPUT_CONTROL_SET_RATE || i_ct == INPUT_CONTROL_SET_RATE ||
...@@ -1111,7 +1119,8 @@ static void ControlReduce( input_thread_t *p_input ) ...@@ -1111,7 +1119,8 @@ static void ControlReduce( input_thread_t *p_input )
} }
} }
static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val ) static vlc_bool_t Control( input_thread_t *p_input, int i_type,
vlc_value_t val )
{ {
vlc_bool_t b_force_update = VLC_FALSE; vlc_bool_t b_force_update = VLC_FALSE;
...@@ -1140,15 +1149,17 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val ...@@ -1140,15 +1149,17 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val
else else
{ {
/* Should not fail */ /* Should not fail */
demux2_Control( p_input->input.p_demux, DEMUX_GET_POSITION, &f_pos ); demux2_Control( p_input->input.p_demux,
DEMUX_GET_POSITION, &f_pos );
f_pos += val.f_float; f_pos += val.f_float;
} }
if( f_pos < 0.0 ) f_pos = 0.0; if( f_pos < 0.0 ) f_pos = 0.0;
if( f_pos > 1.0 ) f_pos = 1.0; if( f_pos > 1.0 ) f_pos = 1.0;
if( demux2_Control( p_input->input.p_demux, DEMUX_SET_POSITION, f_pos ) ) if( demux2_Control( p_input->input.p_demux, DEMUX_SET_POSITION,
f_pos ) )
{ {
msg_Err( p_input, "INPUT_CONTROL_SET_POSITION(_OFFSET) %2.1f%% failed", msg_Err( p_input, "INPUT_CONTROL_SET_POSITION(_OFFSET) "
f_pos * 100 ); "%2.1f%% failed", f_pos * 100 );
} }
else else
{ {
...@@ -1198,8 +1209,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val ...@@ -1198,8 +1209,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val
} }
if( i_ret ) if( i_ret )
{ {
msg_Err( p_input, "INPUT_CONTROL_SET_TIME(_OFFSET) %lld failed", msg_Err( p_input, "INPUT_CONTROL_SET_TIME(_OFFSET) "I64Fd
i_time ); " failed", i_time );
} }
else else
{ {
...@@ -1243,7 +1254,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val ...@@ -1243,7 +1254,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val
/* Reset clock */ /* Reset clock */
es_out_Control( p_input->p_es_out, ES_OUT_RESET_PCR ); es_out_Control( p_input->p_es_out, ES_OUT_RESET_PCR );
} }
else if( val.i_int == PAUSE_S && p_input->i_state == PLAYING_S && p_input->b_can_pause ) else if( val.i_int == PAUSE_S && p_input->i_state == PLAYING_S &&
p_input->b_can_pause )
{ {
int i_ret; int i_ret;
if( p_input->input.p_access ) if( p_input->input.p_access )
...@@ -1307,7 +1319,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val ...@@ -1307,7 +1319,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val
i_rate = INPUT_RATE_MAX; i_rate = INPUT_RATE_MAX;
} }
if( i_rate != INPUT_RATE_DEFAULT && if( i_rate != INPUT_RATE_DEFAULT &&
( !p_input->b_can_pace_control || !p_input->b_out_pace_control ) ) ( !p_input->b_can_pace_control ||
!p_input->b_out_pace_control ) )
{ {
msg_Dbg( p_input, "cannot change rate" ); msg_Dbg( p_input, "cannot change rate" );
i_rate = INPUT_RATE_DEFAULT; i_rate = INPUT_RATE_DEFAULT;
...@@ -1338,8 +1351,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val ...@@ -1338,8 +1351,9 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val
case INPUT_CONTROL_SET_ES: case INPUT_CONTROL_SET_ES:
/* No need to force update, es_out does it if needed */ /* No need to force update, es_out does it if needed */
es_out_Control( p_input->p_es_out, es_out_Control( p_input->p_es_out, ES_OUT_SET_ES,
ES_OUT_SET_ES, input_EsOutGetFromID( p_input->p_es_out, val.i_int ) ); input_EsOutGetFromID( p_input->p_es_out,
val.i_int ) );
break; break;
case INPUT_CONTROL_SET_AUDIO_DELAY: case INPUT_CONTROL_SET_AUDIO_DELAY:
...@@ -1415,13 +1429,13 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val ...@@ -1415,13 +1429,13 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val
if( i_type == INPUT_CONTROL_SET_SEEKPOINT_PREV ) if( i_type == INPUT_CONTROL_SET_SEEKPOINT_PREV )
i_seekpoint = p_demux->info.i_seekpoint - 1; i_seekpoint = p_demux->info.i_seekpoint - 1;
else if( i_type == INPUT_CONTROL_SET_TITLE_NEXT ) else if( i_type == INPUT_CONTROL_SET_SEEKPOINT_NEXT )
i_seekpoint = p_demux->info.i_seekpoint + 1; i_seekpoint = p_demux->info.i_seekpoint + 1;
else else
i_seekpoint = val.i_int; i_seekpoint = val.i_int;
if( i_seekpoint >= 0 && if( i_seekpoint >= 0 && i_seekpoint <
i_seekpoint < p_input->input.title[p_demux->info.i_title]->i_seekpoint ) p_input->input.title[p_demux->info.i_title]->i_seekpoint )
{ {
demux2_Control( p_demux, DEMUX_SET_SEEKPOINT, i_seekpoint ); demux2_Control( p_demux, DEMUX_SET_SEEKPOINT, i_seekpoint );
...@@ -1441,8 +1455,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val ...@@ -1441,8 +1455,8 @@ static vlc_bool_t Control( input_thread_t *p_input, int i_type, vlc_value_t val
else else
i_seekpoint = val.i_int; i_seekpoint = val.i_int;
if( i_seekpoint >= 0 && if( i_seekpoint >= 0 && i_seekpoint <
i_seekpoint < p_input->input.title[p_access->info.i_title]->i_seekpoint ) p_input->input.title[p_access->info.i_title]->i_seekpoint )
{ {
access2_Control( p_access, ACCESS_SET_SEEKPOINT, i_seekpoint ); access2_Control( p_access, ACCESS_SET_SEEKPOINT, i_seekpoint );
stream_AccessReset( p_input->input.p_stream ); stream_AccessReset( p_input->input.p_stream );
...@@ -1760,11 +1774,15 @@ static void SlaveDemux( input_thread_t *p_input ) ...@@ -1760,11 +1774,15 @@ static void SlaveDemux( input_thread_t *p_input )
int64_t i_stime; int64_t i_stime;
if( demux2_Control( in->p_demux, DEMUX_GET_TIME, &i_stime ) ) if( demux2_Control( in->p_demux, DEMUX_GET_TIME, &i_stime ) )
{ {
msg_Err( p_input, "slave[%d] doesn't like DEMUX_GET_TIME -> EOF", i ); msg_Err( p_input, "slave[%d] doesn't like "
"DEMUX_GET_TIME -> EOF", i );
i_ret = 0; i_ret = 0;
break; break;
} }
//msg_Dbg( p_input, "slave time=%lld input=%lld", i_stime, i_time ); #if 0
msg_Dbg( p_input, "slave time="I64Fd" input="I64Fd,
i_stime, i_time );
#endif
if( i_stime >= i_time ) if( i_stime >= i_time )
break; break;
......
...@@ -270,16 +270,13 @@ void input_ControlVarNavigation( input_thread_t *p_input ) ...@@ -270,16 +270,13 @@ void input_ControlVarNavigation( input_thread_t *p_input )
vlc_value_t val2, text, text2; vlc_value_t val2, text, text2;
int j; int j;
/* Add title choice */
val2.i_int = i;
var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val2, NULL );
/* Add Navigation entries */ /* Add Navigation entries */
sprintf( val.psz_string, "title %2i", i ); sprintf( val.psz_string, "title %2i", i );
var_Destroy( p_input, val.psz_string ); var_Destroy( p_input, val.psz_string );
var_Create( p_input, val.psz_string, var_Create( p_input, val.psz_string,
VLC_VAR_INTEGER|VLC_VAR_HASCHOICE|VLC_VAR_ISCOMMAND ); VLC_VAR_INTEGER|VLC_VAR_HASCHOICE|VLC_VAR_ISCOMMAND );
var_AddCallback( p_input, val.psz_string, NavigationCallback, (void *)i ); var_AddCallback( p_input, val.psz_string,
NavigationCallback, (void *)i );
if( p_input->title[i]->psz_name == NULL || if( p_input->title[i]->psz_name == NULL ||
*p_input->title[i]->psz_name == '\0' ) *p_input->title[i]->psz_name == '\0' )
...@@ -292,6 +289,11 @@ void input_ControlVarNavigation( input_thread_t *p_input ) ...@@ -292,6 +289,11 @@ void input_ControlVarNavigation( input_thread_t *p_input )
text.psz_string = strdup( p_input->title[i]->psz_name ); text.psz_string = strdup( p_input->title[i]->psz_name );
} }
var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, &text ); var_Change( p_input, "navigation", VLC_VAR_ADDCHOICE, &val, &text );
/* Add title choice */
val2.i_int = i;
var_Change( p_input, "title", VLC_VAR_ADDCHOICE, &val2, &text );
free( text.psz_string ); free( text.psz_string );
for( j = 0; j < p_input->title[i]->i_seekpoint; j++ ) for( j = 0; j < p_input->title[i]->i_seekpoint; j++ )
...@@ -307,10 +309,12 @@ void input_ControlVarNavigation( input_thread_t *p_input ) ...@@ -307,10 +309,12 @@ void input_ControlVarNavigation( input_thread_t *p_input )
} }
else else
{ {
text2.psz_string = strdup( p_input->title[i]->seekpoint[j]->psz_name ); text2.psz_string =
strdup( p_input->title[i]->seekpoint[j]->psz_name );
} }
var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE, &val2, &text2 ); var_Change( p_input, val.psz_string, VLC_VAR_ADDCHOICE,
&val2, &text2 );
if( text2.psz_string ) free( text2.psz_string ); if( text2.psz_string ) free( text2.psz_string );
} }
...@@ -353,8 +357,23 @@ void input_ControlVarTitle( input_thread_t *p_input, int i_title ) ...@@ -353,8 +357,23 @@ void input_ControlVarTitle( input_thread_t *p_input, int i_title )
var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL ); var_Change( p_input, "chapter", VLC_VAR_CLEARCHOICES, NULL, NULL );
for( i = 0; i < t->i_seekpoint; i++ ) for( i = 0; i < t->i_seekpoint; i++ )
{ {
val.i_int = i + 1; vlc_value_t text;
var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, NULL ); val.i_int = i;
if( t->seekpoint[i]->psz_name == NULL ||
*t->seekpoint[i]->psz_name == '\0' )
{
/* Default value */
text.psz_string = malloc( strlen( _("Chapter %i") ) + 20 );
sprintf( text.psz_string, _("Chapter %i"), i );
}
else
{
text.psz_string = strdup( t->seekpoint[i]->psz_name );
}
var_Change( p_input, "chapter", VLC_VAR_ADDCHOICE, &val, &text );
if( text.psz_string ) free( text.psz_string );
} }
} }
......
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