[vlc-commits] lib: allow setting float variables as integers

Rémi Denis-Courmont git at videolan.org
Tue Aug 19 21:17:02 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Aug 19 21:44:08 2014 +0300| [30838535efe0f42b483e517fef0113998318696e] | committer: 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).

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=30838535efe0f42b483e517fef0113998318696e
---

 lib/video.c |   37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/lib/video.c b/lib/video.c
index c8b3711..3f3d19a 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;



More information about the vlc-commits mailing list