[vlc-devel] commit: Add coordinates (VLC_VAR_COORDS) variable type ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Feb 13 19:30:14 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 13 19:49:59 2010 +0200| [c01dd91cd2d526332229ecea8d4f007c065026ea] | committer: Rémi Denis-Courmont 

Add coordinates (VLC_VAR_COORDS) variable type

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

 include/vlc_common.h    |    6 ++++--
 include/vlc_variables.h |   25 +++++++++++++++++++++++++
 src/misc/objects.c      |    5 +++++
 src/misc/variables.c    |    7 ++++++-
 4 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/include/vlc_common.h b/include/vlc_common.h
index a1d1f90..792bcd6 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -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
 /**@}*/
 
 /*****************************************************************************
diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index 51d371b..4a0de14 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -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
  *
diff --git a/src/misc/objects.c b/src/misc/objects.c
index 1dfbffb..f8b6044 100644
--- a/src/misc/objects.c
+++ b/src/misc/objects.c
@@ -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;
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 654cd25..9ac58dd 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -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;




More information about the vlc-devel mailing list