aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/decode/d3d11va.c
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2016-05-17 11:57:28 +0200
committerGravatar wm4 <wm4@nowhere>2016-05-17 11:59:54 +0200
commita02d77ba0df747b60ffad7d2a5eacfc6528aabef (patch)
tree6e2187738fba74cb68c082cfe23663ac8d120c96 /video/decode/d3d11va.c
parent39b64fb176bf90d7146cf7f20c61ab3e7def4191 (diff)
d3d: simplify DLL loading
For some reason, the d3d9/dxva2/d3d11 DLLs are still optional. But we don't need to try so hard to keep exact references. In fact, there's no reason to unload them at all. So load them once in a central place. For simplicity, the d3d9/d3d11 backends both load all DLLs. (They will error out only if the required DLLs could not be loaded.) In theory, we could just call LoadLibrary multiple times (without calling FreeLibrary), but I'm slightly worried that this could be detected as a "bug", or that the reference count could even have a low static limit that could be hit soon.
Diffstat (limited to 'video/decode/d3d11va.c')
-rw-r--r--video/decode/d3d11va.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/video/decode/d3d11va.c b/video/decode/d3d11va.c
index d631fff479..dd4535bdd7 100644
--- a/video/decode/d3d11va.c
+++ b/video/decode/d3d11va.c
@@ -40,7 +40,6 @@ struct d3d11va_decoder {
struct priv {
struct mp_log *log;
- HMODULE d3d11_dll;
ID3D11Device *device;
ID3D11DeviceContext *device_ctx;
ID3D11VideoDevice *video_dev;
@@ -51,7 +50,6 @@ struct priv {
};
struct d3d11va_surface {
- HMODULE d3d11_dll;
ID3D11Texture2D *texture;
int subindex;
ID3D11VideoDecoderOutputView *surface;
@@ -66,9 +64,6 @@ static void d3d11va_release_img(void *arg)
if (surface->texture)
ID3D11Texture2D_Release(surface->texture);
- if (surface->d3d11_dll)
- FreeLibrary(surface->d3d11_dll);
-
talloc_free(surface);
}
@@ -79,10 +74,6 @@ static struct mp_image *d3d11va_new_ref(ID3D11VideoDecoderOutputView *view,
return NULL;
struct d3d11va_surface *surface = talloc_zero(NULL, struct d3d11va_surface);
- surface->d3d11_dll = LoadLibrary(L"d3d11.dll");
- if (!surface->d3d11_dll)
- goto fail;
-
surface->surface = view;
ID3D11VideoDecoderOutputView_AddRef(surface->surface);
ID3D11VideoDecoderOutputView_GetResource(
@@ -105,9 +96,6 @@ static struct mp_image *d3d11va_new_ref(ID3D11VideoDecoderOutputView *view,
mpi->planes[3] = (void *)surface->surface;
return mpi;
-fail:
- d3d11va_release_img(surface);
- return NULL;
}
static struct mp_image *d3d11va_allocate_image(struct lavc_ctx *s, int w, int h)
@@ -434,9 +422,6 @@ static void destroy_device(struct lavc_ctx *s)
if (p->device_ctx)
ID3D11DeviceContext_Release(p->device_ctx);
-
- if (p->d3d11_dll)
- FreeLibrary(p->d3d11_dll);
}
static bool create_device(struct lavc_ctx *s, BOOL thread_safe)
@@ -444,14 +429,14 @@ static bool create_device(struct lavc_ctx *s, BOOL thread_safe)
HRESULT hr;
struct priv *p = s->hwdec_priv;
- p->d3d11_dll = LoadLibrary(L"d3d11.dll");
- if (!p->d3d11_dll) {
+ d3d_load_dlls();
+ if (!d3d11_dll) {
MP_ERR(p, "Failed to load D3D11 library\n");
return false;
}
PFN_D3D11_CREATE_DEVICE CreateDevice =
- (void *)GetProcAddress(p->d3d11_dll, "D3D11CreateDevice");
+ (void *)GetProcAddress(d3d11_dll, "D3D11CreateDevice");
if (!CreateDevice) {
MP_ERR(p, "Failed to get D3D11CreateDevice symbol from DLL: %s\n",
mp_LastError_to_str());