mirror of
https://code.videolan.org/videolan/vlc
synced 2024-10-07 03:56:28 +02:00
variables: inline var_FreeList() in simple loops
This works like config choices.
This commit is contained in:
parent
5d31da4eca
commit
7048874668
@ -1138,14 +1138,12 @@ static int Input( vlc_object_t *p_this, char const *psz_cmd,
|
|||||||
msg_rc( "+----[ %s ]", name );
|
msg_rc( "+----[ %s ]", name );
|
||||||
for ( size_t i = 0; i < count; i++ )
|
for ( size_t i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
if ( i_value == val.p_values[i].i_int )
|
msg_rc( "| %"PRId64" - %s%s", val.p_values[i].i_int, text[i],
|
||||||
msg_rc( "| %"PRId64" - %s *", val.p_values[i].i_int,
|
(i_value == val.p_values[i].i_int) ? " *" : "" );
|
||||||
text[i] );
|
free(text[i]);
|
||||||
else
|
|
||||||
msg_rc( "| %"PRId64" - %s", val.p_values[i].i_int,
|
|
||||||
text[i] );
|
|
||||||
}
|
}
|
||||||
var_FreeList( &val, &text );
|
free(text);
|
||||||
|
free(val.p_values);
|
||||||
msg_rc( "+----[ end of %s ]", name );
|
msg_rc( "+----[ end of %s ]", name );
|
||||||
}
|
}
|
||||||
free( name );
|
free( name );
|
||||||
@ -1593,25 +1591,25 @@ static int VideoConfig( vlc_object_t *p_this, char const *psz_cmd,
|
|||||||
{
|
{
|
||||||
for ( size_t i = 0; i < count; i++ )
|
for ( size_t i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
if ( f_value == val.p_values[i].f_float )
|
msg_rc( "| %f - %s%s", val.p_values[i].f_float, text[i],
|
||||||
msg_rc( "| %f - %s *", val.p_values[i].f_float, text[i] );
|
f_value == val.p_values[i].f_float ? " *" : "" );
|
||||||
else
|
free(text[i]);
|
||||||
msg_rc( "| %f - %s", val.p_values[i].f_float, text[i] );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for ( size_t i = 0; 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%s", val.p_values[i].psz_string, text[i],
|
||||||
msg_rc( "| %s - %s *", val.p_values[i].psz_string,
|
strcmp(psz_value, val.p_values[i].psz_string)
|
||||||
text[i] );
|
? "" : " *" );
|
||||||
else
|
free(text[i]);
|
||||||
msg_rc( "| %s - %s", val.p_values[i].psz_string, text[i] );
|
free(val.p_values[i].psz_string);
|
||||||
}
|
}
|
||||||
free( psz_value );
|
free( psz_value );
|
||||||
}
|
}
|
||||||
var_FreeList( &val, &text );
|
free(text);
|
||||||
|
free(val.p_values);
|
||||||
msg_rc( "+----[ end of %s ]", name );
|
msg_rc( "+----[ end of %s ]", name );
|
||||||
|
|
||||||
free( name );
|
free( name );
|
||||||
@ -1692,12 +1690,12 @@ static int AudioChannel( vlc_object_t *obj, char const *cmd,
|
|||||||
msg_rc( "+----[ %s ]", cmd );
|
msg_rc( "+----[ %s ]", cmd );
|
||||||
for ( size_t i = 0; i < count; i++ )
|
for ( size_t i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
if ( i_value == val.p_values[i].i_int )
|
msg_rc( "| %"PRId64" - %s%s", val.p_values[i].i_int, text[i],
|
||||||
msg_rc( "| %"PRId64" - %s *", val.p_values[i].i_int, text[i] );
|
i_value == val.p_values[i].i_int ? " *" : "" );
|
||||||
else
|
free(text[i]);
|
||||||
msg_rc( "| %"PRId64" - %s", val.p_values[i].i_int, text[i] );
|
|
||||||
}
|
}
|
||||||
var_FreeList( &val, &text );
|
free(text);
|
||||||
|
free(val.p_values);
|
||||||
msg_rc( "+----[ end of %s ]", cmd );
|
msg_rc( "+----[ end of %s ]", cmd );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1527,6 +1527,8 @@
|
|||||||
if (!strcmp(val.psz_string, val_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 ];
|
[lmi setState: TRUE ];
|
||||||
|
|
||||||
|
free(text_list[i]);
|
||||||
|
free(val_list.p_values[i].psz_string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VLC_VAR_INTEGER:
|
case VLC_VAR_INTEGER:
|
||||||
@ -1542,6 +1544,8 @@
|
|||||||
|
|
||||||
if (val_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 ];
|
[lmi setState: TRUE ];
|
||||||
|
|
||||||
|
free(text_list[i]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1551,7 +1555,8 @@
|
|||||||
|
|
||||||
/* clean up everything */
|
/* clean up everything */
|
||||||
if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
|
if ((i_type & VLC_VAR_TYPE) == VLC_VAR_STRING) free(val.psz_string);
|
||||||
var_FreeList(&val_list, &text_list);
|
free(text);
|
||||||
|
free(val_list.p_values);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)toggleVar:(id)sender
|
- (void)toggleVar:(id)sender
|
||||||
|
@ -285,10 +285,15 @@ void AspectRatioComboBox::updateRatios()
|
|||||||
var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES,
|
var_Change( p_vout, "aspect-ratio", VLC_VAR_GETCHOICES,
|
||||||
&count, &val_list, &text_list );
|
&count, &val_list, &text_list );
|
||||||
for( size_t i = 0; i < count; i++ )
|
for( size_t i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
addItem( qfu( text_list[i] ),
|
addItem( qfu( text_list[i] ),
|
||||||
QString( val_list.p_values[i].psz_string ) );
|
QString( val_list.p_values[i].psz_string ) );
|
||||||
|
free(text_list[i]);
|
||||||
|
free(val_list.p_values[i].psz_string);
|
||||||
|
}
|
||||||
setEnabled( true );
|
setEnabled( true );
|
||||||
var_FreeList( &val_list, &text_list );
|
free(text_list);
|
||||||
|
free(val_list.p_values);
|
||||||
vlc_object_release( p_vout );
|
vlc_object_release( p_vout );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,14 +672,17 @@ void ExtV4l2::Refresh( void )
|
|||||||
|
|
||||||
for( size_t i = 0; i < count; i++ )
|
for( size_t i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
char *vartext;
|
char *vartext, *psz_var = text[i];
|
||||||
const char *psz_var = text[i];
|
QString name;
|
||||||
|
|
||||||
if( var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &vartext ) )
|
if( !var_Change( p_obj, psz_var, VLC_VAR_GETTEXT, &vartext ) )
|
||||||
continue;
|
{
|
||||||
|
name = qtr(vartext);
|
||||||
QString name = qtr( vartext );
|
|
||||||
free(vartext);
|
free(vartext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
name = qfu(psz_var);
|
||||||
|
|
||||||
msg_Dbg( p_intf, "v4l2 control \"%" PRIx64 "\": %s (%s)",
|
msg_Dbg( p_intf, "v4l2 control \"%" PRIx64 "\": %s (%s)",
|
||||||
val.p_values[i].i_int, psz_var, qtu( name ) );
|
val.p_values[i].i_int, psz_var, qtu( name ) );
|
||||||
|
|
||||||
@ -709,8 +712,10 @@ void ExtV4l2::Refresh( void )
|
|||||||
qlonglong( val2.p_values[j].i_int) );
|
qlonglong( val2.p_values[j].i_int) );
|
||||||
if( i_val == val2.p_values[j].i_int )
|
if( i_val == val2.p_values[j].i_int )
|
||||||
combobox->setCurrentIndex( j );
|
combobox->setCurrentIndex( j );
|
||||||
|
free(text2[j]);
|
||||||
}
|
}
|
||||||
var_FreeList( &val2, &text2 );
|
free(text2);
|
||||||
|
free(val2.p_values);
|
||||||
|
|
||||||
CONNECT( combobox, currentIndexChanged( int ), this,
|
CONNECT( combobox, currentIndexChanged( int ), this,
|
||||||
ValueChange( int ) );
|
ValueChange( int ) );
|
||||||
@ -774,8 +779,10 @@ void ExtV4l2::Refresh( void )
|
|||||||
msg_Warn( p_intf, "Unhandled var type for %s", psz_var );
|
msg_Warn( p_intf, "Unhandled var type for %s", psz_var );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
free(psz_var);
|
||||||
}
|
}
|
||||||
var_FreeList( &val, &text );
|
free(text);
|
||||||
|
free(val.p_values);
|
||||||
vlc_object_release( p_obj );
|
vlc_object_release( p_obj );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1426,6 +1426,7 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
|
|||||||
val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) );
|
val.psz_string && !strcmp( val.psz_string, CURVAL.psz_string ) );
|
||||||
|
|
||||||
free( val.psz_string );
|
free( val.psz_string );
|
||||||
|
free(CURVAL.psz_string);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VLC_VAR_INTEGER:
|
case VLC_VAR_INTEGER:
|
||||||
@ -1450,11 +1451,13 @@ int VLCMenuBar::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
free(CURTEXT);
|
||||||
}
|
}
|
||||||
currentGroup = NULL;
|
currentGroup = NULL;
|
||||||
|
|
||||||
/* clean up everything */
|
/* clean up everything */
|
||||||
var_FreeList( &val_list, &text_list );
|
free(text_list);
|
||||||
|
free(val_list.p_values);
|
||||||
|
|
||||||
#undef RADIO_OR_COMMAND
|
#undef RADIO_OR_COMMAND
|
||||||
#undef CURVAL
|
#undef CURVAL
|
||||||
|
@ -238,6 +238,8 @@ static int vlclua_var_get_list( lua_State *L )
|
|||||||
if( !vlclua_pushvalue( L, val.i_type, val.p_values[i] ) )
|
if( !vlclua_pushvalue( L, val.i_type, val.p_values[i] ) )
|
||||||
lua_pushnil( L );
|
lua_pushnil( L );
|
||||||
lua_settable( L, -3 );
|
lua_settable( L, -3 );
|
||||||
|
if( (val.i_type & VLC_VAR_CLASS) == VLC_VAR_STRING )
|
||||||
|
free(val.p_values[i].psz_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_createtable( L, count, 0 );
|
lua_createtable( L, count, 0 );
|
||||||
@ -246,9 +248,11 @@ static int vlclua_var_get_list( lua_State *L )
|
|||||||
lua_pushinteger( L, i + 1 );
|
lua_pushinteger( L, i + 1 );
|
||||||
lua_pushstring( L, text[i] );
|
lua_pushstring( L, text[i] );
|
||||||
lua_settable( L, -3 );
|
lua_settable( L, -3 );
|
||||||
|
free(text[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var_FreeList( &val, &text );
|
free(text);
|
||||||
|
free(val.p_values);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,9 @@ static void test_choices( libvlc_int_t *p_libvlc )
|
|||||||
var_Change( p_libvlc, "bla", VLC_VAR_GETCHOICES, &count, &vals, &texts );
|
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 &&
|
assert( count == 1 && vals.i_count == 1 && vals.p_values[0].i_int == 1 &&
|
||||||
!strcmp( texts[0], "one" ) );
|
!strcmp( texts[0], "one" ) );
|
||||||
var_FreeList( &vals, &texts );
|
free(texts[0]);
|
||||||
|
free(texts);
|
||||||
|
free(vals.p_values);
|
||||||
|
|
||||||
var_Change( p_libvlc, "bla", VLC_VAR_CLEARCHOICES );
|
var_Change( p_libvlc, "bla", VLC_VAR_CLEARCHOICES );
|
||||||
assert( var_CountChoices( p_libvlc, "bla" ) == 0 );
|
assert( var_CountChoices( p_libvlc, "bla" ) == 0 );
|
||||||
|
Loading…
Reference in New Issue
Block a user