summaryrefslogtreecommitdiffstats
path: root/video/decode/d3d.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-05-17 11:57:28 +0200
committerwm4 <wm4@nowhere>2016-05-17 11:59:54 +0200
commita02d77ba0df747b60ffad7d2a5eacfc6528aabef (patch)
tree6e2187738fba74cb68c082cfe23663ac8d120c96 /video/decode/d3d.c
parent39b64fb176bf90d7146cf7f20c61ab3e7def4191 (diff)
downloadmpv-a02d77ba0df747b60ffad7d2a5eacfc6528aabef.tar.bz2
mpv-a02d77ba0df747b60ffad7d2a5eacfc6528aabef.tar.xz
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/d3d.c')
-rw-r--r--video/decode/d3d.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/video/decode/d3d.c b/video/decode/d3d.c
index df10c9fe19..b978472723 100644
--- a/video/decode/d3d.c
+++ b/video/decode/d3d.c
@@ -15,6 +15,8 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <pthread.h>
+
#include <libavcodec/avcodec.h>
#include "lavc.h"
@@ -96,6 +98,22 @@ static const struct d3dva_mode d3dva_modes[] = {
#undef MODE
#undef MODE2
+HMODULE d3d11_dll, d3d9_dll, dxva2_dll;
+
+static pthread_once_t d3d_load_once = PTHREAD_ONCE_INIT;
+
+static void d3d_do_load(void)
+{
+ d3d11_dll = LoadLibrary(L"d3d11.dll");
+ d3d9_dll = LoadLibrary(L"d3d9.dll");
+ dxva2_dll = LoadLibrary(L"dxva2.dll");
+}
+
+void d3d_load_dlls(void)
+{
+ pthread_once(&d3d_load_once, d3d_do_load);
+}
+
int d3d_probe_codec(const char *codec)
{
enum AVCodecID codecid = mp_codec_to_av_codec_id(codec);