[vlc-commits] variables: add count parameter for VLC_VAR_GETCHOICES
Rémi Denis-Courmont
git at videolan.org
Sun Jun 10 12:11:27 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jun 10 10:58:43 2018 +0300| [5e50399a4582895d3e505c8ae1164016e985e1d7] | committer: Rémi Denis-Courmont
variables: add count parameter for VLC_VAR_GETCHOICES
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5e50399a4582895d3e505c8ae1164016e985e1d7
---
lib/audio.c | 7 +-
lib/media_player.c | 9 +-
lib/video.c | 20 ++--
modules/control/gestures.c | 28 +++---
modules/control/hotkeys.c | 117 ++++++++++++------------
modules/control/oldrc.c | 24 +++--
modules/gui/macosx/VLCMainMenu.m | 9 +-
modules/gui/ncurses.c | 12 ++-
modules/gui/qt/components/controller_widget.cpp | 7 +-
modules/gui/qt/components/extended_panels.cpp | 12 ++-
modules/gui/qt/input_manager.cpp | 12 ++-
modules/gui/qt/menus.cpp | 7 +-
modules/lua/libs/variables.c | 32 +++----
src/audio_output/output.c | 8 +-
src/input/input.c | 7 +-
src/misc/variables.c | 2 +
test/src/misc/variables.c | 5 +-
17 files changed, 176 insertions(+), 142 deletions(-)
diff --git a/lib/audio.c b/lib/audio.c
index 33758332fb..5ec8687a1c 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -382,14 +382,15 @@ 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;
+ size_t count;
int i_ret = -1;
if( !p_input_thread )
return -1;
- var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list,
- (char ***)NULL );
- for( int i = 0; i < val_list.i_count; i++ )
+ var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES,
+ &count, &val_list, (char ***)NULL );
+ for( size_t i = 0; i < count; i++ )
{
if( i_track == val_list.p_values[i].i_int )
{
diff --git a/lib/media_player.c b/lib/media_player.c
index 541e5090fd..3d6474e6f5 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1790,12 +1790,15 @@ libvlc_track_description_t *
vlc_list_t val_list;
char **text_list;
- int i_ret = var_Change( p_input, psz_variable, VLC_VAR_GETCHOICES, &val_list, &text_list );
+ size_t count;
+
+ int i_ret = var_Change( p_input, psz_variable, VLC_VAR_GETCHOICES,
+ &count, &val_list, &text_list );
if( i_ret != VLC_SUCCESS )
return NULL;
/* no tracks */
- if( val_list.i_count <= 0 )
+ if( count == 0 )
goto end;
p_track_description = malloc( sizeof *p_track_description );
@@ -1806,7 +1809,7 @@ libvlc_track_description_t *
}
p_actual = p_track_description;
p_previous = NULL;
- for( int i = 0; i < val_list.i_count; i++ )
+ for( size_t i = 0; i < count; i++ )
{
if( !p_actual )
{
diff --git a/lib/video.c b/lib/video.c
index 828d167db3..d4966fa57d 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -354,14 +354,15 @@ 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;
+ size_t count;
int i_ret = -1;
if( !p_input_thread )
return -1;
- var_Change(p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list,
- (char ***)NULL);
- for (int i = 0; i < list.i_count; i++)
+ var_Change(p_input_thread, "spu-es", VLC_VAR_GETCHOICES,
+ &count, &list, (char ***)NULL);
+ for (size_t i = 0; i < count; i++)
{
if( i_spu == list.p_values[i].i_int )
{
@@ -452,10 +453,12 @@ static void teletext_enable( input_thread_t *p_input_thread, bool b_enable )
if( b_enable )
{
vlc_list_t list;
+ size_t count;
+
if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETCHOICES,
- &list, (char ***)NULL ) )
+ &count, &list, (char ***)NULL ) )
{
- if( list.i_count > 0 )
+ if( count > 0 )
var_SetInteger( p_input_thread, "spu-es",
list.p_values[0].i_int );
@@ -569,14 +572,15 @@ 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;
+ size_t count;
int i_ret = -1;
if( !p_input_thread )
return -1;
- var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list,
- (char ***)NULL );
- for( int i = 0; i < val_list.i_count; i++ )
+ var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES,
+ &count, &val_list, (char ***)NULL );
+ for( size_t i = 0; i < count; i++ )
{
if( i_track == val_list.p_values[i].i_int )
{
diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index 9585973096..cf08f92bed 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -278,25 +278,27 @@ static void ProcessGesture( intf_thread_t *p_intf )
break;
vlc_list_t list;
+ size_t count;
+
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
- &list, (char ***)NULL );
+ &count, &list, (char ***)NULL );
- if( list.i_count > 1 )
+ if( count > 1 )
{
int i_audio_es = var_GetInteger( p_input, "audio-es" );
- int i;
+ size_t i;
- for( i = 0; i < list.i_count; i++ )
+ for( i = 0; i < count; i++ )
if( i_audio_es == list.p_values[i].i_int )
break;
/* value of audio-es was not in choices list */
- if( i == list.i_count )
+ if( i == count )
{
msg_Warn( p_input,
"invalid current audio track, selecting 0" );
i = 0;
}
- else if( i == list.i_count - 1 )
+ else if( i == count - 1 )
i = 1;
else
i++;
@@ -315,25 +317,27 @@ static void ProcessGesture( intf_thread_t *p_intf )
break;
vlc_list_t list;
+ size_t count;
+
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
- &list, (char ***)NULL );
+ &count, &list, (char ***)NULL );
- if( list.i_count > 1 )
+ if( count > 1 )
{
int i_audio_es = var_GetInteger( p_input, "spu-es" );
- int i;
+ size_t i;
- for( i = 0; i < list.i_count; i++ )
+ for( i = 0; i < count; i++ )
if( i_audio_es == list.p_values[i].i_int )
break;
/* value of audio-es was not in choices list */
- if( i == list.i_count )
+ if( i == count )
{
msg_Warn( p_input,
"invalid current subtitle track, selecting 0" );
i = 0;
}
- else if( i == list.i_count - 1 )
+ else if( i == count - 1 )
i = 1;
else
i++;
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 7271fad777..0ec2b04c29 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -629,12 +629,13 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{
vlc_value_t val;
vlc_list_t list;
+ size_t count;
var_Get( p_input, "spu-es", &val );
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
- &list, (char ***)NULL );
+ &count, &list, (char ***)NULL );
- if( list.i_count < 1 || val.i_int < 0 )
+ if( count < 1 || val.i_int < 0 )
{
DisplayMessage( p_vout, _("No active subtitle") );
var_FreeList( &list, NULL );
@@ -698,12 +699,13 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{
vlc_value_t val;
vlc_list_t list;
+ size_t count;
var_Get( p_input, "spu-es", &val );
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
- &list, (char ***)NULL );
+ &count, &list, (char ***)NULL );
- if( list.i_count < 1 || val.i_int < 0 )
+ if( count < 1 || val.i_int < 0 )
{
DisplayMessage( p_vout, _("No active subtitle") );
var_FreeList( &list, NULL );
@@ -742,16 +744,17 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
vlc_value_t val;
vlc_list_t list;
char **list2;
+ size_t count;
var_Get( p_input, "audio-es", &val );
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
- &list, &list2 );
+ &count, &list, &list2 );
- if( list.i_count > 1 )
+ if( count > 1 )
{
- int i;
+ size_t i;
- for( i = 0; i < list.i_count; i++ )
+ for( i = 0; i < count; i++ )
{
if( val.i_int == list.p_values[i].i_int )
{
@@ -759,13 +762,13 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
}
}
/* value of audio-es was not in choices list */
- if( i == list.i_count )
+ if( i == count )
{
msg_Warn( p_input,
"invalid current audio track, selecting 0" );
i = 0;
}
- else if( i == list.i_count - 1 )
+ else if( i == count - 1 )
i = 1;
else
i++;
@@ -783,37 +786,33 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
vlc_value_t val;
vlc_list_t list;
char **list2;
- int i;
+ size_t count, i;
var_Get( p_input, "spu-es", &val );
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
- &list, &list2 );
+ &count, &list, &list2 );
- if( list.i_count <= 1 )
+ if( count <= 1 )
{
DisplayMessage( p_vout, _("Subtitle track: %s"),
_("N/A") );
var_FreeList( &list, &list2 );
break;
}
- for( i = 0; i < list.i_count; i++ )
- {
+ for( i = 0; i < count; i++ )
if( val.i_int == list.p_values[i].i_int )
- {
break;
- }
- }
/* value of spu-es was not in choices list */
- if( i == list.i_count )
+ if( i == count )
{
msg_Warn( p_input,
"invalid current subtitle track, selecting 0" );
i = 0;
}
- else if ((i == list.i_count - 1) && (i_action == ACTIONID_SUBTITLE_TRACK))
+ else if ((i == count - 1) && (i_action == ACTIONID_SUBTITLE_TRACK))
i = 0;
else if ((i == 0) && (i_action == ACTIONID_SUBTITLE_REVERSE_TRACK))
- i = list.i_count - 1;
+ 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 );
@@ -826,11 +825,12 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{
vlc_list_t list;
char **list2;
+ size_t count;
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
- &list, &list2 );
+ &count, &list, &list2 );
- if( list.i_count <= 1 )
+ if( count <= 1 )
{
DisplayMessage( p_vout, _("Subtitle track: %s"),
_("N/A") );
@@ -858,7 +858,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
/* if subtitles were disabled with no saved id, use the first track */
if( i_cur_id != -1 || i_new_id != -1 )
{
- for( int i = 0; i < list.i_count; ++i )
+ for( size_t i = 0; i < count; ++i )
{
if( i_new_id == list.p_values[i].i_int )
{
@@ -880,42 +880,38 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
vlc_value_t val;
vlc_list_t list;
char **list2;
- int i;
+ size_t count, i;
var_Get( p_input, "program", &val );
var_Change( p_input, "program", VLC_VAR_GETCHOICES,
- &list, &list2 );
+ &count, &list, &list2 );
- if( list.i_count <= 1 )
+ if( count <= 1 )
{
DisplayMessage( p_vout, _("Program Service ID: %s"),
_("N/A") );
var_FreeList( &list, &list2 );
break;
}
- for( i = 0; i < list.i_count; i++ )
- {
+ for( i = 0; i < count; i++ )
if( val.i_int == list.p_values[i].i_int )
- {
break;
- }
- }
/* value of program sid was not in choices list */
- if( i == list.i_count )
+ if( i == count )
{
msg_Warn( p_input,
"invalid current program SID, selecting 0" );
i = 0;
}
else if( i_action == ACTIONID_PROGRAM_SID_NEXT ) {
- if( i == list.i_count - 1 )
+ if( i == count - 1 )
i = 0;
else
i++;
}
else { /* ACTIONID_PROGRAM_SID_PREV */
if( i == 0 )
- i = list.i_count - 1;
+ i = count - 1;
else
i--;
}
@@ -1048,13 +1044,14 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
vlc_value_t val;
vlc_list_t val_list;
char **text_list;
+ size_t count;
var_Get( p_vout, "aspect-ratio", &val );
if( var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES,
- &val_list, &text_list ) >= 0 )
+ &count, &val_list, &text_list ) >= 0 )
{
- int i;
- for( i = 0; i < val_list.i_count; i++ )
+ size_t i;
+ for( i = 0; i < count; i++ )
{
if( !strcmp( val_list.p_values[i].psz_string,
val.psz_string ) )
@@ -1063,7 +1060,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
break;
}
}
- if( i == val_list.i_count ) i = 0;
+ if( i == count ) i = 0;
var_SetString( p_vout, "aspect-ratio",
val_list.p_values[i].psz_string );
DisplayMessage( p_vout, _("Aspect ratio: %s"),
@@ -1081,13 +1078,14 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
vlc_value_t val;
vlc_list_t val_list;
char **text_list;
+ size_t count;
var_Get( p_vout, "crop", &val );
if( var_Change( p_vout, "crop", VLC_VAR_GETCHOICES,
- &val_list, &text_list ) >= 0 )
+ &count, &val_list, &text_list ) >= 0 )
{
- int i;
- for( i = 0; i < val_list.i_count; i++ )
+ size_t i;
+ for( i = 0; i < count; i++ )
{
if( !strcmp( val_list.p_values[i].psz_string,
val.psz_string ) )
@@ -1096,7 +1094,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
break;
}
}
- if( i == val_list.i_count ) i = 0;
+ if( i == count ) i = 0;
var_SetString( p_vout, "crop",
val_list.p_values[i].psz_string );
DisplayMessage( p_vout, _("Crop: %s"), text_list[i] );
@@ -1231,13 +1229,14 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
vlc_value_t val;
vlc_list_t val_list;
char **text_list;
+ size_t count;
var_Get( p_vout, "zoom", &val );
if( var_Change( p_vout, "zoom", VLC_VAR_GETCHOICES,
- &val_list, &text_list ) >= 0 )
+ &count, &val_list, &text_list ) >= 0 )
{
- int i;
- for( i = 0; i < val_list.i_count; i++ )
+ size_t i;
+ for( i = 0; i < count; i++ )
{
if( val_list.p_values[i].f_float == val.f_float )
{
@@ -1248,8 +1247,8 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
break;
}
}
- if( i == val_list.i_count ) i = 0;
- if( i == -1 ) i = val_list.i_count-1;
+ 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 );
DisplayMessage( p_vout, _("Zoom mode: %s"), text_list[i] );
@@ -1275,10 +1274,12 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
char *psz_mode = var_GetString( p_vout, "deinterlace-mode" );
vlc_list_t vlist;
char **tlist;
- if( psz_mode && !var_Change( p_vout, "deinterlace-mode", VLC_VAR_GETCHOICES, &vlist, &tlist ) )
+ size_t count;
+
+ if( psz_mode && !var_Change( p_vout, "deinterlace-mode", VLC_VAR_GETCHOICES, &count, &vlist, &tlist ) )
{
const char *psz_text = NULL;
- for( int i = 0; i < vlist.i_count; i++ )
+ for( size_t i = 0; i < count; i++ )
{
if( !strcmp( vlist.p_values[i].psz_string, psz_mode ) )
{
@@ -1301,12 +1302,14 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
char *psz_mode = var_GetString( p_vout, "deinterlace-mode" );
vlc_list_t vlist;
char **tlist;
+ size_t count;
- if( psz_mode && !var_Change( p_vout, "deinterlace-mode", VLC_VAR_GETCHOICES, &vlist, &tlist ))
+ if( psz_mode && !var_Change( p_vout, "deinterlace-mode", VLC_VAR_GETCHOICES, &count, &vlist, &tlist ))
{
const char *psz_text = NULL;
- int i;
- for( i = 0; i < vlist.i_count; i++ )
+ size_t i;
+
+ for( i = 0; i < count; i++ )
{
if( !strcmp( vlist.p_values[i].psz_string, psz_mode ) )
{
@@ -1314,7 +1317,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
break;
}
}
- if( i == vlist.i_count ) i = 0;
+ if( i == count ) i = 0;
psz_text = tlist[i];
var_SetString( p_vout, "deinterlace-mode", vlist.p_values[i].psz_string );
@@ -1343,11 +1346,13 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
{
vlc_value_t val;
vlc_list_t list;
+ size_t count;
+
var_Get( p_input, "spu-es", &val );
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
- &list, (char ***)NULL );
- if( list.i_count < 1 || val.i_int < 0 )
+ &count, &list, (char ***)NULL );
+ if( count < 1 || val.i_int < 0 )
{
DisplayMessage( p_vout,
_("Subtitle position: no active subtitle") );
diff --git a/modules/control/oldrc.c b/modules/control/oldrc.c
index bd0bebb6e5..6a03c6108f 100644
--- a/modules/control/oldrc.c
+++ b/modules/control/oldrc.c
@@ -1124,18 +1124,19 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
/* get */
vlc_list_t val;
char **text;
+ size_t count;
int i_value = var_GetInteger( p_input, psz_variable );
- if ( var_Change( p_input, psz_variable,
- VLC_VAR_GETCHOICES, &val, &text ) < 0 )
+ if ( var_Change( p_input, psz_variable, VLC_VAR_GETCHOICES,
+ &count, &val, &text ) < 0 )
{
free( name );
goto out;
}
msg_rc( "+----[ %s ]", name );
- for ( int i = 0; i < val.i_count; i++ )
+ for ( size_t i = 0; i < count; i++ )
{
if ( i_value == val.p_values[i].i_int )
msg_rc( "| %"PRId64" - %s *", val.p_values[i].i_int,
@@ -1561,6 +1562,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
char **text;
float f_value = 0.;
char *psz_value = NULL;
+ size_t count;
if( !strcmp( psz_variable, "zoom" ) )
f_value = var_GetFloat( p_vout, "zoom" );
@@ -1574,8 +1576,8 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
}
}
- if ( var_Change( p_vout, psz_variable,
- VLC_VAR_GETCHOICES, &val, &text ) < 0 )
+ if ( var_Change( p_vout, psz_variable, VLC_VAR_GETCHOICES,
+ &count, &val, &text ) < 0 )
{
vlc_object_release( p_vout );
free( psz_value );
@@ -1589,7 +1591,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
msg_rc( "+----[ %s ]", name );
if( !strcmp( psz_variable, "zoom" ) )
{
- for ( int i = 0; i < val.i_count; i++ )
+ for ( size_t i = 0; i < count; i++ )
{
if ( f_value == val.p_values[i].f_float )
msg_rc( "| %f - %s *", val.p_values[i].f_float, text[i] );
@@ -1599,7 +1601,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
}
else
{
- for ( int i = 0; i < val.i_count; i++ )
+ for ( size_t i = 0; i < count; i++ )
{
if ( !strcmp( psz_value, val.p_values[i].psz_string ) )
msg_rc( "| %s - %s *", val.p_values[i].psz_string,
@@ -1676,8 +1678,10 @@ static int AudioChannel( vlc_object_t *obj, char const *cmd,
/* Retrieve all registered ***. */
vlc_list_t val;
char **text;
- if ( var_Change( p_aout, "stereo-mode",
- VLC_VAR_GETCHOICES, &val, &text ) < 0 )
+ size_t count;
+
+ if ( var_Change( p_aout, "stereo-mode", VLC_VAR_GETCHOICES,
+ &count, &val, &text ) < 0 )
{
ret = VLC_ENOVAR;
goto out;
@@ -1686,7 +1690,7 @@ static int AudioChannel( vlc_object_t *obj, char const *cmd,
int i_value = var_GetInteger( p_aout, "stereo-mode" );
msg_rc( "+----[ %s ]", cmd );
- for ( int i = 0; i < val.i_count; i++ )
+ for ( size_t i = 0; i < count; i++ )
{
if ( i_value == val.p_values[i].i_int )
msg_rc( "| %"PRId64" - %s *", val.p_values[i].i_int, text[i] );
diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m
index 510d87c1a5..b86b60ba3e 100644
--- a/modules/gui/macosx/VLCMainMenu.m
+++ b/modules/gui/macosx/VLCMainMenu.m
@@ -1450,7 +1450,8 @@
vlc_value_t val;
vlc_list_t val_list;
char **text_list;
- int i_type, i;
+ size_t count, i;
+ int i_type;
/* remove previous items */
[menu removeAllItems];
@@ -1499,15 +1500,15 @@
}
if (var_Change(p_object, psz_variable, VLC_VAR_GETCHOICES,
- &val_list, &text_list) < 0) {
+ &count, &val_list, &text_list) < 0) {
if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
return;
}
/* make (un)sensitive */
- [parent setEnabled: (val_list.i_count > 1)];
+ [parent setEnabled: (count > 1)];
- for (i = 0; i < val_list.i_count; i++) {
+ for (i = 0; i < count; i++) {
NSMenuItem *lmi;
NSString *title = @"";
VLCAutoGeneratedMenuContent *data;
diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c
index 0e96fd727c..3ed37493da 100644
--- a/modules/gui/ncurses.c
+++ b/modules/gui/ncurses.c
@@ -1539,18 +1539,20 @@ static void CycleESTrack(input_thread_t *input, const char *var)
return;
vlc_list_t list;
- if (var_Change(input, var, VLC_VAR_GETCHOICES, &list,
- (char ***)NULL) < 0)
+ size_t count;
+
+ if (var_Change(input, var, VLC_VAR_GETCHOICES,
+ &count, &list, (char ***)NULL) < 0)
return;
int64_t current = var_GetInteger(input, var);
- int i;
- for (i = 0; i < list.i_count; i++)
+ size_t i;
+ for (i = 0; i < count; i++)
if (list.p_values[i].i_int == current)
break;
- if (++i >= list.i_count)
+ if (++i >= count)
i = 0;
var_SetInteger(input, var, list.p_values[i].i_int);
}
diff --git a/modules/gui/qt/components/controller_widget.cpp b/modules/gui/qt/components/controller_widget.cpp
index 285b2cdcd2..25184bc370 100644
--- a/modules/gui/qt/components/controller_widget.cpp
+++ b/modules/gui/qt/components/controller_widget.cpp
@@ -270,6 +270,8 @@ void AspectRatioComboBox::updateRatios()
clear();
vlc_list_t val_list;
char **text_list;
+ size_t count;
+
vout_thread_t* p_vout = THEMIM->getVout();
/* Disable if there is no vout */
@@ -280,8 +282,9 @@ void AspectRatioComboBox::updateRatios()
return;
}
- var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES, &val_list, &text_list );
- for( int i = 0; i < val_list.i_count; i++ )
+ var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES,
+ &count, &val_list, &text_list );
+ for( size_t i = 0; i < count; i++ )
addItem( qfu( text_list[i] ),
QString( val_list.p_values[i].psz_string ) );
setEnabled( true );
diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp
index 075002386a..f1a6638659 100644
--- a/modules/gui/qt/components/extended_panels.cpp
+++ b/modules/gui/qt/components/extended_panels.cpp
@@ -653,8 +653,10 @@ void ExtV4l2::Refresh( void )
{
vlc_list_t val;
char **text;
+ size_t count;
+
int i_ret = var_Change( p_obj, "controls", VLC_VAR_GETCHOICES,
- &val, &text );
+ &count, &val, &text );
if( i_ret < 0 )
{
msg_Err( p_intf, "Oops, v4l2 object doesn't have a 'controls' variable." );
@@ -668,7 +670,7 @@ void ExtV4l2::Refresh( void )
QVBoxLayout *layout = new QVBoxLayout( box );
box->setLayout( layout );
- for( int i = 0; i < val.i_count; i++ )
+ for( size_t i = 0; i < count; i++ )
{
char *vartext;
const char *psz_var = text[i];
@@ -697,9 +699,11 @@ void ExtV4l2::Refresh( void )
vlc_list_t val2;
char **text2;
+ size_t count2;
+
var_Change( p_obj, psz_var, VLC_VAR_GETCHOICES,
- &val2, &text2 );
- for( int j = 0; j < val2.i_count; j++ )
+ &count2, &val2, &text2 );
+ for( size_t j = 0; j < count2; j++ )
{
combobox->addItem( text2[j],
qlonglong( val2.p_values[j].i_int) );
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index 6d670e1610..529d88a8c5 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -861,21 +861,23 @@ void InputManager::activateTeletext( bool b_enable )
{
vlc_list_t list;
char **text;
+ size_t count;
- if( hasInput() && !var_Change( p_input, "teletext-es", VLC_VAR_GETCHOICES, &list, &text ) )
+ if( hasInput() && !var_Change( p_input, "teletext-es", VLC_VAR_GETCHOICES,
+ &count, &list, &text ) )
{
- if( list.i_count > 0 )
+ if( count > 0 )
{
/* Prefer the page 100 if it is present */
- int i;
- for( i = 0; i < list.i_count; i++ )
+ size_t i;
+ for( i = 0; i < count; i++ )
{
/* The description is the page number as a string */
const char *psz_page = text[i];
if( psz_page && !strcmp( psz_page, "100" ) )
break;
}
- if( i >= list.i_count )
+ if( i >= count )
i = 0;
var_SetInteger( p_input, "spu-es", b_enable ? list.p_values[i].i_int : -1 );
}
diff --git a/modules/gui/qt/menus.cpp b/modules/gui/qt/menus.cpp
index ab36e7a413..c2d44e4185 100644
--- a/modules/gui/qt/menus.cpp
+++ b/modules/gui/qt/menus.cpp
@@ -1377,7 +1377,8 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
vlc_value_t val;
vlc_list_t val_list;
char **text_list;
- int i_type, i;
+ size_t count, i;
+ int i_type;
/* Check the type of the object variable */
i_type = var_Type( p_object, psz_var );
@@ -1400,7 +1401,7 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
}
if( var_Change( p_object, psz_var, VLC_VAR_GETCHOICES,
- &val_list, &text_list ) < 0 )
+ &count, &val_list, &text_list ) < 0 )
{
return VLC_EGENERIC;
}
@@ -1409,7 +1410,7 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
#define CURTEXT text_list[i]
#define RADIO_OR_COMMAND ( i_type & ( VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE ) ) ? ITEM_RADIO : ITEM_NORMAL
- for( i = 0; i < val_list.i_count; i++ )
+ for( i = 0; i < count; i++ )
{
vlc_value_t another_val;
QString menutext;
diff --git a/modules/lua/libs/variables.c b/modules/lua/libs/variables.c
index 3e74f34487..ef0f1c3dcf 100644
--- a/modules/lua/libs/variables.c
+++ b/modules/lua/libs/variables.c
@@ -83,21 +83,6 @@ static int vlclua_pushvalue( lua_State *L, int i_type, vlc_value_t val )
return 1;
}
-static int vlclua_pushlist( lua_State *L, vlc_list_t *p_list )
-{
- int i_count = p_list->i_count;
-
- lua_createtable( L, i_count, 0 );
- for( int i = 0; i < i_count; i++ )
- {
- lua_pushinteger( L, i+1 );
- if( !vlclua_pushvalue( L, p_list->i_type, p_list->p_values[i] ) )
- lua_pushnil( L );
- lua_settable( L, -3 );
- }
- return 1;
-}
-
static int vlclua_tovalue( lua_State *L, int i_type, vlc_value_t *val )
{
switch( i_type & VLC_VAR_CLASS )
@@ -237,17 +222,26 @@ static int vlclua_var_get_list( lua_State *L )
{
vlc_list_t val;
char **text;
+ size_t count;
vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
const char *psz_var = luaL_checkstring( L, 2 );
- int i_ret = var_Change( *pp_obj, psz_var, VLC_VAR_GETCHOICES, &val, &text );
+ int i_ret = var_Change( *pp_obj, psz_var, VLC_VAR_GETCHOICES,
+ &count, &val, &text );
if( i_ret < 0 )
return vlclua_push_ret( L, i_ret );
- vlclua_pushlist( L, &val );
+ 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 );
+ lua_settable( L, -3 );
+ }
- lua_createtable( L, val.i_count, 0 );
- for( int i = 0; i < val.i_count; i++ )
+ lua_createtable( L, count, 0 );
+ for( size_t i = 0; i < count; i++ )
{
lua_pushinteger( L, i + 1 );
lua_pushstring( L, text[i] );
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index e35d2f7539..6c132668df 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -472,10 +472,12 @@ static void aout_PrepareStereoMode (audio_output_t *aout,
bool mode_available = false;
vlc_list_t vals;
- if (!var_Change(aout, "stereo-mode", VLC_VAR_GETCHOICES, &vals,
- (char ***)NULL))
+ size_t count;
+
+ if (!var_Change(aout, "stereo-mode", VLC_VAR_GETCHOICES,
+ &count, &vals, (char ***)NULL))
{
- for (int i = 0; !mode_available && i < vals.i_count; ++i)
+ for (size_t i = 0; !mode_available && i < count; ++i)
{
if (vals.p_values[i].i_int == i_output_mode)
mode_available = true;
diff --git a/src/input/input.c b/src/input/input.c
index 3aba8fdc5c..50cca381cd 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -3278,16 +3278,17 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
/* Select the ES */
vlc_list_t list;
+ size_t entries;
- if( var_Change( p_input, psz_es, VLC_VAR_GETCHOICES, &list,
- (char ***)NULL ) )
+ if( var_Change( p_input, psz_es, VLC_VAR_GETCHOICES,
+ &entries, &list, (char ***)NULL ) )
return VLC_SUCCESS;
if( count == 0 )
count++;
/* if it was first one, there is disable too */
- if( count < (size_t)list.i_count )
+ if( count < entries )
{
const int i_id = list.p_values[count].i_int;
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 58f3760b4c..a0a62ba714 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -551,9 +551,11 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name, int i_action, ...)
break;
case VLC_VAR_GETCHOICES:
{
+ size_t *count = va_arg(ap, size_t *);
vlc_list_t *values = va_arg(ap, vlc_list_t *);
char ***texts = va_arg(ap, char ***);
+ *count = p_var->choices.i_count;
values->p_values =
xmalloc( p_var->choices.i_count * sizeof(vlc_value_t) );
values->i_type = p_var->i_type;
diff --git a/test/src/misc/variables.c b/test/src/misc/variables.c
index 5cc1770544..a0a29b28cd 100644
--- a/test/src/misc/variables.c
+++ b/test/src/misc/variables.c
@@ -326,6 +326,7 @@ static void test_choices( libvlc_int_t *p_libvlc )
vlc_value_t val;
vlc_list_t vals;
char **texts;
+ size_t count;
var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
val.i_int = 1;
@@ -339,8 +340,8 @@ static void test_choices( libvlc_int_t *p_libvlc )
var_Change( p_libvlc, "bla", VLC_VAR_DELCHOICE, val );
assert( var_CountChoices( p_libvlc, "bla" ) == 1 );
- var_Change( p_libvlc, "bla", VLC_VAR_GETCHOICES, &vals, &texts );
- assert( vals.i_count == 1 && vals.p_values[0].i_int == 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" ) );
var_FreeList( &vals, &texts );
More information about the vlc-commits
mailing list