]> git.sesse.net Git - vlc/commitdiff
Add coordinates (VLC_VAR_COORDS) variable type
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 13 Feb 2010 17:49:59 +0000 (19:49 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 13 Feb 2010 18:30:11 +0000 (20:30 +0200)
include/vlc_common.h
include/vlc_variables.h
src/misc/objects.c
src/misc/variables.c

index a1d1f9087f2ace926fdf2aab8db39964f291f7c6..792bcd67583fa064f6313ccabab87b26fad980aa 100644 (file)
@@ -420,9 +420,10 @@ typedef union
     vlc_object_t *  p_object;
     vlc_list_t *    p_list;
     mtime_t         i_time;
+    struct { int32_t x; int32_t y; } coords;
 
-   /* Make sure the structure is at least 64bits */
-    struct { char a, b, c, d, e, f, g, h; } padding;
+    /* Make sure the structure is at least 64bits */
+    uint8_t padding[8];
 
 } vlc_value_t;
 
@@ -456,6 +457,7 @@ struct vlc_list_t
 #define VLC_VAR_ADDRESS   0x0070
 #define VLC_VAR_MUTEX     0x0080
 #define VLC_VAR_LIST      0x0090
+#define VLC_VAR_COORDS    0x00A0
 /**@}*/
 
 /*****************************************************************************
index 51d371b6ffa468c15f3fdd92a044cb3780862e3b..4a0de14f21a11ec05225d8934756519b15fcf37e 100644 (file)
@@ -223,6 +223,16 @@ static inline int var_SetTime( vlc_object_t *p_obj, const char *psz_name, int64_
     return var_SetChecked( p_obj, psz_name, VLC_VAR_TIME, val );
 }
 
+static inline int var_SetCoords( vlc_object_t *obj, const char *name,
+                                 int32_t x, int32_t y )
+{
+    vlc_value_t val;
+    val.coords.x = x;
+    val.coords.y = y;
+    return var_SetChecked (obj, name, VLC_VAR_COORDS, val);
+}
+#define var_SetCoords(o,n,x,y) var_SetCoords(VLC_OBJECT(o),n,x,y)
+
 /**
  * Set the value of a float variable
  *
@@ -323,6 +333,21 @@ static inline int64_t var_GetTime( vlc_object_t *p_obj, const char *psz_name )
         return 0;
 }
 
+static inline void var_GetCoords( vlc_object_t *obj, const char *name,
+                                  int32_t *px, int32_t *py )
+{
+    vlc_value_t val;
+
+    if (likely(!var_GetChecked (obj, name, VLC_VAR_COORDS, &val)))
+    {
+        *px = val.coords.x;
+        *py = val.coords.y;
+    }
+    else
+        *px = *py = 0;
+}
+#define var_GetCoords(o,n,x,y) var_GetCoords(VLC_OBJECT(o),n,x,y)
+
 /**
  * Get a float value
  *
index 1dfbffb28a3a6de8b6a9094730673c3eaa96515e..f8b6044587320fa8585403f6180f0324e396091a 100644 (file)
@@ -751,6 +751,7 @@ static void DumpVariable (const void *data, const VISIT which, const int depth)
         MYCASE( VARIABLE, "variable" );
         MYCASE( FLOAT, "float" );
         MYCASE( TIME, "time" );
+        MYCASE( COORDS, "coords" );
         MYCASE( ADDRESS, "address" );
         MYCASE( MUTEX, "mutex" );
         MYCASE( LIST, "list" );
@@ -786,6 +787,10 @@ static void DumpVariable (const void *data, const VISIT which, const int depth)
         case VLC_VAR_TIME:
             printf( ": %"PRIi64, (int64_t)p_var->val.i_time );
             break;
+        case VLC_VAR_COORDS:
+            printf( ": %"PRId32"x%"PRId32,
+                    p_var->val.coords.x, p_var->val.coords.y );
+            break;
         case VLC_VAR_ADDRESS:
             printf( ": %p", p_var->val.p_address );
             break;
index 654cd2584ba80b209011a7b5bed33e3fd9b082a9..9ac58dd9fa728db2a7caab65094bf173c5f80c6b 100644 (file)
@@ -157,7 +157,8 @@ int_ops    = { CmpInt,     DupDummy,  FreeDummy,  },
 list_ops   = { CmpAddress, DupList,   FreeList,   },
 mutex_ops  = { CmpAddress, DupDummy,  FreeMutex,  },
 string_ops = { CmpString,  DupString, FreeString, },
-time_ops   = { CmpTime,    DupDummy,  FreeDummy,  };
+time_ops   = { CmpTime,    DupDummy,  FreeDummy,  },
+coords_ops = { NULL,       DupDummy,  FreeDummy,  };
 
 /*****************************************************************************
  * Local prototypes
@@ -271,6 +272,10 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type )
             p_var->ops = &time_ops;
             p_var->val.i_time = 0;
             break;
+        case VLC_VAR_COORDS:
+            p_var->ops = &coords_ops;
+            p_var->val.coords.x = p_var->val.coords.y = 0;
+            break;
         case VLC_VAR_ADDRESS:
             p_var->ops = &addr_ops;
             p_var->val.p_address = NULL;