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, ...@@ -643,26 +643,29 @@ set_int( libvlc_media_player_t *p_mi, const char *restrict name,
{ {
if( !opt ) return; if( !opt ) return;
if( !opt->type ) /* the enabler */ switch( opt->type )
{ {
vout_thread_t *vout = GetVout( p_mi, 0 ); case 0: /* the enabler */
if (vout)
{ {
/* Fill sub-source */ vout_thread_t *vout = GetVout( p_mi, 0 );
vout_EnableFilter( vout, opt->name, value, false ); if (vout != NULL)
var_TriggerCallback( vout, "sub-source" ); { /* Fill sub-source */
vlc_object_release( vout ); vout_EnableFilter( vout, opt->name, value, false );
var_TriggerCallback( vout, "sub-source" );
vlc_object_release( vout );
}
break;
} }
return; case VLC_VAR_INTEGER:
} var_SetInteger( p_mi, opt->name, value );
break;
if( opt->type != VLC_VAR_INTEGER ) case VLC_VAR_FLOAT:
{ var_SetFloat( p_mi, opt->name, value );
libvlc_printerr( "Invalid argument to %s in %s", name, "set int" ); break;
return; default:
libvlc_printerr( "Invalid argument to %s in %s", name, "set int" );
return;
} }
var_SetInteger( p_mi, opt->name, value );
} }
static int static int
...@@ -680,6 +683,8 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -680,6 +683,8 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name,
} }
case VLC_VAR_INTEGER: case VLC_VAR_INTEGER:
return var_GetInteger(p_mi, opt->name); return var_GetInteger(p_mi, opt->name);
case VLC_VAR_FLOAT:
return lroundf(var_GetFloat(p_mi, opt->name));
default: default:
libvlc_printerr( "Invalid argument to %s in %s", name, "get int" ); libvlc_printerr( "Invalid argument to %s in %s", name, "get int" );
return 0; 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