Commit 63ce4362 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

variables: pass vlc_list_t directly with VLC_VAR_GETCHOICES

parent 7b9b1e30
......@@ -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_value_t *, vlc_value_t * );
VLC_API void var_FreeList( vlc_list_t *, vlc_list_t * );
/*****************************************************************************
......
......@@ -381,17 +381,17 @@ 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_value_t val_list;
vlc_list_t val_list;
int i_ret = -1;
if( !p_input_thread )
return -1;
var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list,
(vlc_value_t *)NULL );
for( int i = 0; i < val_list.p_list->i_count; i++ )
(vlc_list_t *)NULL );
for( int i = 0; i < val_list.i_count; i++ )
{
if( i_track == val_list.p_list->p_values[i].i_int )
if( i_track == val_list.p_values[i].i_int )
{
if( var_SetInteger( p_input_thread, "audio-es", i_track ) < 0 )
break;
......
......@@ -1788,13 +1788,13 @@ libvlc_track_description_t *
if( !p_input )
return NULL;
vlc_value_t val_list, text_list;
vlc_list_t val_list, 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;
/* no tracks */
if( val_list.p_list->i_count <= 0 )
if( val_list.i_count <= 0 )
goto end;
p_track_description = malloc( sizeof *p_track_description );
......@@ -1805,7 +1805,7 @@ libvlc_track_description_t *
}
p_actual = p_track_description;
p_previous = NULL;
for( int i = 0; i < val_list.p_list->i_count; i++ )
for( int i = 0; i < val_list.i_count; i++ )
{
if( !p_actual )
{
......@@ -1819,8 +1819,8 @@ libvlc_track_description_t *
goto end;
}
}
p_actual->i_id = val_list.p_list->p_values[i].i_int;
p_actual->psz_name = strdup( text_list.p_list->p_values[i].psz_string );
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->p_next = NULL;
if( p_previous )
p_previous->p_next = p_actual;
......
......@@ -353,17 +353,17 @@ 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_value_t list;
vlc_list_t list;
int i_ret = -1;
if( !p_input_thread )
return -1;
var_Change(p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list,
(vlc_value_t *)NULL);
for (int i = 0; i < list.p_list->i_count; i++)
(vlc_list_t *)NULL);
for (int i = 0; i < list.i_count; i++)
{
if( i_spu == list.p_list->p_values[i].i_int )
if( i_spu == list.p_values[i].i_int )
{
if( var_SetInteger( p_input_thread, "spu-es", i_spu ) < 0 )
break;
......@@ -451,13 +451,13 @@ static void teletext_enable( input_thread_t *p_input_thread, bool b_enable )
{
if( b_enable )
{
vlc_value_t list;
vlc_list_t list;
if( !var_Change( p_input_thread, "teletext-es", VLC_VAR_GETCHOICES,
&list, (vlc_value_t *)NULL ) )
&list, (vlc_list_t *)NULL ) )
{
if( list.p_list->i_count > 0 )
if( list.i_count > 0 )
var_SetInteger( p_input_thread, "spu-es",
list.p_list->p_values[0].i_int );
list.p_values[0].i_int );
var_FreeList( &list, NULL );
}
......@@ -568,17 +568,17 @@ 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_value_t val_list;
vlc_list_t val_list;
int i_ret = -1;
if( !p_input_thread )
return -1;
var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list,
(vlc_value_t *)NULL );
for( int i = 0; i < val_list.p_list->i_count; i++ )
(vlc_list_t *)NULL );
for( int i = 0; i < val_list.i_count; i++ )
{
if( i_track == val_list.p_list->p_values[i].i_int )
if( i_track == val_list.p_values[i].i_int )
{
if( var_SetInteger( p_input_thread, "video-es", i_track ) < 0 )
break;
......
......@@ -277,31 +277,31 @@ static void ProcessGesture( intf_thread_t *p_intf )
if( p_input == NULL )
break;
vlc_value_t list, list2;
vlc_list_t list, list2;
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
&list, &list2 );
if( list.p_list->i_count > 1 )
if( list.i_count > 1 )
{
int i_audio_es = var_GetInteger( p_input, "audio-es" );
int i;
for( i = 0; i < list.p_list->i_count; i++ )
if( i_audio_es == list.p_list->p_values[i].i_int )
for( i = 0; i < list.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.p_list->i_count )
if( i == list.i_count )
{
msg_Warn( p_input,
"invalid current audio track, selecting 0" );
i = 0;
}
else if( i == list.p_list->i_count - 1 )
else if( i == list.i_count - 1 )
i = 1;
else
i++;
var_SetInteger( p_input, "audio-es",
list.p_list->p_values[i].i_int );
list.p_values[i].i_int );
}
var_FreeList( &list, &list2 );
vlc_object_release( p_input );
......@@ -314,31 +314,31 @@ static void ProcessGesture( intf_thread_t *p_intf )
if( p_input == NULL )
break;
vlc_value_t list, list2;
vlc_list_t list, list2;
var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
&list, &list2 );
if( list.p_list->i_count > 1 )
if( list.i_count > 1 )
{
int i_audio_es = var_GetInteger( p_input, "spu-es" );
int i;
for( i = 0; i < list.p_list->i_count; i++ )
if( i_audio_es == list.p_list->p_values[i].i_int )
for( i = 0; i < list.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.p_list->i_count )
if( i == list.i_count )
{
msg_Warn( p_input,
"invalid current subtitle track, selecting 0" );
i = 0;
}
else if( i == list.p_list->i_count - 1 )
else if( i == list.i_count - 1 )
i = 1;
else
i++;
var_SetInteger( p_input, "audio-es",
list.p_list->p_values[i].i_int );
list.p_values[i].i_int );
}
var_FreeList( &list, &list2 );
vlc_object_release( p_input );
......
This diff is collapsed.
......@@ -1122,7 +1122,7 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
else
{
/* get */
vlc_value_t val, text;
vlc_list_t val, text;
int i_value = var_GetInteger( p_input, psz_variable );
......@@ -1131,16 +1131,14 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
goto out;
msg_rc( "+----[ %s ]", val_name.psz_string );
for ( int i = 0; i < val.p_list->i_count; i++ )
for ( int i = 0; i < val.i_count; i++ )
{
if ( i_value == val.p_list->p_values[i].i_int )
msg_rc( "| %"PRId64" - %s *",
val.p_list->p_values[i].i_int,
text.p_list->p_values[i].psz_string );
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 );
else
msg_rc( "| %"PRId64" - %s",
val.p_list->p_values[i].i_int,
text.p_list->p_values[i].psz_string );
msg_rc( "| %"PRId64" - %s", val.p_values[i].i_int,
text.p_values[i].psz_string );
}
var_FreeList( &val, &text );
msg_rc( "+----[ end of %s ]", val_name.psz_string );
......@@ -1555,7 +1553,7 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
{
/* get */
vlc_value_t val_name;
vlc_value_t val, text;
vlc_list_t val, text;
float f_value = 0.;
char *psz_value = NULL;
......@@ -1586,26 +1584,26 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
msg_rc( "+----[ %s ]", val_name.psz_string );
if( !strcmp( psz_variable, "zoom" ) )
{
for ( int i = 0; i < val.p_list->i_count; i++ )
for ( int i = 0; i < val.i_count; i++ )
{
if ( f_value == val.p_list->p_values[i].f_float )
msg_rc( "| %f - %s *", val.p_list->p_values[i].f_float,
text.p_list->p_values[i].psz_string );
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 );
else
msg_rc( "| %f - %s", val.p_list->p_values[i].f_float,
text.p_list->p_values[i].psz_string );
msg_rc( "| %f - %s", val.p_values[i].f_float,
text.p_values[i].psz_string );
}
}
else
{
for ( int i = 0; i < val.p_list->i_count; i++ )
for ( int i = 0; i < val.i_count; i++ )
{
if ( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) )
msg_rc( "| %s - %s *", val.p_list->p_values[i].psz_string,
text.p_list->p_values[i].psz_string );
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 );
else
msg_rc( "| %s - %s", val.p_list->p_values[i].psz_string,
text.p_list->p_values[i].psz_string );
msg_rc( "| %s - %s", val.p_values[i].psz_string,
text.p_values[i].psz_string );
}
free( psz_value );
}
......@@ -1674,7 +1672,7 @@ static int AudioChannel( vlc_object_t *obj, char const *cmd,
if ( !*cur.psz_string )
{
/* Retrieve all registered ***. */
vlc_value_t val, text;
vlc_list_t val, text;
if ( var_Change( p_aout, "stereo-mode",
VLC_VAR_GETCHOICES, &val, &text ) < 0 )
{
......@@ -1685,14 +1683,14 @@ 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.p_list->i_count; i++ )
for ( int i = 0; i < val.i_count; i++ )
{
if ( i_value == val.p_list->p_values[i].i_int )
msg_rc( "| %"PRId64" - %s *", val.p_list->p_values[i].i_int,
text.p_list->p_values[i].psz_string );
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 );
else
msg_rc( "| %"PRId64" - %s", val.p_list->p_values[i].i_int,
text.p_list->p_values[i].psz_string );
msg_rc( "| %"PRId64" - %s", val.p_values[i].i_int,
text.p_values[i].psz_string );
}
var_FreeList( &val, &text );
msg_rc( "+----[ end of %s ]", cmd );
......
......@@ -1446,7 +1446,8 @@
var:(const char *)psz_variable
selector:(SEL)pf_callback
{
vlc_value_t val, val_list, text_list;
vlc_value_t val;
vlc_list_t val_list, text_list;
int i_type, i;
/* remove previous items */
......@@ -1502,9 +1503,9 @@
}
/* make (un)sensitive */
[parent setEnabled: (val_list.p_list->i_count > 1)];
[parent setEnabled: (val_list.i_count > 1)];
for (i = 0; i < val_list.p_list->i_count; i++) {
for (i = 0; i < val_list.i_count; i++) {
NSMenuItem *lmi;
NSString *title = @"";
VLCAutoGeneratedMenuContent *data;
......@@ -1512,31 +1513,31 @@
switch(i_type & VLC_VAR_TYPE) {
case VLC_VAR_STRING:
title = _NS(text_list.p_list->p_values[i].psz_string ? text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string);
title = _NS(text_list.p_values[i].psz_string ? text_list.p_values[i].psz_string : val_list.p_values[i].psz_string);
lmi = [menu addItemWithTitle: title action: pf_callback keyEquivalent: @""];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val_list.p_list->p_values[i] ofType: i_type];
andValue: val_list.p_values[i] ofType: i_type];
[lmi setRepresentedObject:data];
[lmi setTarget: self];
if (!strcmp(val.psz_string, val_list.p_list->p_values[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND))
if (!strcmp(val.psz_string, val_list.p_values[i].psz_string) && !(i_type & VLC_VAR_ISCOMMAND))
[lmi setState: TRUE ];
break;
case VLC_VAR_INTEGER:
title = text_list.p_list->p_values[i].psz_string ?
_NS(text_list.p_list->p_values[i].psz_string) : [NSString stringWithFormat: @"%"PRId64, val_list.p_list->p_values[i].i_int];
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];
lmi = [menu addItemWithTitle: title action: pf_callback keyEquivalent: @""];
data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val_list.p_list->p_values[i] ofType: i_type];
andValue: val_list.p_values[i] ofType: i_type];
[lmi setRepresentedObject:data];
[lmi setTarget: self];
if (val_list.p_list->p_values[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND))
if (val_list.p_values[i].i_int == val.i_int && !(i_type & VLC_VAR_ISCOMMAND))
[lmi setState: TRUE ];
break;
......
......@@ -1529,22 +1529,21 @@ static void CycleESTrack(input_thread_t *input, const char *var)
if (!input)
return;
vlc_value_t val;
if (var_Change(input, var, VLC_VAR_GETCHOICES, &val,
(vlc_value_t *)NULL) < 0)
vlc_list_t list;
if (var_Change(input, var, VLC_VAR_GETCHOICES, &list,
(vlc_list_t *)NULL) < 0)
return;
vlc_list_t *list = val.p_list;
int64_t current = var_GetInteger(input, var);
int i;
for (i = 0; i < list->i_count; i++)
if (list->p_values[i].i_int == current)
for (i = 0; i < list.i_count; i++)
if (list.p_values[i].i_int == current)
break;
if (++i >= list->i_count)
if (++i >= list.i_count)
i = 0;
var_SetInteger(input, var, list->p_values[i].i_int);
var_SetInteger(input, var, list.p_values[i].i_int);
}
static void HandleCommonKey(intf_thread_t *intf, input_thread_t *input,
......
......@@ -268,7 +268,7 @@ void AspectRatioComboBox::updateRatios()
{
/* Clear the list before updating */
clear();
vlc_value_t val_list, text_list;
vlc_list_t val_list, text_list;
vout_thread_t* p_vout = THEMIM->getVout();
/* Disable if there is no vout */
......@@ -280,9 +280,9 @@ void AspectRatioComboBox::updateRatios()
}
var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES, &val_list, &text_list );
for( int i = 0; i < val_list.p_list->i_count; i++ )
addItem( qfu( text_list.p_list->p_values[i].psz_string ),
QString( val_list.p_list->p_values[i].psz_string ) );
for( int i = 0; i < val_list.i_count; i++ )
addItem( qfu( text_list.p_values[i].psz_string ),
QString( val_list.p_values[i].psz_string ) );
setEnabled( true );
var_FreeList( &val_list, &text_list );
vlc_object_release( p_vout );
......
......@@ -651,7 +651,7 @@ void ExtV4l2::Refresh( void )
}
if( p_obj )
{
vlc_value_t val, text;
vlc_list_t val, text;
int i_ret = var_Change( p_obj, "controls", VLC_VAR_GETCHOICES,
&val, &text );
if( i_ret < 0 )
......@@ -667,10 +667,10 @@ void ExtV4l2::Refresh( void )
QVBoxLayout *layout = new QVBoxLayout( box );
box->setLayout( layout );
for( int i = 0; i < val.p_list->i_count; i++ )
for( int i = 0; i < val.i_count; i++ )
{
vlc_value_t vartext;
const char *psz_var = text.p_list->p_values[i].psz_string;
const char *psz_var = text.p_values[i].psz_string;
if( var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &vartext ) )
continue;
......@@ -678,7 +678,7 @@ void ExtV4l2::Refresh( void )
QString name = qtr( vartext.psz_string );
free( vartext.psz_string );
msg_Dbg( p_intf, "v4l2 control \"%" PRIx64 "\": %s (%s)",
val.p_list->p_values[i].i_int, psz_var, qtu( name ) );
val.p_values[i].i_int, psz_var, qtu( name ) );
int i_type = var_Type( p_obj, psz_var );
switch( i_type & VLC_VAR_TYPE )
......@@ -694,15 +694,15 @@ void ExtV4l2::Refresh( void )
QComboBox *combobox = new QComboBox( box );
combobox->setObjectName( qfu( psz_var ) );
vlc_value_t val2, text2;
vlc_list_t val2, text2;
var_Change( p_obj, psz_var, VLC_VAR_GETCHOICES,
&val2, &text2 );
for( int j = 0; j < val2.p_list->i_count; j++ )
for( int j = 0; j < val2.i_count; j++ )
{
combobox->addItem(
text2.p_list->p_values[j].psz_string,
qlonglong( val2.p_list->p_values[j].i_int) );
if( i_val == val2.p_list->p_values[j].i_int )
text2.p_values[j].psz_string,
qlonglong( val2.p_values[j].i_int) );
if( i_val == val2.p_values[j].i_int )
combobox->setCurrentIndex( j );
}
var_FreeList( &val2, &text2 );
......
......@@ -859,24 +859,24 @@ void InputManager::telexSetTransparency( bool b_transparentTelextext )
void InputManager::activateTeletext( bool b_enable )
{
vlc_value_t list;
vlc_value_t text;
vlc_list_t list, text;
if( hasInput() && !var_Change( p_input, "teletext-es", VLC_VAR_GETCHOICES, &list, &text ) )
{
if( list.p_list->i_count > 0 )
if( list.i_count > 0 )
{
/* Prefer the page 100 if it is present */
int i;
for( i = 0; i < text.p_list->i_count; i++ )
for( i = 0; i < text.i_count; i++ )
{
/* The description is the page number as a string */
const char *psz_page = text.p_list->p_values[i].psz_string;
const char *psz_page = text.p_values[i].psz_string;
if( psz_page && !strcmp( psz_page, "100" ) )
break;
}
if( i >= list.p_list->i_count )
if( i >= list.i_count )
i = 0;
var_SetInteger( p_input, "spu-es", b_enable ? list.p_list->p_values[i].i_int : -1 );
var_SetInteger( p_input, "spu-es", b_enable ? list.p_values[i].i_int : -1 );
}
var_FreeList( &list, &text );
}
......
......@@ -1376,7 +1376,8 @@ static bool CheckTitle( vlc_object_t *p_object, const char *psz_var )
int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
vlc_object_t *p_object )
{
vlc_value_t val, val_list, text_list;
vlc_value_t val;
vlc_list_t val_list, text_list;
int i_type, i;
/* Check the type of the object variable */
......@@ -1405,11 +1406,11 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
return VLC_EGENERIC;
}
#define CURVAL val_list.p_list->p_values[i]
#define CURTEXT text_list.p_list->p_values[i].psz_string
#define CURVAL val_list.p_values[i]
#define CURTEXT text_list.p_values[i].psz_string
#define RADIO_OR_COMMAND ( i_type & ( VLC_VAR_ISCOMMAND | VLC_VAR_HASCHOICE ) ) ? ITEM_RADIO : ITEM_NORMAL
for( i = 0; i < val_list.p_list->i_count; i++ )
for( i = 0; i < val_list.i_count; i++ )
{
vlc_value_t another_val;
QString menutext;
......
......@@ -235,8 +235,7 @@ static int vlclua_var_create( lua_State *L )
static int vlclua_var_get_list( lua_State *L )
{
vlc_value_t val;
vlc_value_t text;
vlc_list_t val, text;
vlc_object_t **pp_obj = luaL_checkudata( L, 1, "vlc_object" );
const char *psz_var = luaL_checkstring( L, 2 );
......@@ -244,8 +243,8 @@ static int vlclua_var_get_list( lua_State *L )
if( i_ret < 0 )
return vlclua_push_ret( L, i_ret );
vlclua_pushlist( L, val.p_list );
vlclua_pushlist( L, text.p_list );
vlclua_pushlist( L, &val );
vlclua_pushlist( L, &text );
var_FreeList( &val, &text );
return 2;
......
......@@ -475,13 +475,13 @@ static void aout_PrepareStereoMode (audio_output_t *aout,
}
bool mode_available = false;
vlc_value_t vals;
vlc_list_t vals;
if (!var_Change(aout, "stereo-mode", VLC_VAR_GETCHOICES, &vals,
(vlc_value_t *)NULL))
(vlc_list_t *)NULL))
{
for (int i = 0; !mode_available && i < vals.p_list->i_count; ++i)
for (int i = 0; !mode_available && i < vals.i_count; ++i)
{
if (vals.p_list->p_values[i].i_int == i_output_mode)
if (vals.p_values[i].i_int == i_output_mode)
mode_available = true;
}
var_FreeList(&vals, NULL);
......
......@@ -3277,19 +3277,19 @@ static int input_SlaveSourceAdd( input_thread_t *p_input,
return VLC_SUCCESS;
/* Select the ES */
vlc_value_t list;
vlc_list_t list;
if( var_Change( p_input, psz_es, VLC_VAR_GETCHOICES, &list,
(vlc_value_t *)NULL ) )
(vlc_list_t *)NULL ) )
return VLC_SUCCESS;
if( count == 0 )
count++;
/* if it was first one, there is disable too */
if( count < (size_t)list.p_list->i_count )
if( count < (size_t)list.i_count )
{
const int i_id = list.p_list->p_values[count].i_int;
const int i_id = list.p_values[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 );
......
......@@ -551,31 +551,32 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name, int i_action, ...)
break;
case VLC_VAR_GETCHOICES:
{
vlc_value_t *p_val = va_arg(ap, vlc_value_t *);
vlc_value_t *p_val2 = va_arg(ap, vlc_value_t *);
vlc_list_t *values = va_arg(ap, vlc_list_t *);
vlc_list_t *texts = va_arg(ap, vlc_list_t *);
p_val->p_list = xmalloc( sizeof(vlc_list_t) );
p_val->p_list->p_values =
values->p_values =
xmalloc( p_var->choices.i_count * sizeof(vlc_value_t) );
p_val->p_list->i_type = p_var->i_type;
p_val->p_list->i_count = p_var->choices.i_count;
if( p_val2 )
values->i_type = p_var->i_type;
values->i_count = p_var->choices.i_count;
for( int i = 0 ; i < p_var->choices.i_count ; i++ )
{
p_val2->p_list = xmalloc( sizeof(vlc_list_t) );
p_val2->p_list->p_values =
xmalloc( p_var->choices.i_count * sizeof(vlc_value_t) );
p_val2->p_list->i_type = VLC_VAR_STRING;
p_val2->p_list->i_count = p_var->choices.i_count;
values->p_values[i] = p_var->choices.p_values[i];
p_var->ops->pf_dup( &values->p_values[i] );
}
for( int i = 0 ; i < p_var->choices.i_count ; i++ )
if( texts != NULL )
{
p_val->p_list->p_values[i] = p_var->choices.p_values[i];
p_var->ops->pf_dup( &p_val->p_list->p_values[i] );
if( p_val2 )
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;
for( int i = 0 ; i < p_var->choices.i_count ; i++ )
{
p_val2->p_list->p_values[i].psz_string =
p_var->choices_text.p_values[i].psz_string ?
strdup(p_var->choices_text.p_values[i].psz_string) : NULL;
texts->p_values[i].psz_string =
p_var->choices_text.p_values[i].psz_string
? strdup(p_var->choices_text.p_values[i].psz_string) : NULL;
}
}
break;
......@@ -1137,28 +1138,25 @@ error:
return VLC_EGENERIC;
}
void var_FreeList( vlc_value_t *p_val, vlc_value_t *p_val2 )
void var_FreeList( vlc_list_t *values, vlc_list_t *texts )
{
switch( p_val->p_list->i_type & VLC_VAR_CLASS )
switch( values->i_type & VLC_VAR_CLASS )
{
case VLC_VAR_STRING:
for( int i = 0; i < p_val->p_list->i_count; i++ )
free( p_val->p_list->p_values[i].psz_string );
for( int i = 0; i < values->i_count; i++ )
free( values->p_values[i].psz_string );
break;
}
free( p_val->p_list->p_values );
free( p_val->p_list );
free( values->p_values );
if( p_val2 != NULL )
if( texts != NULL )
{
assert( p_val2->p_list != NULL );
assert( p_val2->p_list->i_type == VLC_VAR_STRING );
assert( texts->i_type == VLC_VAR_STRING );
for( int i = 0; i < p_val2->p_list->i_count; i++ )
free( p_val2->p_list->p_values[i].psz_string );
free( p_val2->p_list->p_values );
free( p_val2->p_list );
for( int i = 0; i < texts->i_count; i++ )
<