[vlc-commits] direct3d9: move D3D9_Create/D3D9_Destroy in libd3d9_cmmon

Steve Lhomme git at videolan.org
Mon Nov 20 19:00:03 CET 2017


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Sat Nov 18 14:26:39 2017 +0100| [c7369881619914442a0f7f17cf0d9452ac0d5bc9] | committer: Jean-Baptiste Kempf

direct3d9: move D3D9_Create/D3D9_Destroy in libd3d9_cmmon

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/video_chroma/d3d9_fmt.c        | 62 ++++++++++++++++++++++++++++++++
 modules/video_chroma/d3d9_fmt.h        |  4 +++
 modules/video_output/win32/direct3d9.c | 66 ++--------------------------------
 3 files changed, 68 insertions(+), 64 deletions(-)

diff --git a/modules/video_chroma/d3d9_fmt.c b/modules/video_chroma/d3d9_fmt.c
index 833ba6e6cf..f2a5505a54 100644
--- a/modules/video_chroma/d3d9_fmt.c
+++ b/modules/video_chroma/d3d9_fmt.c
@@ -171,3 +171,65 @@ int D3D9_FillPresentationParameters(vlc_object_t *o, d3d9_handle_t *hd3d, UINT A
 
     return VLC_SUCCESS;
 }
+
+void D3D9_Destroy(d3d9_handle_t *hd3d)
+{
+    if (hd3d->obj)
+    {
+       IDirect3D9_Release(hd3d->obj);
+       hd3d->obj = NULL;
+    }
+    if (hd3d->hdll)
+    {
+        FreeLibrary(hd3d->hdll);
+        hd3d->hdll = NULL;
+    }
+}
+
+/**
+ * It initializes an instance of Direct3D9
+ */
+#undef D3D9_Create
+int D3D9_Create(vlc_object_t *o, d3d9_handle_t *hd3d)
+{
+    hd3d->hdll = LoadLibrary(TEXT("D3D9.DLL"));
+    if (!hd3d->hdll) {
+        msg_Warn(o, "cannot load d3d9.dll, aborting");
+        return VLC_EGENERIC;
+    }
+
+    LPDIRECT3D9 (WINAPI *OurDirect3DCreate9)(UINT SDKVersion);
+    OurDirect3DCreate9 =
+        (void *)GetProcAddress(hd3d->hdll, "Direct3DCreate9");
+    if (!OurDirect3DCreate9) {
+        msg_Err(o, "Cannot locate reference to Direct3DCreate9 ABI in DLL");
+        goto error;
+    }
+
+    HRESULT (WINAPI *OurDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
+    OurDirect3DCreate9Ex =
+        (void *)GetProcAddress(hd3d->hdll, "Direct3DCreate9Ex");
+
+    /* Create the D3D object. */
+    hd3d->use_ex = false;
+    if (OurDirect3DCreate9Ex) {
+        HRESULT hr = OurDirect3DCreate9Ex(D3D_SDK_VERSION, &hd3d->objex);
+        if(!FAILED(hr)) {
+            msg_Dbg(o, "Using Direct3D9 Extended API!");
+            hd3d->use_ex = true;
+        }
+    }
+
+    if (!hd3d->obj)
+    {
+        hd3d->obj = OurDirect3DCreate9(D3D_SDK_VERSION);
+        if (!hd3d->obj) {
+            msg_Err(o, "Could not create Direct3D9 instance.");
+            goto error;
+        }
+    }
+    return VLC_SUCCESS;
+error:
+    D3D9_Destroy( hd3d );
+    return VLC_EGENERIC;
+}
diff --git a/modules/video_chroma/d3d9_fmt.h b/modules/video_chroma/d3d9_fmt.h
index b793717b9a..8fd22140d6 100644
--- a/modules/video_chroma/d3d9_fmt.h
+++ b/modules/video_chroma/d3d9_fmt.h
@@ -78,6 +78,10 @@ HRESULT D3D9_CreateDevice(vlc_object_t *, d3d9_handle_t *, HWND,
 #define D3D9_CreateDevice(a,b,c,d,e) D3D9_CreateDevice( VLC_OBJECT(a), b, c, d, e )
 
 void D3D9_ReleaseDevice(d3d9_device_t *);
+int D3D9_Create(vlc_object_t *, d3d9_handle_t *);
+#define D3D9_Create(a,b) D3D9_Create( VLC_OBJECT(a), b )
+
+void D3D9_Destroy(d3d9_handle_t *);
 
 int D3D9_FillPresentationParameters(vlc_object_t *, d3d9_handle_t *, UINT AdapterToUse, HWND,
                                     const video_format_t *, d3d9_device_t *out);
diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index 4aed47b6b1..df35bc55e1 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -184,7 +184,6 @@ static picture_pool_t*DisplayPool(vout_display_t *, unsigned);
 static int            Control(vout_display_t *, int, va_list);
 static void           Manage (vout_display_t *);
 
-static int  D3D9_Create(vlc_object_t *, d3d9_handle_t *);
 static int  Direct3D9Reset  (vout_display_t *);
 static void Direct3D9Destroy(struct d3dctx *);
 
@@ -265,7 +264,7 @@ static int Open(vlc_object_t *object)
     if (!sys)
         return VLC_ENOMEM;
 
-    if (D3D9_Create(VLC_OBJECT(vd), &sys->d3dctx.hd3d)) {
+    if (D3D9_Create(vd, &sys->d3dctx.hd3d)) {
         msg_Err(vd, "Direct3D9 could not be initialized");
         free(sys);
         return VLC_EGENERIC;
@@ -734,73 +733,12 @@ static void Manage (vout_display_t *vd)
     }
 }
 
-static void D3D9_Release(d3d9_handle_t *hd3d)
-{
-    if (hd3d->obj)
-    {
-       IDirect3D9_Release(hd3d->obj);
-       hd3d->obj = NULL;
-    }
-    if (hd3d->hdll)
-    {
-        FreeLibrary(hd3d->hdll);
-        hd3d->hdll = NULL;
-    }
-}
-
-/**
- * It initializes an instance of Direct3D9
- */
-static int D3D9_Create(vlc_object_t *o, d3d9_handle_t *hd3d)
-{
-    hd3d->hdll = LoadLibrary(TEXT("D3D9.DLL"));
-    if (!hd3d->hdll) {
-        msg_Warn(o, "cannot load d3d9.dll, aborting");
-        return VLC_EGENERIC;
-    }
-
-    LPDIRECT3D9 (WINAPI *OurDirect3DCreate9)(UINT SDKVersion);
-    OurDirect3DCreate9 =
-        (void *)GetProcAddress(hd3d->hdll, "Direct3DCreate9");
-    if (!OurDirect3DCreate9) {
-        msg_Err(o, "Cannot locate reference to Direct3DCreate9 ABI in DLL");
-        goto error;
-    }
-
-    HRESULT (WINAPI *OurDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
-    OurDirect3DCreate9Ex =
-        (void *)GetProcAddress(hd3d->hdll, "Direct3DCreate9Ex");
-
-    /* Create the D3D object. */
-    hd3d->use_ex = false;
-    if (OurDirect3DCreate9Ex) {
-        HRESULT hr = OurDirect3DCreate9Ex(D3D_SDK_VERSION, &hd3d->objex);
-        if(!FAILED(hr)) {
-            msg_Dbg(o, "Using Direct3D9 Extended API!");
-            hd3d->use_ex = true;
-        }
-    }
-
-    if (!hd3d->obj)
-    {
-        hd3d->obj = OurDirect3DCreate9(D3D_SDK_VERSION);
-        if (!hd3d->obj) {
-            msg_Err(o, "Could not create Direct3D9 instance.");
-            goto error;
-        }
-    }
-    return VLC_SUCCESS;
-error:
-    D3D9_Release( hd3d );
-    return VLC_EGENERIC;
-}
-
 /**
  * It releases an instance of Direct3D9
  */
 static void Direct3D9Destroy(struct d3dctx *d3dctx)
 {
-    D3D9_Release( &d3dctx->hd3d );
+    D3D9_Destroy( &d3dctx->hd3d );
 
     if (d3dctx->hxdll)
     {



More information about the vlc-commits mailing list