[vlc-commits] Make drawable-hwnd an integer config item (untested)

Rémi Denis-Courmont git at videolan.org
Mon Apr 11 17:22:36 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Apr 11 18:21:34 2011 +0300| [fa439d768f4fb160fade097a5fbd71956fc2d9b9] | committer: Rémi Denis-Courmont

Make drawable-hwnd an integer config item (untested)

Most of the code churn in this commit comes from converting from void *
to uintptr.

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

 modules/video_output/drawable.c |   39 +++++++++++++++++++++++----------------
 src/control/media_player.c      |    6 +++---
 src/libvlc.c                    |    2 +-
 3 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/modules/video_output/drawable.c b/modules/video_output/drawable.c
index bf01e9b..b8f7cec 100644
--- a/modules/video_output/drawable.c
+++ b/modules/video_output/drawable.c
@@ -31,6 +31,11 @@
 #include <vlc_plugin.h>
 #include <vlc_vout_window.h>
 
+#define HWND_TEXT N_("Window handle (HWND)")
+#define HWND_LONGTEXT N_( \
+    "Video will be embedded in this pre-existing window. " \
+    "If zero, a new window will be created.")
+
 static int  Open (vout_window_t *, const vout_window_cfg_t *);
 static void Close(vout_window_t *);
 
@@ -45,6 +50,9 @@ vlc_module_begin ()
     set_capability ("vout window hwnd", 0)
     set_callbacks (Open, Close)
     add_shortcut ("embed-hwnd")
+
+    add_integer ("drawable-hwnd", 0, HWND_TEXT, HWND_LONGTEXT, true)
+        change_volatile ()
 vlc_module_end ()
 
 static int Control (vout_window_t *, int, va_list);
@@ -52,7 +60,7 @@ static int Control (vout_window_t *, int, va_list);
 /* Keep a list of busy drawables, so we don't overlap videos if there are
  * more than one video track in the stream. */
 static vlc_mutex_t serializer = VLC_STATIC_MUTEX;
-static void **used = NULL;
+static uintptr_t *used = NULL;
 
 /**
  * Find the drawable set by libvlc application.
@@ -60,20 +68,20 @@ static void **used = NULL;
 static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
 {
     VLC_UNUSED (cfg);
-    void *val = var_InheritAddress (wnd, "drawable-hwnd");
-    if (val == NULL)
+    uintptr_t val = var_InheritInteger (wnd, "drawable-hwnd");
+    if (val == 0)
         return VLC_EGENERIC;
 
-    void **tab;
+    uintptr_t *tab;
     size_t n = 0;
 
     vlc_mutex_lock (&serializer);
     if (used != NULL)
-        for (/*n = 0*/; used[n] != NULL; n++)
+        for (/*n = 0*/; used[n]; n++)
             if (used[n] == val)
             {
-                msg_Warn (wnd, "HWND %p is busy", val);
-                val = NULL;
+                msg_Warn (wnd, "HWND 0x%zX is busy", val);
+                val = 0;
                 goto skip;
             }
 
@@ -82,19 +90,19 @@ static int Open (vout_window_t *wnd, const vout_window_cfg_t *cfg)
     {
         used = tab;
         used[n] = val;
-        used[n + 1] = NULL;
+        used[n + 1] = 0;
     }
     else
-        val = NULL;
+        val = 0;
 skip:
     vlc_mutex_unlock (&serializer);
 
-    if (val == NULL)
+    if (val == 0)
         return VLC_EGENERIC;
 
-    wnd->handle.hwnd = val;
+    wnd->handle.hwnd = (void *)val;
     wnd->control = Control;
-    wnd->sys = val;
+    wnd->sys = (void *)val;
     return VLC_SUCCESS;
 }
 
@@ -103,7 +111,7 @@ skip:
  */
 static void Close (vout_window_t *wnd)
 {
-    void *val = wnd->sys;
+    uintptr_t val = (uintptr_t)wnd->sys;
     size_t n = 0;
 
     /* Remove this drawable from the list of busy ones */
@@ -111,12 +119,12 @@ static void Close (vout_window_t *wnd)
     assert (used != NULL);
     while (used[n] != val)
     {
-        assert (used[n] != NULL);
+        assert (used[n]);
         n++;
     }
     do
         used[n] = used[n + 1];
-    while (used[++n] != NULL);
+    while (used[++n] != 0);
 
     if (n == 0)
     {
@@ -141,4 +149,3 @@ static int Control (vout_window_t *wnd, int query, va_list ap)
             return VLC_EGENERIC;
     }
 }
-
diff --git a/src/control/media_player.c b/src/control/media_player.c
index efea8ab..333d32a 100644
--- a/src/control/media_player.c
+++ b/src/control/media_player.c
@@ -404,7 +404,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create (mp, "vmem-pitch", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT);
     var_Create (mp, "drawable-xid", VLC_VAR_INTEGER);
 #ifdef WIN32
-    var_Create (mp, "drawable-hwnd", VLC_VAR_ADDRESS);
+    var_Create (mp, "drawable-hwnd", VLC_VAR_INTEGER);
 #endif
 #ifdef __APPLE__
     var_Create (mp, "drawable-agl", VLC_VAR_INTEGER);
@@ -914,7 +914,7 @@ void libvlc_media_player_set_hwnd( libvlc_media_player_t *p_mi,
 #ifdef WIN32
     var_SetString (p_mi, "window",
                    (drawable != NULL) ? "embed-hwnd,any" : "");
-    var_SetAddress (p_mi, "drawable-hwnd", drawable);
+    var_SetInteger (p_mi, "drawable-hwnd", (uintptr_t)drawable);
 #else
     (void) p_mi; (void) drawable;
 #endif
@@ -927,7 +927,7 @@ void *libvlc_media_player_get_hwnd( libvlc_media_player_t *p_mi )
 {
     assert (p_mi != NULL);
 #ifdef WIN32
-    return var_GetAddress (p_mi, "drawable-hwnd");
+    return (void *)(uintptr_t)var_GetInteger (p_mi, "drawable-hwnd");
 #else
     return NULL;
 #endif
diff --git a/src/libvlc.c b/src/libvlc.c
index dabca31..525e15d 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -955,7 +955,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     var_Create( p_libvlc, "drawable-nsobject", VLC_VAR_ADDRESS );
 #endif
 #ifdef WIN32
-    var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_ADDRESS );
+    var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_INTEGER );
 #endif
 
     /*



More information about the vlc-commits mailing list