[vlc-commits] variables: use char *** for VLC_VAR_GETCHOICES texts

Rémi Denis-Courmont git at videolan.org
Sun Jun 10 12:11:25 CEST 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jun  9 17:41:54 2018 +0300| [34925c7cb582d56a3a40bcbd3fb2f42073afeb76] | committer: Rémi Denis-Courmont

variables: use char *** for VLC_VAR_GETCHOICES texts

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=34925c7cb582d56a3a40bcbd3fb2f42073afeb76
---

 include/vlc_variables.h                         |  2 +-
 lib/audio.c                                     |  2 +-
 lib/media_player.c                              |  5 ++-
 lib/video.c                                     |  6 +--
 modules/control/gestures.c                      |  4 +-
 modules/control/hotkeys.c                       | 55 ++++++++++++++-----------
 modules/control/oldrc.c                         | 30 +++++++-------
 modules/gui/macosx/VLCMainMenu.m                |  9 ++--
 modules/gui/ncurses.c                           |  2 +-
 modules/gui/qt/components/controller_widget.cpp |  5 ++-
 modules/gui/qt/components/extended_panels.cpp   | 11 ++---
 modules/gui/qt/input_manager.cpp                |  7 ++--
 modules/gui/qt/menus.cpp                        |  5 ++-
 modules/lua/libs/variables.c                    | 12 +++++-
 src/audio_output/output.c                       |  2 +-
 src/input/input.c                               |  2 +-
 src/misc/variables.c                            | 21 ++++------
 test/src/misc/variables.c                       |  6 +--
 18 files changed, 98 insertions(+), 88 deletions(-)

diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index 4cf328822a..fc0f1e351f 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -212,7 +212,7 @@ VLC_API int var_Inherit( vlc_object_t *, const char *, int, vlc_value_t * );
  * @param p_val: the list variable
  * @param p_val2: the variable associated or NULL
  */
-VLC_API void var_FreeList( vlc_list_t *, vlc_list_t * );
+VLC_API void var_FreeList( vlc_list_t *, char *** );
 
 
 /*****************************************************************************
diff --git a/lib/audio.c b/lib/audio.c
index 23280ff60a..33758332fb 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -388,7 +388,7 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
         return -1;
 
     var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list,
-                (vlc_list_t *)NULL );
+                (char ***)NULL );
     for( int i = 0; i < val_list.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 dc5813227a..541e5090fd 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -1788,7 +1788,8 @@ libvlc_track_description_t *
     if( !p_input )
         return NULL;
 
-    vlc_list_t val_list, text_list;
+    vlc_list_t val_list;
+    char **text_list;
     int i_ret = var_Change( p_input, psz_variable, VLC_VAR_GETCHOICES, &val_list, &text_list );
     if( i_ret != VLC_SUCCESS )
         return NULL;
@@ -1820,7 +1821,7 @@ libvlc_track_description_t *
             }
         }
         p_actual->i_id = val_list.p_values[i].i_int;
-        p_actual->psz_name = strdup( text_list.p_values[i].psz_string );
+        p_actual->psz_name = strdup( text_list[i] );
         p_actual->p_next = NULL;
         if( p_previous )
             p_previous->p_next = p_actual;
diff --git a/lib/video.c b/lib/video.c
index d34862e8b0..828d167db3 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -360,7 +360,7 @@ int libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu )
         return -1;
 
     var_Change(p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list,
-               (vlc_list_t *)NULL);
+               (char ***)NULL);
     for (int i = 0; i < list.i_count; i++)
     {
         if( i_spu == list.p_values[i].i_int )
@@ -453,7 +453,7 @@ static void teletext_enable( input_thread_t *p_input_thread, bool b_enable )
     {
         vlc_list_t list;
         if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETCHOICES,
-                         &list, (vlc_list_t *)NULL ) )
+                         &list, (char ***)NULL ) )
         {
             if( list.i_count > 0 )
                 var_SetInteger( p_input_thread, "spu-es",
@@ -575,7 +575,7 @@ int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
         return -1;
 
     var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list,
-                (vlc_list_t *)NULL );
+                (char ***)NULL );
     for( int i = 0; i < val_list.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 1b27182618..9585973096 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -279,7 +279,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
 
             vlc_list_t list;
             var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
-                        &list, (vlc_list_t *)NULL );
+                        &list, (char ***)NULL );
 
             if( list.i_count > 1 )
             {
@@ -316,7 +316,7 @@ static void ProcessGesture( intf_thread_t *p_intf )
 
             vlc_list_t list;
             var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
-                        &list, (vlc_list_t *)NULL );
+                        &list, (char ***)NULL );
 
             if( list.i_count > 1 )
             {
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 5321b6771f..7271fad777 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -632,7 +632,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
 
                 var_Get( p_input, "spu-es", &val );
                 var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
-                            &list, (vlc_list_t *)NULL );
+                            &list, (char ***)NULL );
 
                 if( list.i_count < 1 || val.i_int < 0 )
                 {
@@ -701,7 +701,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
 
                 var_Get( p_input, "spu-es", &val );
                 var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
-                            &list, (vlc_list_t *)NULL );
+                            &list, (char ***)NULL );
 
                 if( list.i_count < 1 || val.i_int < 0 )
                 {
@@ -740,7 +740,8 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
             if( p_input )
             {
                 vlc_value_t val;
-                vlc_list_t list, list2;
+                vlc_list_t list;
+                char **list2;
 
                 var_Get( p_input, "audio-es", &val );
                 var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
@@ -769,8 +770,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                     else
                         i++;
                     var_Set( p_input, "audio-es", list.p_values[i] );
-                    DisplayMessage( p_vout, _("Audio track: %s"),
-                                    list2.p_values[i].psz_string );
+                    DisplayMessage( p_vout, _("Audio track: %s"), list2[i] );
                 }
                 var_FreeList( &list, &list2 );
             }
@@ -781,7 +781,8 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
             if( p_input )
             {
                 vlc_value_t val;
-                vlc_list_t list, list2;
+                vlc_list_t list;
+                char **list2;
                 int i;
                 var_Get( p_input, "spu-es", &val );
 
@@ -816,15 +817,15 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                 else
                     i = (i_action == ACTIONID_SUBTITLE_TRACK) ? i+1 : i-1;
                 var_SetInteger( p_input, "spu-es", list.p_values[i].i_int );
-                DisplayMessage( p_vout, _("Subtitle track: %s"),
-                                list2.p_values[i].psz_string );
+                DisplayMessage( p_vout, _("Subtitle track: %s"), list2[i] );
                 var_FreeList( &list, &list2 );
             }
             break;
         case ACTIONID_SUBTITLE_TOGGLE:
             if( p_input )
             {
-                vlc_list_t list, list2;
+                vlc_list_t list;
+                char **list2;
 
                 var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
                             &list, &list2 );
@@ -868,7 +869,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                 }
                 var_SetInteger( p_input, "spu-es", list.p_values[i_new_index].i_int );
                 DisplayMessage( p_vout, _("Subtitle track: %s"),
-                                list2.p_values[i_new_index].psz_string );
+                                list2[i_new_index] );
                 var_FreeList( &list, &list2 );
             }
             break;
@@ -877,7 +878,8 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
             if( p_input )
             {
                 vlc_value_t val;
-                vlc_list_t list, list2;
+                vlc_list_t list;
+                char **list2;
                 int i;
                 var_Get( p_input, "program", &val );
 
@@ -919,7 +921,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                     }
                 var_Set( p_input, "program", list.p_values[i] );
                 DisplayMessage( p_vout, _("Program Service ID: %s"),
-                                list2.p_values[i].psz_string );
+                                list2[i] );
                 var_FreeList( &list, &list2 );
             }
             break;
@@ -1044,7 +1046,8 @@ 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, text_list;
+                vlc_list_t val_list;
+                char **text_list;
 
                 var_Get( p_vout, "aspect-ratio", &val );
                 if( var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES,
@@ -1064,7 +1067,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                     var_SetString( p_vout, "aspect-ratio",
                                    val_list.p_values[i].psz_string );
                     DisplayMessage( p_vout, _("Aspect ratio: %s"),
-                                    text_list.p_values[i].psz_string );
+                                    text_list[i] );
 
                     var_FreeList( &val_list, &text_list );
                 }
@@ -1076,7 +1079,8 @@ 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, text_list;
+                vlc_list_t val_list;
+                char **text_list;
 
                 var_Get( p_vout, "crop", &val );
                 if( var_Change( p_vout, "crop", VLC_VAR_GETCHOICES,
@@ -1095,8 +1099,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                     if( i == val_list.i_count ) i = 0;
                     var_SetString( p_vout, "crop",
                                    val_list.p_values[i].psz_string );
-                    DisplayMessage( p_vout, _("Crop: %s"),
-                                    text_list.p_values[i].psz_string );
+                    DisplayMessage( p_vout, _("Crop: %s"), text_list[i] );
 
                     var_FreeList( &val_list, &text_list );
                 }
@@ -1226,7 +1229,8 @@ 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, text_list;
+                vlc_list_t val_list;
+                char **text_list;
 
                 var_Get( p_vout, "zoom", &val );
                 if( var_Change( p_vout, "zoom", VLC_VAR_GETCHOICES,
@@ -1248,8 +1252,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                     if( i == -1 ) i = val_list.i_count-1;
                     var_SetFloat( p_vout, "zoom",
                                   val_list.p_values[i].f_float );
-                    DisplayMessage( p_vout, _("Zoom mode: %s"),
-                                    text_list.p_values[i].psz_string );
+                    DisplayMessage( p_vout, _("Zoom mode: %s"), text_list[i] );
 
                     var_FreeList( &val_list, &text_list );
                 }
@@ -1270,7 +1273,8 @@ 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, tlist;
+                    vlc_list_t vlist;
+                    char **tlist;
                     if( psz_mode && !var_Change( p_vout, "deinterlace-mode", VLC_VAR_GETCHOICES, &vlist, &tlist ) )
                     {
                         const char *psz_text = NULL;
@@ -1278,7 +1282,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                         {
                             if( !strcmp( vlist.p_values[i].psz_string, psz_mode ) )
                             {
-                                psz_text = tlist.p_values[i].psz_string;
+                                psz_text = tlist[i];
                                 break;
                             }
                         }
@@ -1295,7 +1299,8 @@ 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, tlist;
+                vlc_list_t vlist;
+                char **tlist;
 
                 if( psz_mode && !var_Change( p_vout, "deinterlace-mode", VLC_VAR_GETCHOICES, &vlist, &tlist ))
                 {
@@ -1310,7 +1315,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                         }
                     }
                     if( i == vlist.i_count ) i = 0;
-                    psz_text = tlist.p_values[i].psz_string;
+                    psz_text = tlist[i];
                     var_SetString( p_vout, "deinterlace-mode", vlist.p_values[i].psz_string );
 
                     int i_deinterlace = var_GetInteger( p_vout, "deinterlace" );
@@ -1341,7 +1346,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
                 var_Get( p_input, "spu-es", &val );
 
                 var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
-                            &list, (vlc_list_t *)NULL );
+                            &list, (char ***)NULL );
                 if( list.i_count < 1 || val.i_int < 0 )
                 {
                     DisplayMessage( p_vout,
diff --git a/modules/control/oldrc.c b/modules/control/oldrc.c
index 7420e6733a..bd0bebb6e5 100644
--- a/modules/control/oldrc.c
+++ b/modules/control/oldrc.c
@@ -1122,7 +1122,8 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
         else
         {
             /* get */
-            vlc_list_t val, text;
+            vlc_list_t val;
+            char **text;
 
             int i_value = var_GetInteger( p_input, psz_variable );
 
@@ -1138,10 +1139,10 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
             {
                 if ( i_value == val.p_values[i].i_int )
                     msg_rc( "| %"PRId64" - %s *", val.p_values[i].i_int,
-                            text.p_values[i].psz_string );
+                            text[i] );
                 else
                     msg_rc( "| %"PRId64" - %s", val.p_values[i].i_int,
-                            text.p_values[i].psz_string );
+                            text[i] );
             }
             var_FreeList( &val, &text );
             msg_rc( "+----[ end of %s ]", name );
@@ -1556,7 +1557,8 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
     {
         /* get */
         char *name;
-        vlc_list_t val, text;
+        vlc_list_t val;
+        char **text;
         float f_value = 0.;
         char *psz_value = NULL;
 
@@ -1590,11 +1592,9 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
             for ( int i = 0; i < val.i_count; i++ )
             {
                 if ( f_value == val.p_values[i].f_float )
-                    msg_rc( "| %f - %s *", val.p_values[i].f_float,
-                            text.p_values[i].psz_string );
+                    msg_rc( "| %f - %s *", val.p_values[i].f_float, text[i] );
                 else
-                    msg_rc( "| %f - %s", val.p_values[i].f_float,
-                            text.p_values[i].psz_string );
+                    msg_rc( "| %f - %s", val.p_values[i].f_float, text[i] );
             }
         }
         else
@@ -1603,10 +1603,9 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
             {
                 if ( !strcmp( psz_value, val.p_values[i].psz_string ) )
                     msg_rc( "| %s - %s *", val.p_values[i].psz_string,
-                            text.p_values[i].psz_string );
+                            text[i] );
                 else
-                    msg_rc( "| %s - %s", val.p_values[i].psz_string,
-                            text.p_values[i].psz_string );
+                    msg_rc( "| %s - %s", val.p_values[i].psz_string, text[i] );
             }
             free( psz_value );
         }
@@ -1675,7 +1674,8 @@ static int AudioChannel( vlc_object_t *obj, char const *cmd,
     if ( !*cur.psz_string )
     {
         /* Retrieve all registered ***. */
-        vlc_list_t val, text;
+        vlc_list_t val;
+        char **text;
         if ( var_Change( p_aout, "stereo-mode",
                          VLC_VAR_GETCHOICES, &val, &text ) < 0 )
         {
@@ -1689,11 +1689,9 @@ static int AudioChannel( vlc_object_t *obj, char const *cmd,
         for ( int i = 0; i < val.i_count; i++ )
         {
             if ( i_value == val.p_values[i].i_int )
-                msg_rc( "| %"PRId64" - %s *", val.p_values[i].i_int,
-                        text.p_values[i].psz_string );
+                msg_rc( "| %"PRId64" - %s *", val.p_values[i].i_int, text[i] );
             else
-                msg_rc( "| %"PRId64" - %s", val.p_values[i].i_int,
-                        text.p_values[i].psz_string );
+                msg_rc( "| %"PRId64" - %s", val.p_values[i].i_int, text[i] );
         }
         var_FreeList( &val, &text );
         msg_rc( "+----[ end of %s ]", cmd );
diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m
index 1ca3eda65d..510d87c1a5 100644
--- a/modules/gui/macosx/VLCMainMenu.m
+++ b/modules/gui/macosx/VLCMainMenu.m
@@ -1448,7 +1448,8 @@
             selector:(SEL)pf_callback
 {
     vlc_value_t val;
-    vlc_list_t val_list, text_list;
+    vlc_list_t val_list;
+    char **text_list;
     int i_type, i;
 
     /* remove previous items */
@@ -1514,7 +1515,7 @@
         switch(i_type & VLC_VAR_TYPE) {
             case VLC_VAR_STRING:
 
-                title = _NS(text_list.p_values[i].psz_string ? text_list.p_values[i].psz_string : val_list.p_values[i].psz_string);
+                title = _NS(text_list[i] ? text_list[i] : val_list.p_values[i].psz_string);
 
                 lmi = [menu addItemWithTitle: title action: pf_callback keyEquivalent: @""];
                 data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
@@ -1529,8 +1530,8 @@
 
             case VLC_VAR_INTEGER:
 
-                title = text_list.p_values[i].psz_string ?
-                _NS(text_list.p_values[i].psz_string) : [NSString stringWithFormat: @"%"PRId64, val_list.p_values[i].i_int];
+                title = text_list[i] ?
+                _NS(text_list[i]) : [NSString stringWithFormat: @"%"PRId64, val_list.p_values[i].i_int];
 
                 lmi = [menu addItemWithTitle: title action: pf_callback keyEquivalent: @""];
                 data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
diff --git a/modules/gui/ncurses.c b/modules/gui/ncurses.c
index c645f43bf6..0e96fd727c 100644
--- a/modules/gui/ncurses.c
+++ b/modules/gui/ncurses.c
@@ -1540,7 +1540,7 @@ static void CycleESTrack(input_thread_t *input, const char *var)
 
     vlc_list_t list;
     if (var_Change(input, var, VLC_VAR_GETCHOICES, &list,
-                   (vlc_list_t *)NULL) < 0)
+                   (char ***)NULL) < 0)
         return;
 
     int64_t current = var_GetInteger(input, var);
diff --git a/modules/gui/qt/components/controller_widget.cpp b/modules/gui/qt/components/controller_widget.cpp
index 24e5372846..285b2cdcd2 100644
--- a/modules/gui/qt/components/controller_widget.cpp
+++ b/modules/gui/qt/components/controller_widget.cpp
@@ -268,7 +268,8 @@ void AspectRatioComboBox::updateRatios()
 {
     /* Clear the list before updating */
     clear();
-    vlc_list_t val_list, text_list;
+    vlc_list_t val_list;
+    char **text_list;
     vout_thread_t* p_vout = THEMIM->getVout();
 
     /* Disable if there is no vout */
@@ -281,7 +282,7 @@ void AspectRatioComboBox::updateRatios()
 
     var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES, &val_list, &text_list );
     for( int i = 0; i < val_list.i_count; i++ )
-        addItem( qfu( text_list.p_values[i].psz_string ),
+        addItem( qfu( text_list[i] ),
                  QString( val_list.p_values[i].psz_string ) );
     setEnabled( true );
     var_FreeList( &val_list, &text_list );
diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp
index 25b192ffdd..075002386a 100644
--- a/modules/gui/qt/components/extended_panels.cpp
+++ b/modules/gui/qt/components/extended_panels.cpp
@@ -651,7 +651,8 @@ void ExtV4l2::Refresh( void )
     }
     if( p_obj )
     {
-        vlc_list_t val, text;
+        vlc_list_t val;
+        char **text;
         int i_ret = var_Change( p_obj, "controls", VLC_VAR_GETCHOICES,
                                 &val, &text );
         if( i_ret < 0 )
@@ -670,7 +671,7 @@ void ExtV4l2::Refresh( void )
         for( int i = 0; i < val.i_count; i++ )
         {
             char *vartext;
-            const char *psz_var = text.p_values[i].psz_string;
+            const char *psz_var = text[i];
 
             if( var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &vartext ) )
                 continue;
@@ -694,13 +695,13 @@ void ExtV4l2::Refresh( void )
                         QComboBox *combobox = new QComboBox( box );
                         combobox->setObjectName( qfu( psz_var ) );
 
-                        vlc_list_t val2, text2;
+                        vlc_list_t val2;
+                        char **text2;
                         var_Change( p_obj, psz_var, VLC_VAR_GETCHOICES,
                                     &val2, &text2 );
                         for( int j = 0; j < val2.i_count; j++ )
                         {
-                            combobox->addItem(
-                                       text2.p_values[j].psz_string,
+                            combobox->addItem( text2[j],
                                        qlonglong( val2.p_values[j].i_int) );
                             if( i_val == val2.p_values[j].i_int )
                                 combobox->setCurrentIndex( j );
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index 8a3fc596ae..6d670e1610 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -859,7 +859,8 @@ void InputManager::telexSetTransparency( bool b_transparentTelextext )
 
 void InputManager::activateTeletext( bool b_enable )
 {
-    vlc_list_t list, text;
+    vlc_list_t list;
+    char **text;
 
     if( hasInput() && !var_Change( p_input, "teletext-es", VLC_VAR_GETCHOICES, &list, &text ) )
     {
@@ -867,10 +868,10 @@ void InputManager::activateTeletext( bool b_enable )
         {
             /* Prefer the page 100 if it is present */
             int i;
-            for( i = 0; i < text.i_count; i++ )
+            for( i = 0; i < list.i_count; i++ )
             {
                 /* The description is the page number as a string */
-                const char *psz_page = text.p_values[i].psz_string;
+                const char *psz_page = text[i];
                 if( psz_page && !strcmp( psz_page, "100" ) )
                     break;
             }
diff --git a/modules/gui/qt/menus.cpp b/modules/gui/qt/menus.cpp
index a848feb0a4..ab36e7a413 100644
--- a/modules/gui/qt/menus.cpp
+++ b/modules/gui/qt/menus.cpp
@@ -1375,7 +1375,8 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
                                    vlc_object_t *p_object )
 {
     vlc_value_t val;
-    vlc_list_t val_list, text_list;
+    vlc_list_t val_list;
+    char **text_list;
     int i_type, i;
 
     /* Check the type of the object variable */
@@ -1405,7 +1406,7 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
     }
 
 #define CURVAL val_list.p_values[i]
-#define CURTEXT text_list.p_values[i].psz_string
+#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++ )
diff --git a/modules/lua/libs/variables.c b/modules/lua/libs/variables.c
index bd34eedbaa..3e74f34487 100644
--- a/modules/lua/libs/variables.c
+++ b/modules/lua/libs/variables.c
@@ -235,7 +235,8 @@ static int vlclua_var_create( lua_State *L )
 
 static int vlclua_var_get_list( lua_State *L )
 {
-    vlc_list_t val, text;
+    vlc_list_t val;
+    char **text;
     vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
     const char *psz_var = luaL_checkstring( L, 2 );
 
@@ -244,7 +245,14 @@ static int vlclua_var_get_list( lua_State *L )
         return vlclua_push_ret( L, i_ret );
 
     vlclua_pushlist( L, &val );
-    vlclua_pushlist( L, &text );
+
+    lua_createtable( L, val.i_count, 0 );
+    for( int i = 0; i < val.i_count; i++ )
+    {
+        lua_pushinteger( L, i + 1 );
+        lua_pushstring( L, text[i] );
+        lua_settable( L, -3 );
+    }
 
     var_FreeList( &val, &text );
     return 2;
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 6d3f3c7125..e35d2f7539 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -473,7 +473,7 @@ 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,
-                    (vlc_list_t *)NULL))
+                    (char ***)NULL))
     {
         for (int i = 0; !mode_available && i < vals.i_count; ++i)
         {
diff --git a/src/input/input.c b/src/input/input.c
index b3d69f08b5..3aba8fdc5c 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -3280,7 +3280,7 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
     vlc_list_t list;
 
     if( var_Change( p_input, psz_es, VLC_VAR_GETCHOICES, &list,
-                    (vlc_list_t *)NULL ) )
+                    (char ***)NULL ) )
         return VLC_SUCCESS;
 
     if( count == 0 )
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 273d17d3c2..58f3760b4c 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -552,7 +552,7 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name, int i_action, ...)
         case VLC_VAR_GETCHOICES:
         {
             vlc_list_t *values = va_arg(ap, vlc_list_t *);
-            vlc_list_t *texts = va_arg(ap, vlc_list_t *);
+            char ***texts = va_arg(ap, char ***);
 
             values->p_values =
                 xmalloc( p_var->choices.i_count * sizeof(vlc_value_t) );
@@ -567,17 +567,12 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name, int i_action, ...)
 
             if( texts != NULL )
             {
-                texts->p_values =
-                    xmalloc( p_var->choices.i_count * sizeof(vlc_value_t) );
-                texts->i_type = VLC_VAR_STRING;
-                texts->i_count = p_var->choices.i_count;
+                *texts = xmalloc( p_var->choices.i_count * sizeof(char *) );
 
                 for( int i = 0 ; i < p_var->choices.i_count ; i++ )
-                {
-                    texts->p_values[i].psz_string =
+                    (*texts)[i] =
                         p_var->choices_text.p_values[i].psz_string
                             ? strdup(p_var->choices_text.p_values[i].psz_string) : NULL;
-                }
             }
             break;
         }
@@ -1135,7 +1130,7 @@ error:
     return VLC_EGENERIC;
 }
 
-void var_FreeList( vlc_list_t *values, vlc_list_t *texts )
+void var_FreeList( vlc_list_t *values, char ***texts )
 {
     switch( values->i_type & VLC_VAR_CLASS )
     {
@@ -1149,11 +1144,9 @@ void var_FreeList( vlc_list_t *values, vlc_list_t *texts )
 
     if( texts != NULL )
     {
-        assert( texts->i_type == VLC_VAR_STRING );
-
-        for( int i = 0; i < texts->i_count; i++ )
-            free( texts->p_values[i].psz_string );
-        free( texts->p_values );
+        for( int i = 0; i < values->i_count; i++ )
+            free( (*texts)[i] );
+        free( *texts );
     }
 }
 
diff --git a/test/src/misc/variables.c b/test/src/misc/variables.c
index 877ea22d47..5cc1770544 100644
--- a/test/src/misc/variables.c
+++ b/test/src/misc/variables.c
@@ -324,7 +324,8 @@ 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, texts;
+    vlc_list_t vals;
+    char **texts;
 
     var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
     val.i_int = 1;
@@ -340,8 +341,7 @@ static void test_choices( libvlc_int_t *p_libvlc )
 
     var_Change( p_libvlc, "bla", VLC_VAR_GETCHOICES, &vals, &texts );
     assert( vals.i_count == 1 && vals.p_values[0].i_int == 1 &&
-            texts.i_count == 1 &&
-            !strcmp( texts.p_values[0].psz_string, "one" ) );
+            !strcmp( texts[0], "one" ) );
     var_FreeList( &vals, &texts );
 
     var_Change( p_libvlc, "bla", VLC_VAR_CLEARCHOICES );



More information about the vlc-commits mailing list