MSW: fix assertion failure on Open() error paths (fix #3889)
[vlc.git] / modules / video_output / msw / directx.c
index 5e05a2f..014a0d0 100644 (file)
 
 #include "common.h"
 
+#ifdef UNICODE
+#   error "Unicode mode not supported"
+#endif
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -114,19 +118,8 @@ vlc_module_begin()
     set_capability("vout display", 100)
     add_shortcut("directx")
     set_callbacks(Open, Close)
-
-    /* FIXME: Hack to avoid unregistering our window class */
-    linked_with_a_crap_library_which_uses_atexit()
 vlc_module_end()
 
-#if 0 /* FIXME */
-    /* check if we registered a window class because we need to
-     * unregister it */
-    WNDCLASS wndclass;
-    if (GetClassInfo(GetModuleHandle(NULL), "VLC DirectX", &wndclass))
-        UnregisterClass("VLC DirectX", GetModuleHandle(NULL));
-#endif
-
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
@@ -190,7 +183,7 @@ static int Open(vlc_object_t *object)
     HMODULE huser32 = GetModuleHandle(_T("USER32"));
     if (huser32) {
         sys->MonitorFromWindow = (void*)GetProcAddress(huser32, _T("MonitorFromWindow"));
-        sys->GetMonitorInfo = (void*)GetProcAddress(huser32, _T("GetMonitorInfoW"));
+        sys->GetMonitorInfo = (void*)GetProcAddress(huser32, _T("GetMonitorInfoA"));
     } else {
         sys->MonitorFromWindow = NULL;
         sys->GetMonitorInfo = NULL;
@@ -216,8 +209,9 @@ static int Open(vlc_object_t *object)
     vout_display_info_t info = vd->info;
     info.is_slow = true;
     info.has_double_click = true;
-    info.has_hide_mouse = true;
+    info.has_hide_mouse = false;
     info.has_pictures_invalid = true;
+    info.has_event_thread = true;
 
     /* Interaction TODO support starting with wallpaper mode */
     vlc_mutex_init(&sys->lock);
@@ -242,7 +236,11 @@ static int Open(vlc_object_t *object)
     return VLC_SUCCESS;
 
 error:
-    Close(VLC_OBJECT(vd));
+    DirectXClose(vd);
+    CommonClean(vd);
+    if (sys->hddraw_dll)
+        FreeLibrary(sys->hddraw_dll);
+    free(sys);
     return VLC_EGENERIC;
 }
 
@@ -588,7 +586,7 @@ static int DirectXOpenDDraw(vout_display_t *vd)
     if (sys->MonitorFromWindow) {
         HRESULT (WINAPI *OurDirectDrawEnumerateEx)(LPDDENUMCALLBACKEXA, LPVOID, DWORD);
         OurDirectDrawEnumerateEx =
-          (void *)GetProcAddress(sys->hddraw_dll, _T("DirectDrawEnumerateExW"));
+          (void *)GetProcAddress(sys->hddraw_dll, _T("DirectDrawEnumerateExA"));
 
         if (OurDirectDrawEnumerateEx) {
             char *device = var_GetString(vd, "directx-device");
@@ -1486,7 +1484,7 @@ static int FindDevicesCallback(vlc_object_t *object, char const *name,
     /* Enumerate displays */
     HRESULT (WINAPI *OurDirectDrawEnumerateEx)(LPDDENUMCALLBACKEXA,
                                                LPVOID, DWORD) =
-        (void *)GetProcAddress(hddraw_dll, _T("DirectDrawEnumerateExW"));
+        (void *)GetProcAddress(hddraw_dll, _T("DirectDrawEnumerateExA"));
     if (OurDirectDrawEnumerateEx)
         OurDirectDrawEnumerateEx(DirectXEnumCallback2, item,
                                  DDENUM_ATTACHEDSECONDARYDEVICES);