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

lib: allow setting float variables as integers

Just convert to/from float on the fly. That enables backward compatibility
for setting/getting adjust hue as an interger (next commit).
parent 06f474e2
......@@ -643,26 +643,29 @@ set_int( libvlc_media_player_t *p_mi, const char *restrict name,
{
if( !opt ) return;
if( !opt->type ) /* the enabler */
switch( opt->type )
{
vout_thread_t *vout = GetVout( p_mi, 0 );
if (vout)
case 0: /* the enabler */
{
/* Fill sub-source */
vout_EnableFilter( vout, opt->name, value, false );
var_TriggerCallback( vout, "sub-source" );
vlc_object_release( vout );
vout_thread_t *vout = GetVout( p_mi, 0 );
if (vout != NULL)
{ /* Fill sub-source */
vout_EnableFilter( vout, opt->name, value, false );
var_TriggerCallback( vout, "sub-source" );
vlc_object_release( vout );
}
break;
}
return;
}
if( opt->type != VLC_VAR_INTEGER )
{
libvlc_printerr( "Invalid argument to %s in %s", name, "set int" );
return;
case VLC_VAR_INTEGER:
var_SetInteger( p_mi, opt->name, value );
break;
case VLC_VAR_FLOAT:
var_SetFloat( p_mi, opt->name, value );
break;
default:
libvlc_printerr( "Invalid argument to %s in %s", name, "set int" );
return;
}
var_SetInteger( p_mi, opt->name, value );
}
static int
......@@ -680,6 +683,8 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name,
}
case VLC_VAR_INTEGER:
return var_GetInteger(p_mi, opt->name);
case VLC_VAR_FLOAT:
return lroundf(var_GetFloat(p_mi, opt->name));
default:
libvlc_printerr( "Invalid argument to %s in %s", name, "get int" );
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment