[vlc-commits] variables: use table of vlc_value_t for VLC_VAR_GETCHOICES
Rémi Denis-Courmont
git at videolan.org
Sun Jun 10 12:11:39 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jun 10 12:59:47 2018 +0300| [0b3b1edf141570a32fb39b4da9737724e06ebdc7] | committer: Rémi Denis-Courmont
variables: use table of vlc_value_t for VLC_VAR_GETCHOICES
This simplifies the notation. No function differences.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b3b1edf141570a32fb39b4da9737724e06ebdc7
---
lib/audio.c | 6 +-
lib/media_player.c | 6 +-
lib/video.c | 19 ++--
modules/control/gestures.c | 18 ++--
modules/control/hotkeys.c | 114 +++++++++++-------------
modules/control/oldrc.c | 30 +++----
modules/gui/macosx/VLCMainMenu.m | 18 ++--
modules/gui/ncurses.c | 8 +-
modules/gui/qt/components/controller_widget.cpp | 8 +-
modules/gui/qt/components/extended_panels.cpp | 14 +--
modules/gui/qt/input_manager.cpp | 8 +-
modules/gui/qt/menus.cpp | 6 +-
modules/lua/libs/variables.c | 14 +--
src/audio_output/output.c | 6 +-
src/input/input.c | 6 +-
src/misc/variables.c | 11 ++-
test/src/misc/variables.c | 7 +-
17 files changed, 144 insertions(+), 155 deletions(-)
diff --git a/lib/audio.c b/lib/audio.c
index ff513b3944..4d35723023 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -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 )
{
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;
int i_ret = -1;
@@ -392,7 +392,7 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
&count, &val_list, (char ***)NULL );
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 )
break;
@@ -402,7 +402,7 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
}
libvlc_printerr( "Track identifier not found" );
end:
- free( val_list.p_values );
+ free( val_list );
vlc_object_release( p_input_thread );
return i_ret;
}
diff --git a/lib/media_player.c b/lib/media_player.c
index 06ddf9df09..cd9d3eea31 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1787,7 +1787,7 @@ libvlc_track_description_t *
if( !p_input )
return NULL;
- vlc_list_t val_list;
+ vlc_value_t *val_list;
char **text_list;
size_t count;
@@ -1806,13 +1806,13 @@ libvlc_track_description_t *
}
*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];
pp = &tr->p_next;
}
*pp = NULL;
- free(val_list.p_values);
+ free(val_list);
free(text_list);
vlc_object_release( p_input );
diff --git a/lib/video.c b/lib/video.c
index 4c03f015b4..1aa3a0a3d8 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -353,7 +353,7 @@ libvlc_track_description_t *
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 );
- vlc_list_t list;
+ vlc_value_t *list;
size_t count;
int i_ret = -1;
@@ -364,7 +364,7 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
&count, &list, (char ***)NULL);
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 )
break;
@@ -375,7 +375,7 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
libvlc_printerr( "Track identifier not found" );
end:
vlc_object_release (p_input_thread);
- free(list.p_values);
+ free(list);
return i_ret;
}
@@ -452,17 +452,16 @@ static void teletext_enable( input_thread_t *p_input_thread, bool b_enable )
{
if( b_enable )
{
- vlc_list_t list;
+ vlc_value_t *list;
size_t count;
if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETCHOICES,
&count, &list, (char ***)NULL ) )
{
if( count > 0 )
- var_SetInteger( p_input_thread, "spu-es",
- list.p_values[0].i_int );
+ var_SetInteger( p_input_thread, "spu-es", list[0].i_int );
- free(list.p_values);
+ free(list);
}
}
else
@@ -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 )
{
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;
int i_ret = -1;
@@ -582,7 +581,7 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
&count, &val_list, (char ***)NULL );
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 )
break;
@@ -592,7 +591,7 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
}
libvlc_printerr( "Track identifier not found" );
end:
- free(val_list.p_values);
+ free(val_list);
vlc_object_release( p_input_thread );
return i_ret;
}
diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index 967d8a8b99..891456f255 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -277,7 +277,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
if( p_input == NULL )
break;
- vlc_list_t list;
+ vlc_value_t *list;
size_t count;
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
@@ -289,7 +289,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
size_t 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;
/* value of audio-es was not in choices list */
if( i == count )
@@ -302,10 +302,9 @@ static void ProcessGesture( intf_thread_t *p_intf )
i = 1;
else
i++;
- var_SetInteger( p_input, "audio-es",
- list.p_values[i].i_int );
+ var_SetInteger( p_input, "audio-es", list[i].i_int );
}
- free(list.p_values);
+ free(list);
vlc_object_release( p_input );
break;
}
@@ -316,7 +315,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
if( p_input == NULL )
break;
- vlc_list_t list;
+ vlc_value_t *list;
size_t count;
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
@@ -328,7 +327,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
size_t 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;
/* value of audio-es was not in choices list */
if( i == count )
@@ -341,10 +340,9 @@ static void ProcessGesture( intf_thread_t *p_intf )
i = 1;
else
i++;
- var_SetInteger( p_input, "audio-es",
- list.p_values[i].i_int );
+ var_SetInteger( p_input, "audio-es", list[i].i_int );
}
- free(list.p_values);
+ free(list);
vlc_object_release( p_input );
break;
}
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index b8f47d1a6d..5428373eb4 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -107,21 +107,21 @@ vlc_module_begin ()
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 );
}
-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++ )
- free( values.p_values[i].psz_string );
+ for( size_t i = 0; i < n; i++ )
+ 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,
@@ -645,7 +645,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input )
{
vlc_value_t val;
- vlc_list_t list;
+ vlc_value_t *list;
size_t count;
var_Get( p_input, "spu-es", &val );
@@ -662,7 +662,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
DisplayMessage(p_vout,
_("Sub sync: bookmarked subtitle time"));
}
- free(list.p_values);
+ free(list);
}
break;
case ACTIONID_SUBSYNC_APPLY:
@@ -716,7 +716,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input )
{
vlc_value_t val;
- vlc_list_t list;
+ vlc_value_t *list;
size_t count;
var_Get( p_input, "spu-es", &val );
@@ -726,7 +726,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( count < 1 || val.i_int < 0 )
{
DisplayMessage( p_vout, _("No active subtitle") );
- free(list.p_values);
+ free(list);
break;
}
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,
ClearChannels( p_vout, slider_chan );
DisplayMessage( p_vout, _( "Subtitle delay %i ms" ),
(int)(i_delay/1000) );
- free(list.p_values);
+ free(list);
}
break;
}
@@ -760,7 +760,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input )
{
vlc_value_t val;
- vlc_list_t list;
+ vlc_value_t *list;
char **list2;
size_t count;
@@ -773,12 +773,8 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
size_t 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;
- }
- }
/* value of audio-es was not in choices list */
if( i == count )
{
@@ -790,10 +786,10 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
i = 1;
else
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] );
}
- var_FreeList( list, list2 );
+ var_FreeList( count, list, list2 );
}
break;
@@ -802,7 +798,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input )
{
vlc_value_t val;
- vlc_list_t list;
+ vlc_value_t *list;
char **list2;
size_t count, i;
var_Get( p_input, "spu-es", &val );
@@ -814,11 +810,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{
DisplayMessage( p_vout, _("Subtitle track: %s"),
_("N/A") );
- var_FreeList( list, list2 );
+ var_FreeList( count, list, list2 );
break;
}
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;
/* value of spu-es was not in choices list */
if( i == count )
@@ -833,15 +829,15 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
i = count - 1;
else
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] );
- var_FreeList( list, list2 );
+ var_FreeList( count, list, list2 );
}
break;
case ACTIONID_SUBTITLE_TOGGLE:
if( p_input )
{
- vlc_list_t list;
+ vlc_value_t *list;
char **list2;
size_t count;
@@ -852,7 +848,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{
DisplayMessage( p_vout, _("Subtitle track: %s"),
_("N/A") );
- var_FreeList( list, list2 );
+ var_FreeList( count, list, list2 );
break;
}
@@ -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 )
{
- if( i_new_id == list.p_values[i].i_int )
+ if( i_new_id == list[i].i_int )
{
i_new_index = i;
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"),
list2[i_new_index] );
- var_FreeList( list, list2 );
+ var_FreeList( count, list, list2 );
}
break;
case ACTIONID_PROGRAM_SID_NEXT:
@@ -896,7 +892,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input )
{
vlc_value_t val;
- vlc_list_t list;
+ vlc_value_t *list;
char **list2;
size_t count, i;
var_Get( p_input, "program", &val );
@@ -908,11 +904,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{
DisplayMessage( p_vout, _("Program Service ID: %s"),
_("N/A") );
- var_FreeList( list, list2 );
+ var_FreeList( count, list, list2 );
break;
}
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;
/* value of program sid was not in choices list */
if( i == count )
@@ -933,10 +929,10 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
else
i--;
}
- var_Set( p_input, "program", list.p_values[i] );
+ var_Set( p_input, "program", list[i] );
DisplayMessage( p_vout, _("Program Service ID: %s"),
list2[i] );
- var_FreeList( list, list2 );
+ var_FreeList( count, list, list2 );
}
break;
@@ -1060,7 +1056,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_vout )
{
vlc_value_t val;
- vlc_list_t val_list;
+ vlc_value_t *val_list;
char **text_list;
size_t count;
@@ -1071,8 +1067,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
size_t i;
for( i = 0; i < count; i++ )
{
- if( !strcmp( val_list.p_values[i].psz_string,
- val.psz_string ) )
+ if( !strcmp( val_list[i].psz_string, val.psz_string ) )
{
i++;
break;
@@ -1080,11 +1075,11 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
}
if( i == count ) i = 0;
var_SetString( p_vout, "aspect-ratio",
- val_list.p_values[i].psz_string );
+ val_list[i].psz_string );
DisplayMessage( p_vout, _("Aspect ratio: %s"),
text_list[i] );
- var_FreeStringList( val_list, text_list );
+ var_FreeStringList( count, val_list, text_list );
}
free( val.psz_string );
}
@@ -1094,7 +1089,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_vout )
{
vlc_value_t val;
- vlc_list_t val_list;
+ vlc_value_t *val_list;
char **text_list;
size_t count;
@@ -1105,19 +1100,17 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
size_t i;
for( i = 0; i < count; i++ )
{
- if( !strcmp( val_list.p_values[i].psz_string,
- val.psz_string ) )
+ if( !strcmp( val_list[i].psz_string, val.psz_string ) )
{
i++;
break;
}
}
if( i == count ) i = 0;
- var_SetString( p_vout, "crop",
- val_list.p_values[i].psz_string );
+ var_SetString( p_vout, "crop", val_list[i].psz_string );
DisplayMessage( p_vout, _("Crop: %s"), text_list[i] );
- var_FreeStringList( val_list, text_list );
+ var_FreeStringList( count, val_list, text_list );
}
free( val.psz_string );
}
@@ -1245,7 +1238,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_vout )
{
vlc_value_t val;
- vlc_list_t val_list;
+ vlc_value_t *val_list;
char **text_list;
size_t count;
@@ -1256,7 +1249,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
size_t i;
for( i = 0; i < count; i++ )
{
- if( val_list.p_values[i].f_float == val.f_float )
+ if( val_list[i].f_float == val.f_float )
{
if( i_action == ACTIONID_ZOOM )
i++;
@@ -1267,11 +1260,10 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
}
if( i == count ) i = 0;
if( i == (size_t)-1 ) i = count-1;
- var_SetFloat( p_vout, "zoom",
- val_list.p_values[i].f_float );
+ var_SetFloat( p_vout, "zoom", val_list[i].f_float );
DisplayMessage( p_vout, _("Zoom mode: %s"), text_list[i] );
- var_FreeStringList( val_list, text_list );
+ var_FreeStringList( count, val_list, text_list );
}
}
break;
@@ -1290,7 +1282,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
var_SetInteger( p_vout, "deinterlace", 1 );
char *psz_mode = var_GetString( p_vout, "deinterlace-mode" );
- vlc_list_t vlist;
+ vlc_value_t *vlist;
char **tlist;
size_t count;
@@ -1299,7 +1291,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
const char *psz_text = NULL;
for( size_t i = 0; i < count; i++ )
{
- if( !strcmp( vlist.p_values[i].psz_string, psz_mode ) )
+ if( !strcmp( vlist[i].psz_string, psz_mode ) )
{
psz_text = tlist[i];
break;
@@ -1308,7 +1300,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
DisplayMessage( p_vout, "%s (%s)", _("Deinterlace on"),
psz_text ? psz_text : psz_mode );
- var_FreeStringList( vlist, tlist );
+ var_FreeStringList( count, vlist, tlist );
}
free( psz_mode );
}
@@ -1318,7 +1310,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_vout )
{
char *psz_mode = var_GetString( p_vout, "deinterlace-mode" );
- vlc_list_t vlist;
+ vlc_value_t *vlist;
char **tlist;
size_t count;
@@ -1329,7 +1321,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
for( i = 0; i < count; i++ )
{
- if( !strcmp( vlist.p_values[i].psz_string, psz_mode ) )
+ if( !strcmp( vlist[i].psz_string, psz_mode ) )
{
i++;
break;
@@ -1337,7 +1329,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
}
if( i == count ) i = 0;
psz_text = tlist[i];
- var_SetString( p_vout, "deinterlace-mode", vlist.p_values[i].psz_string );
+ var_SetString( p_vout, "deinterlace-mode", vlist[i].psz_string );
int i_deinterlace = var_GetInteger( p_vout, "deinterlace" );
if( i_deinterlace != 0 )
@@ -1351,7 +1343,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
psz_text ? psz_text : psz_mode );
}
- var_FreeStringList( vlist, tlist );
+ var_FreeStringList( count, vlist, tlist );
}
free( psz_mode );
}
@@ -1363,7 +1355,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
if( p_input )
{
vlc_value_t val;
- vlc_list_t list;
+ vlc_value_t *list;
size_t count;
var_Get( p_input, "spu-es", &val );
@@ -1374,7 +1366,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{
DisplayMessage( p_vout,
_("Subtitle position: no active subtitle") );
- free(list.p_values);
+ free(list);
break;
}
@@ -1386,7 +1378,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
ClearChannels( p_vout, slider_chan );
DisplayMessage( p_vout, _( "Subtitle position %d px" ), i_pos );
- free(list.p_values);
+ free(list);
}
break;
}
diff --git a/modules/control/oldrc.c b/modules/control/oldrc.c
index 2e92a31f06..40d004b871 100644
--- a/modules/control/oldrc.c
+++ b/modules/control/oldrc.c
@@ -1122,7 +1122,7 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
else
{
/* get */
- vlc_list_t val;
+ vlc_value_t *val;
char **text;
size_t count;
@@ -1138,12 +1138,12 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
msg_rc( "+----[ %s ]", name );
for ( size_t i = 0; i < count; i++ )
{
- msg_rc( "| %"PRId64" - %s%s", val.p_values[i].i_int, text[i],
- (i_value == val.p_values[i].i_int) ? " *" : "" );
+ msg_rc( "| %"PRId64" - %s%s", val[i].i_int, text[i],
+ (i_value == val[i].i_int) ? " *" : "" );
free(text[i]);
}
free(text);
- free(val.p_values);
+ free(val);
msg_rc( "+----[ end of %s ]", name );
}
free( name );
@@ -1556,7 +1556,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
{
/* get */
char *name;
- vlc_list_t val;
+ vlc_value_t *val;
char **text;
float f_value = 0.;
char *psz_value = NULL;
@@ -1591,8 +1591,8 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
{
for ( size_t i = 0; i < count; i++ )
{
- msg_rc( "| %f - %s%s", val.p_values[i].f_float, text[i],
- f_value == val.p_values[i].f_float ? " *" : "" );
+ msg_rc( "| %f - %s%s", val[i].f_float, text[i],
+ f_value == val[i].f_float ? " *" : "" );
free(text[i]);
}
}
@@ -1600,16 +1600,16 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
{
for ( size_t i = 0; i < count; i++ )
{
- msg_rc( "| %s - %s%s", val.p_values[i].psz_string, text[i],
- strcmp(psz_value, val.p_values[i].psz_string)
+ msg_rc( "| %s - %s%s", val[i].psz_string, text[i],
+ strcmp(psz_value, val[i].psz_string)
? "" : " *" );
free(text[i]);
- free(val.p_values[i].psz_string);
+ free(val[i].psz_string);
}
free( psz_value );
}
free(text);
- free(val.p_values);
+ free(val);
msg_rc( "+----[ end of %s ]", name );
free( name );
@@ -1674,7 +1674,7 @@ static int AudioChannel( vlc_object_t *obj, char const *cmd,
if ( !*cur.psz_string )
{
/* Retrieve all registered ***. */
- vlc_list_t val;
+ vlc_value_t *val;
char **text;
size_t count;
@@ -1690,12 +1690,12 @@ static int AudioChannel( vlc_object_t *obj, char const *cmd,
msg_rc( "+----[ %s ]", cmd );
for ( size_t i = 0; i < count; i++ )
{
- msg_rc( "| %"PRId64" - %s%s", val.p_values[i].i_int, text[i],
- i_value == val.p_values[i].i_int ? " *" : "" );
+ msg_rc( "| %"PRId64" - %s%s", val[i].i_int, text[i],
+ i_value == val[i].i_int ? " *" : "" );
free(text[i]);
}
free(text);
- free(val.p_values);
+ free(val);
msg_rc( "+----[ end of %s ]", cmd );
}
else
diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m
index 3712f65e14..bcb462f505 100644
--- a/modules/gui/macosx/VLCMainMenu.m
+++ b/modules/gui/macosx/VLCMainMenu.m
@@ -1448,7 +1448,7 @@
selector:(SEL)pf_callback
{
vlc_value_t val;
- vlc_list_t val_list;
+ vlc_value_t *val_list;
char **text_list;
size_t count, i;
int i_type;
@@ -1516,33 +1516,33 @@
switch(i_type & VLC_VAR_TYPE) {
case VLC_VAR_STRING:
- title = _NS(text_list[i] ? text_list[i] : val_list.p_values[i].psz_string);
+ title = _NS(text_list[i] ? text_list[i] : val_list[i].psz_string);
lmi = [menu addItemWithTitle: title action: pf_callback keyEquivalent: @""];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
- andValue: val_list.p_values[i] ofType: i_type];
+ andValue: val_list[i] ofType: i_type];
[lmi setRepresentedObject:data];
[lmi setTarget: self];
- if (!strcmp(val.psz_string, val_list.p_values[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND))
+ if (!strcmp(val.psz_string, val_list[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND))
[lmi setState: TRUE ];
free(text_list[i]);
- free(val_list.p_values[i].psz_string);
+ free(val_list[i].psz_string);
break;
case VLC_VAR_INTEGER:
title = text_list[i] ?
- _NS(text_list[i]) : [NSString stringWithFormat: @"%"PRId64, val_list.p_values[i].i_int];
+ _NS(text_list[i]) : [NSString stringWithFormat: @"%"PRId64, val_list[i].i_int];
lmi = [menu addItemWithTitle: title action: pf_callback keyEquivalent: @""];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
- andValue: val_list.p_values[i] ofType: i_type];
+ andValue: val_list[i] ofType: i_type];
[lmi setRepresentedObject:data];
[lmi setTarget: self];
- if (val_list.p_values[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND))
+ if (val_list[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND))
[lmi setState: TRUE ];
free(text_list[i]);
@@ -1556,7 +1556,7 @@
/* clean up everything */
if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
free(text);
- free(val_list.p_values);
+ free(val_list);
}
- (void)toggleVar:(id)sender
diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c
index f73e54fd14..f745e6359e 100644
--- a/modules/gui/ncurses.c
+++ b/modules/gui/ncurses.c
@@ -1538,7 +1538,7 @@ static void CycleESTrack(input_thread_t *input, const char *var)
if (!input)
return;
- vlc_list_t list;
+ vlc_value_t *list;
size_t count;
if (var_Change(input, var, VLC_VAR_GETCHOICES,
@@ -1549,13 +1549,13 @@ static void CycleESTrack(input_thread_t *input, const char *var)
size_t i;
for (i = 0; i < count; i++)
- if (list.p_values[i].i_int == current)
+ if (list[i].i_int == current)
break;
if (++i >= count)
i = 0;
- var_SetInteger(input, var, list.p_values[i].i_int);
- free(list.p_values);
+ var_SetInteger(input, var, list[i].i_int);
+ free(list);
}
static void HandleCommonKey(intf_thread_t *intf, input_thread_t *input,
diff --git a/modules/gui/qt/components/controller_widget.cpp b/modules/gui/qt/components/controller_widget.cpp
index 69d340e43a..775bf2c99f 100644
--- a/modules/gui/qt/components/controller_widget.cpp
+++ b/modules/gui/qt/components/controller_widget.cpp
@@ -268,7 +268,7 @@ void AspectRatioComboBox::updateRatios()
{
/* Clear the list before updating */
clear();
- vlc_list_t val_list;
+ vlc_value_t *val_list;
char **text_list;
size_t count;
@@ -287,13 +287,13 @@ void AspectRatioComboBox::updateRatios()
for( size_t i = 0; i < count; i++ )
{
addItem( qfu( text_list[i] ),
- QString( val_list.p_values[i].psz_string ) );
+ QString( val_list[i].psz_string ) );
free(text_list[i]);
- free(val_list.p_values[i].psz_string);
+ free(val_list[i].psz_string);
}
setEnabled( true );
free(text_list);
- free(val_list.p_values);
+ free(val_list);
vlc_object_release( p_vout );
}
diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp
index 1d4a427287..768ffe5241 100644
--- a/modules/gui/qt/components/extended_panels.cpp
+++ b/modules/gui/qt/components/extended_panels.cpp
@@ -651,7 +651,7 @@ void ExtV4l2::Refresh( void )
}
if( p_obj )
{
- vlc_list_t val;
+ vlc_value_t *val;
char **text;
size_t count;
@@ -684,7 +684,7 @@ void ExtV4l2::Refresh( void )
name = qfu(psz_var);
msg_Dbg( p_intf, "v4l2 control \"%" PRIx64 "\": %s (%s)",
- val.p_values[i].i_int, psz_var, qtu( name ) );
+ val[i].i_int, psz_var, qtu( name ) );
int i_type = var_Type( p_obj, psz_var );
switch( i_type & VLC_VAR_TYPE )
@@ -700,7 +700,7 @@ void ExtV4l2::Refresh( void )
QComboBox *combobox = new QComboBox( box );
combobox->setObjectName( qfu( psz_var ) );
- vlc_list_t val2;
+ vlc_value_t *val2;
char **text2;
size_t count2;
@@ -709,13 +709,13 @@ void ExtV4l2::Refresh( void )
for( size_t j = 0; j < count2; j++ )
{
combobox->addItem( text2[j],
- qlonglong( val2.p_values[j].i_int) );
- if( i_val == val2.p_values[j].i_int )
+ qlonglong( val2[j].i_int) );
+ if( i_val == val2[j].i_int )
combobox->setCurrentIndex( j );
free(text2[j]);
}
free(text2);
- free(val2.p_values);
+ free(val2);
CONNECT( combobox, currentIndexChanged( int ), this,
ValueChange( int ) );
@@ -782,7 +782,7 @@ void ExtV4l2::Refresh( void )
free(psz_var);
}
free(text);
- free(val.p_values);
+ free(val);
vlc_object_release( p_obj );
}
else
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index 247baaa2b2..d433bed227 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -859,7 +859,7 @@ void InputManager::telexSetTransparency( bool b_transparentTelextext )
void InputManager::activateTeletext( bool b_enable )
{
- vlc_list_t list;
+ vlc_value_t *list;
char **text;
size_t count;
@@ -868,17 +868,17 @@ void InputManager::activateTeletext( bool b_enable )
{
if( count > 0 )
{ /* Prefer the page 100 if it is present */
- int id = list.p_values[0].i_int;
+ int id = list[0].i_int;
for( size_t i = 0; i < count; i++ )
{ /* The description is the page number as a string */
if( text[i] != NULL && !strcmp( text[i], "100" ) )
- id = list.p_values[i].i_int;
+ id = list[i].i_int;
free(text[i]);
}
var_SetInteger( p_input, "spu-es", b_enable ? id : -1 );
}
free(text);
- free(list.p_values);
+ free(list);
}
}
diff --git a/modules/gui/qt/menus.cpp b/modules/gui/qt/menus.cpp
index a783218602..14e07e4cd2 100644
--- a/modules/gui/qt/menus.cpp
+++ b/modules/gui/qt/menus.cpp
@@ -1375,7 +1375,7 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
vlc_object_t *p_object )
{
vlc_value_t val;
- vlc_list_t val_list;
+ vlc_value_t *val_list;
char **text_list;
size_t count, i;
int i_type;
@@ -1406,7 +1406,7 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
return VLC_EGENERIC;
}
-#define CURVAL val_list.p_values[i]
+#define CURVAL val_list[i]
#define CURTEXT text_list[i]
#define RADIO_OR_COMMAND ( i_type & ( VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE ) ) ? ITEM_RADIO : ITEM_NORMAL
@@ -1457,7 +1457,7 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
/* clean up everything */
free(text_list);
- free(val_list.p_values);
+ free(val_list);
#undef RADIO_OR_COMMAND
#undef CURVAL
diff --git a/modules/lua/libs/variables.c b/modules/lua/libs/variables.c
index 7cb6e75678..6016253466 100644
--- a/modules/lua/libs/variables.c
+++ b/modules/lua/libs/variables.c
@@ -220,7 +220,7 @@ static int vlclua_var_create( lua_State *L )
static int vlclua_var_get_list( lua_State *L )
{
- vlc_list_t val;
+ vlc_value_t *val;
char **text;
size_t count;
vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
@@ -231,15 +231,17 @@ static int vlclua_var_get_list( lua_State *L )
if( i_ret < 0 )
return vlclua_push_ret( L, i_ret );
+ int type = var_Type( *pp_obj, psz_var );
+
lua_createtable( L, count, 0 );
for( size_t i = 0; i < count; i++ )
{
lua_pushinteger( L, i+1 );
- if( !vlclua_pushvalue( L, val.i_type, val.p_values[i] ) )
- lua_pushnil( L );
+ if( !vlclua_pushvalue( L, type, val[i] ) )
+ lua_pushnil( L );
lua_settable( L, -3 );
- if( (val.i_type & VLC_VAR_CLASS) == VLC_VAR_STRING )
- free(val.p_values[i].psz_string);
+ if( (type & VLC_VAR_CLASS) == VLC_VAR_STRING )
+ free(val[i].psz_string);
}
lua_createtable( L, count, 0 );
@@ -252,7 +254,7 @@ static int vlclua_var_get_list( lua_State *L )
}
free(text);
- free(val.p_values);
+ free(val);
return 2;
}
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index f5992e0181..19f195eb80 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -471,7 +471,7 @@ static void aout_PrepareStereoMode (audio_output_t *aout,
}
bool mode_available = false;
- vlc_list_t vals;
+ vlc_value_t *vals;
size_t count;
if (!var_Change(aout, "stereo-mode", VLC_VAR_GETCHOICES,
@@ -479,10 +479,10 @@ static void aout_PrepareStereoMode (audio_output_t *aout,
{
for (size_t i = 0; !mode_available && i < count; ++i)
{
- if (vals.p_values[i].i_int == i_output_mode)
+ if (vals[i].i_int == i_output_mode)
mode_available = true;
}
- free(vals.p_values);
+ free(vals);
}
if (!mode_available)
i_output_mode = i_default_mode;
diff --git a/src/input/input.c b/src/input/input.c
index c20f7539d6..a4136838dd 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -3277,7 +3277,7 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
return VLC_SUCCESS;
/* Select the ES */
- vlc_list_t list;
+ vlc_value_t *list;
size_t entries;
if( var_Change( p_input, psz_es, VLC_VAR_GETCHOICES,
@@ -3290,12 +3290,12 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
if( count < entries )
{
- const int i_id = list.p_values[count].i_int;
+ const int i_id = list[count].i_int;
es_out_Control( input_priv(p_input)->p_es_out_display, ES_OUT_SET_ES_DEFAULT_BY_ID, i_id );
es_out_Control( input_priv(p_input)->p_es_out_display, ES_OUT_SET_ES_BY_ID, i_id );
}
- free(list.p_values);
+ free(list);
return VLC_SUCCESS;
}
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 04979dc512..d53364258a 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -545,18 +545,17 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name, int i_action, ...)
case VLC_VAR_GETCHOICES:
{
size_t *count = va_arg(ap, size_t *);
- vlc_list_t *values = va_arg(ap, vlc_list_t *);
+ vlc_value_t **values = va_arg(ap, vlc_value_t **);
char ***texts = va_arg(ap, char ***);
*count = p_var->choices_count;
- values->i_type = p_var->i_type;
- values->i_count = *count;
- values->p_values = xmalloc(*count * sizeof (values->p_values));
+ *values = xmalloc(p_var->choices_count * sizeof (**values));
for (size_t i = 0; i < p_var->choices_count; i++)
{
- values->p_values[i] = p_var->choices[i];
- p_var->ops->pf_dup( &values->p_values[i] );
+ vlc_value_t *val = (*values) + i;
+ *val = p_var->choices[i];
+ p_var->ops->pf_dup(val);
}
if( texts != NULL )
diff --git a/test/src/misc/variables.c b/test/src/misc/variables.c
index 54c39a53ed..24080b83be 100644
--- a/test/src/misc/variables.c
+++ b/test/src/misc/variables.c
@@ -324,7 +324,7 @@ static void test_limits( libvlc_int_t *p_libvlc )
static void test_choices( libvlc_int_t *p_libvlc )
{
vlc_value_t val;
- vlc_list_t vals;
+ vlc_value_t *vals;
char **texts;
size_t count;
@@ -341,11 +341,10 @@ static void test_choices( libvlc_int_t *p_libvlc )
assert( var_CountChoices( p_libvlc, "bla" ) == 1 );
var_Change( p_libvlc, "bla", VLC_VAR_GETCHOICES, &count, &vals, &texts );
- assert( count == 1 && vals.i_count == 1 && vals.p_values[0].i_int == 1 &&
- !strcmp( texts[0], "one" ) );
+ assert( count == 1 && vals[0].i_int == 1 && !strcmp( texts[0], "one" ) );
free(texts[0]);
free(texts);
- free(vals.p_values);
+ free(vals);
var_Change( p_libvlc, "bla", VLC_VAR_CLEARCHOICES );
assert( var_CountChoices( p_libvlc, "bla" ) == 0 );
More information about the vlc-commits
mailing list