Commit 0b3b1edf authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

variables: use table of vlc_value_t for VLC_VAR_GETCHOICES

This simplifies the notation. No function differences.
parent 7a51579a
...@@ -381,7 +381,7 @@ int libvlc_audio_get_track( libvlc_media_player_t *p_mi ) ...@@ -381,7 +381,7 @@ int libvlc_audio_get_track( libvlc_media_player_t *p_mi )
int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track ) int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_list_t val_list; vlc_value_t *val_list;
size_t count; size_t count;
int i_ret = -1; int i_ret = -1;
...@@ -392,7 +392,7 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track ) ...@@ -392,7 +392,7 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
&count, &val_list, (char ***)NULL ); &count, &val_list, (char ***)NULL );
for( size_t i = 0; i < count; i++ ) for( size_t i = 0; i < count; i++ )
{ {
if( i_track == val_list.p_values[i].i_int ) if( i_track == val_list[i].i_int )
{ {
if( var_SetInteger( p_input_thread, "audio-es", i_track ) < 0 ) if( var_SetInteger( p_input_thread, "audio-es", i_track ) < 0 )
break; break;
...@@ -402,7 +402,7 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track ) ...@@ -402,7 +402,7 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
} }
libvlc_printerr( "Track identifier not found" ); libvlc_printerr( "Track identifier not found" );
end: end:
free( val_list.p_values ); free( val_list );
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
return i_ret; return i_ret;
} }
......
...@@ -1787,7 +1787,7 @@ libvlc_track_description_t * ...@@ -1787,7 +1787,7 @@ libvlc_track_description_t *
if( !p_input ) if( !p_input )
return NULL; return NULL;
vlc_list_t val_list; vlc_value_t *val_list;
char **text_list; char **text_list;
size_t count; size_t count;
...@@ -1806,13 +1806,13 @@ libvlc_track_description_t * ...@@ -1806,13 +1806,13 @@ libvlc_track_description_t *
} }
*pp = tr; *pp = tr;
tr->i_id = val_list.p_values[i].i_int; tr->i_id = val_list[i].i_int;
tr->psz_name = text_list[i]; tr->psz_name = text_list[i];
pp = &tr->p_next; pp = &tr->p_next;
} }
*pp = NULL; *pp = NULL;
free(val_list.p_values); free(val_list);
free(text_list); free(text_list);
vlc_object_release( p_input ); vlc_object_release( p_input );
......
...@@ -353,7 +353,7 @@ libvlc_track_description_t * ...@@ -353,7 +353,7 @@ libvlc_track_description_t *
int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu ) int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_list_t list; vlc_value_t *list;
size_t count; size_t count;
int i_ret = -1; int i_ret = -1;
...@@ -364,7 +364,7 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu ) ...@@ -364,7 +364,7 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
&count, &list, (char ***)NULL); &count, &list, (char ***)NULL);
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
{ {
if( i_spu == list.p_values[i].i_int ) if( i_spu == list[i].i_int )
{ {
if( var_SetInteger( p_input_thread, "spu-es", i_spu ) < 0 ) if( var_SetInteger( p_input_thread, "spu-es", i_spu ) < 0 )
break; break;
...@@ -375,7 +375,7 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu ) ...@@ -375,7 +375,7 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
libvlc_printerr( "Track identifier not found" ); libvlc_printerr( "Track identifier not found" );
end: end:
vlc_object_release (p_input_thread); vlc_object_release (p_input_thread);
free(list.p_values); free(list);
return i_ret; return i_ret;
} }
...@@ -452,17 +452,16 @@ static void teletext_enable( input_thread_t *p_input_thread, bool b_enable ) ...@@ -452,17 +452,16 @@ static void teletext_enable( input_thread_t *p_input_thread, bool b_enable )
{ {
if( b_enable ) if( b_enable )
{ {
vlc_list_t list; vlc_value_t *list;
size_t count; size_t count;
if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETCHOICES, if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETCHOICES,
&count, &list, (char ***)NULL ) ) &count, &list, (char ***)NULL ) )
{ {
if( count > 0 ) if( count > 0 )
var_SetInteger( p_input_thread, "spu-es", var_SetInteger( p_input_thread, "spu-es", list[0].i_int );
list.p_values[0].i_int );
free(list.p_values); free(list);
} }
} }
else else
...@@ -571,7 +570,7 @@ int libvlc_video_get_track( libvlc_media_player_t *p_mi ) ...@@ -571,7 +570,7 @@ int libvlc_video_get_track( libvlc_media_player_t *p_mi )
int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track ) int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_list_t val_list; vlc_value_t *val_list;
size_t count; size_t count;
int i_ret = -1; int i_ret = -1;
...@@ -582,7 +581,7 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track ) ...@@ -582,7 +581,7 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
&count, &val_list, (char ***)NULL ); &count, &val_list, (char ***)NULL );
for( size_t i = 0; i < count; i++ ) for( size_t i = 0; i < count; i++ )
{ {
if( i_track == val_list.p_values[i].i_int ) if( i_track == val_list[i].i_int )
{ {
if( var_SetInteger( p_input_thread, "video-es", i_track ) < 0 ) if( var_SetInteger( p_input_thread, "video-es", i_track ) < 0 )
break; break;
...@@ -592,7 +591,7 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track ) ...@@ -592,7 +591,7 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
} }
libvlc_printerr( "Track identifier not found" ); libvlc_printerr( "Track identifier not found" );
end: end:
free(val_list.p_values); free(val_list);
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
return i_ret; return i_ret;
} }
......
...@@ -277,7 +277,7 @@ static void ProcessGesture( intf_thread_t *p_intf ) ...@@ -277,7 +277,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
if( p_input == NULL ) if( p_input == NULL )
break; break;
vlc_list_t list; vlc_value_t *list;
size_t count; size_t count;
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES, var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
...@@ -289,7 +289,7 @@ static void ProcessGesture( intf_thread_t *p_intf ) ...@@ -289,7 +289,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
size_t i; size_t i;
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
if( i_audio_es == list.p_values[i].i_int ) if( i_audio_es == list[i].i_int )
break; break;
/* value of audio-es was not in choices list */ /* value of audio-es was not in choices list */
if( i == count ) if( i == count )
...@@ -302,10 +302,9 @@ static void ProcessGesture( intf_thread_t *p_intf ) ...@@ -302,10 +302,9 @@ static void ProcessGesture( intf_thread_t *p_intf )
i = 1; i = 1;
else else
i++; i++;
var_SetInteger( p_input, "audio-es", var_SetInteger( p_input, "audio-es", list[i].i_int );
list.p_values[i].i_int );
} }
free(list.p_values); free(list);
vlc_object_release( p_input ); vlc_object_release( p_input );
break; break;
} }
...@@ -316,7 +315,7 @@ static void ProcessGesture( intf_thread_t *p_intf ) ...@@ -316,7 +315,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
if( p_input == NULL ) if( p_input == NULL )
break; break;
vlc_list_t list; vlc_value_t *list;
size_t count; size_t count;
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES, var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
...@@ -328,7 +327,7 @@ static void ProcessGesture( intf_thread_t *p_intf ) ...@@ -328,7 +327,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
size_t i; size_t i;
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
if( i_audio_es == list.p_values[i].i_int ) if( i_audio_es == list[i].i_int )
break; break;
/* value of audio-es was not in choices list */ /* value of audio-es was not in choices list */
if( i == count ) if( i == count )
...@@ -341,10 +340,9 @@ static void ProcessGesture( intf_thread_t *p_intf ) ...@@ -341,10 +340,9 @@ static void ProcessGesture( intf_thread_t *p_intf )
i = 1; i = 1;
else else
i++; i++;
var_SetInteger( p_input, "audio-es", var_SetInteger( p_input, "audio-es", list[i].i_int );
list.p_values[i].i_int );
} }
free(list.p_values); free(list);
vlc_object_release( p_input ); vlc_object_release( p_input );
break; break;
} }
......
...@@ -107,21 +107,21 @@ vlc_module_begin () ...@@ -107,21 +107,21 @@ vlc_module_begin ()
vlc_module_end () vlc_module_end ()
static void var_FreeList( vlc_list_t values, char **texts ) static void var_FreeList( size_t n, vlc_value_t *values, char **texts )
{ {
free( values.p_values ); free( values );
for( int i = 0; i < values.i_count; i++ ) for( size_t i = 0; i < n; i++ )
free( texts[i] ); free( texts[i] );
free( texts ); free( texts );
} }
static void var_FreeStringList( vlc_list_t values, char **texts ) static void var_FreeStringList( size_t n, vlc_value_t *values, char **texts )
{ {
for( int i = 0; i < values.i_count; i++ ) for( size_t i = 0; i < n; i++ )
free( values.p_values[i].psz_string ); free( values[i].psz_string );
var_FreeList( values, texts ); var_FreeList( n, values, texts );
} }
static int MovedEvent( vlc_object_t *p_this, char const *psz_var, static int MovedEvent( vlc_object_t *p_this, char const *psz_var,
...@@ -645,7 +645,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -645,7 +645,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input ) if( p_input )
{ {
vlc_value_t val; vlc_value_t val;
vlc_list_t list; vlc_value_t *list;
size_t count; size_t count;
var_Get( p_input, "spu-es", &val ); var_Get( p_input, "spu-es", &val );
...@@ -662,7 +662,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -662,7 +662,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
DisplayMessage(p_vout, DisplayMessage(p_vout,
_("Sub sync: bookmarked subtitle time")); _("Sub sync: bookmarked subtitle time"));
} }
free(list.p_values); free(list);
} }
break; break;
case ACTIONID_SUBSYNC_APPLY: case ACTIONID_SUBSYNC_APPLY:
...@@ -716,7 +716,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -716,7 +716,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input ) if( p_input )
{ {
vlc_value_t val; vlc_value_t val;
vlc_list_t list; vlc_value_t *list;
size_t count; size_t count;
var_Get( p_input, "spu-es", &val ); var_Get( p_input, "spu-es", &val );
...@@ -726,7 +726,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -726,7 +726,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( count < 1 || val.i_int < 0 ) if( count < 1 || val.i_int < 0 )
{ {
DisplayMessage( p_vout, _("No active subtitle") ); DisplayMessage( p_vout, _("No active subtitle") );
free(list.p_values); free(list);
break; break;
} }
int64_t i_delay = var_GetInteger( p_input, "spu-delay" ) + diff; int64_t i_delay = var_GetInteger( p_input, "spu-delay" ) + diff;
...@@ -735,7 +735,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -735,7 +735,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
ClearChannels( p_vout, slider_chan ); ClearChannels( p_vout, slider_chan );
DisplayMessage( p_vout, _( "Subtitle delay %i ms" ), DisplayMessage( p_vout, _( "Subtitle delay %i ms" ),
(int)(i_delay/1000) ); (int)(i_delay/1000) );
free(list.p_values); free(list);
} }
break; break;
} }
...@@ -760,7 +760,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -760,7 +760,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input ) if( p_input )
{ {
vlc_value_t val; vlc_value_t val;
vlc_list_t list; vlc_value_t *list;
char **list2; char **list2;
size_t count; size_t count;
...@@ -773,12 +773,8 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -773,12 +773,8 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
size_t i; size_t i;
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
{ if( val.i_int == list[i].i_int )
if( val.i_int == list.p_values[i].i_int )
{
break; break;
}
}
/* value of audio-es was not in choices list */ /* value of audio-es was not in choices list */
if( i == count ) if( i == count )
{ {
...@@ -790,10 +786,10 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -790,10 +786,10 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
i = 1; i = 1;
else else
i++; i++;
var_Set( p_input, "audio-es", list.p_values[i] ); var_Set( p_input, "audio-es", list[i] );
DisplayMessage( p_vout, _("Audio track: %s"), list2[i] ); DisplayMessage( p_vout, _("Audio track: %s"), list2[i] );
} }
var_FreeList( list, list2 ); var_FreeList( count, list, list2 );
} }
break; break;
...@@ -802,7 +798,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -802,7 +798,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input ) if( p_input )
{ {
vlc_value_t val; vlc_value_t val;
vlc_list_t list; vlc_value_t *list;
char **list2; char **list2;
size_t count, i; size_t count, i;
var_Get( p_input, "spu-es", &val ); var_Get( p_input, "spu-es", &val );
...@@ -814,11 +810,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -814,11 +810,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{ {
DisplayMessage( p_vout, _("Subtitle track: %s"), DisplayMessage( p_vout, _("Subtitle track: %s"),
_("N/A") ); _("N/A") );
var_FreeList( list, list2 ); var_FreeList( count, list, list2 );
break; break;
} }
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
if( val.i_int == list.p_values[i].i_int ) if( val.i_int == list[i].i_int )
break; break;
/* value of spu-es was not in choices list */ /* value of spu-es was not in choices list */
if( i == count ) if( i == count )
...@@ -833,15 +829,15 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -833,15 +829,15 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
i = count - 1; i = count - 1;
else else
i = (i_action == ACTIONID_SUBTITLE_TRACK) ? i+1 : i-1; i = (i_action == ACTIONID_SUBTITLE_TRACK) ? i+1 : i-1;
var_SetInteger( p_input, "spu-es", list.p_values[i].i_int ); var_SetInteger( p_input, "spu-es", list[i].i_int );
DisplayMessage( p_vout, _("Subtitle track: %s"), list2[i] ); DisplayMessage( p_vout, _("Subtitle track: %s"), list2[i] );
var_FreeList( list, list2 ); var_FreeList( count, list, list2 );
} }
break; break;
case ACTIONID_SUBTITLE_TOGGLE: case ACTIONID_SUBTITLE_TOGGLE:
if( p_input ) if( p_input )
{ {
vlc_list_t list; vlc_value_t *list;
char **list2; char **list2;
size_t count; size_t count;
...@@ -852,7 +848,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -852,7 +848,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{ {
DisplayMessage( p_vout, _("Subtitle track: %s"), DisplayMessage( p_vout, _("Subtitle track: %s"),
_("N/A") ); _("N/A") );
var_FreeList( list, list2 ); var_FreeList( count, list, list2 );
break; break;
} }
...@@ -878,17 +874,17 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -878,17 +874,17 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{ {
for( size_t i = 0; i < count; ++i ) for( size_t i = 0; i < count; ++i )
{ {
if( i_new_id == list.p_values[i].i_int ) if( i_new_id == list[i].i_int )
{ {
i_new_index = i; i_new_index = i;
break; break;
} }
} }
} }
var_SetInteger( p_input, "spu-es", list.p_values[i_new_index].i_int ); var_SetInteger( p_input, "spu-es", list[i_new_index].i_int );
DisplayMessage( p_vout, _("Subtitle track: %s"), DisplayMessage( p_vout, _("Subtitle track: %s"),
list2[i_new_index] ); list2[i_new_index] );
var_FreeList( list, list2 ); var_FreeList( count, list, list2 );
} }
break; break;
case ACTIONID_PROGRAM_SID_NEXT: case ACTIONID_PROGRAM_SID_NEXT:
...@@ -896,7 +892,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -896,7 +892,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input ) if( p_input )
{ {
vlc_value_t val; vlc_value_t val;
vlc_list_t list; vlc_value_t *list;
char **list2; char **list2;
size_t count, i; size_t count, i;
var_Get( p_input, "program", &val ); var_Get( p_input, "program", &val );
...@@ -908,11 +904,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -908,11 +904,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{ {
DisplayMessage( p_vout, _("Program Service ID: %s"), DisplayMessage( p_vout, _("Program Service ID: %s"),
_("N/A") ); _("N/A") );
var_FreeList( list, list2 ); var_FreeList( count, list, list2 );
break; break;
} }
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
if( val.i_int == list.p_values[i].i_int ) if( val.i_int == list[i].i_int )
break; break;
/* value of program sid was not in choices list */ /* value of program sid was not in choices list */
if( i == count ) if( i == count )
...@@ -933,10 +929,10 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -933,10 +929,10 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
else else
i--; i--;
} }
var_Set( p_input, "program", list.p_values[i] ); var_Set( p_input, "program", list[i] );
DisplayMessage( p_vout, _("Program Service ID: %s"), DisplayMessage( p_vout, _("Program Service ID: %s"),
list2[i] ); list2[i] );
var_FreeList( list, list2 ); var_FreeList( count, list, list2 );
} }
break; break;
...@@ -1060,7 +1056,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -1060,7 +1056,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_vout ) if( p_vout )
{ {
vlc_value_t val; vlc_value_t val;
vlc_list_t val_list; vlc_value_t *val_list;
char **text_list; char **text_list;
size_t count; size_t count;
...@@ -1071,8 +1067,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -1071,8 +1067,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
size_t i; size_t i;
for( i = 0; i < count; i++ ) for( i = 0; i < count; i++ )
{ {
if( !strcmp( val_list.p_values[i].psz_string, if( !strcmp( val_list[i].psz_string, val.psz_string ) )
val.psz_string ) )
{ {
i++; i++;
break; break;
...@@ -1080,11 +1075,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input, ...@@ -1080,11 +1075,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
} }
if( i == count ) i = 0; if( i == count ) i = 0;
var_SetString( p_vout, "aspect-ratio", var_SetString( p_vout, "aspect-ratio",
val_list.p_values[i].psz_string ); val_list[i].psz_string );
DisplayMessage( p_vout, _("Aspect ratio: %s"), DisplayMessage( p_vout, _("Aspect ratio: %s"),
text_list[i] ); text_list[i] );
var_FreeStringList( val_list, text_list ); var_FreeStringList( count, val_list, text_list );
} }
free( val.psz_string ); free( val.psz_string );