From 30838535efe0f42b483e517fef0113998318696e Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 19 Aug 2014 21:44:08 +0300 Subject: [PATCH] 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). --- lib/video.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/video.c b/lib/video.c index c8b371130e..3f3d19a37a 100644 --- a/lib/video.c +++ b/lib/video.c @@ -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; -- 2.39.2