[vlc-commits] d3d11_player: move the textures release in a separate function

Steve Lhomme git at videolan.org
Tue Feb 4 09:58:43 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Feb  4 09:50:11 2020 +0100| [0bac9a08fe4d1c5c28da9ae27d6dcc5e8abaf3b0] | committer: Steve Lhomme

d3d11_player: move the textures release in a separate function

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

 doc/libvlc/d3d11_player.cpp | 61 ++++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 28 deletions(-)

diff --git a/doc/libvlc/d3d11_player.cpp b/doc/libvlc/d3d11_player.cpp
index fb8bd81b7e..8fc3d84ac1 100644
--- a/doc/libvlc/d3d11_player.cpp
+++ b/doc/libvlc/d3d11_player.cpp
@@ -267,16 +267,45 @@ static void init_direct3d(struct render_context *ctx)
 
 }
 
+static void release_textures(struct render_context *ctx)
+{
+    if (ctx->resized.sharedHandled)
+    {
+        CloseHandle(ctx->resized.sharedHandled);
+        ctx->resized.sharedHandled = NULL;
+    }
+    if (ctx->resized.textureVLC)
+    {
+        ctx->resized.textureVLC->Release();
+        ctx->resized.textureVLC = NULL;
+    }
+    if (ctx->resized.textureShaderInput)
+    {
+        ctx->resized.textureShaderInput->Release();
+        ctx->resized.textureShaderInput = NULL;
+    }
+    if (ctx->resized.textureRenderTarget)
+    {
+        ctx->resized.textureRenderTarget->Release();
+        ctx->resized.textureRenderTarget = NULL;
+    }
+    if (ctx->resized.texture)
+    {
+        ctx->resized.texture->Release();
+        ctx->resized.texture = NULL;
+    }
+}
+
 static void release_direct3d(struct render_context *ctx)
 {
     ctx->d3deviceVLC->Release();
+
+    release_textures(ctx);
+
     ctx->d3dctxVLC->Release();
     ctx->d3deviceVLC->Release();
 
     ctx->samplerState->Release();
-    ctx->resized.textureRenderTarget->Release();
-    ctx->resized.textureShaderInput->Release();
-    ctx->resized.texture->Release();
     ctx->pShadersInputLayout->Release();
     ctx->pVS->Release();
     ctx->pPS->Release();
@@ -296,31 +325,7 @@ static bool UpdateOutput_cb( void *opaque, const libvlc_video_direct3d_cfg_t *cf
 
     DXGI_FORMAT renderFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
 
-    if (ctx->resized.texture)
-    {
-        ctx->resized.texture->Release();
-        ctx->resized.texture = NULL;
-    }
-    if (ctx->resized.textureVLC)
-    {
-        ctx->resized.textureVLC->Release();
-        ctx->resized.textureVLC = NULL;
-    }
-    if (ctx->resized.textureShaderInput)
-    {
-        ctx->resized.textureShaderInput->Release();
-        ctx->resized.textureShaderInput = NULL;
-    }
-    if (ctx->resized.textureRenderTarget)
-    {
-        ctx->resized.textureRenderTarget->Release();
-        ctx->resized.textureRenderTarget = NULL;
-    }
-    if (ctx->resized.sharedHandled)
-    {
-        CloseHandle(ctx->resized.sharedHandled);
-        ctx->resized.sharedHandled = NULL;
-    }
+    release_textures(ctx);
 
     /* interim texture */
     D3D11_TEXTURE2D_DESC texDesc = { };



More information about the vlc-commits mailing list