浏览代码

coreaudio-encoder: Actually fix coreaudio loading

Apparently using LoadLibrary on a full path doesn't work -- you need to
use SetDllDirectory before loading a library.
jp9000 5 年之前
父节点
当前提交
e1a0c60735
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      plugins/coreaudio-encoder/windows-imports.h

+ 5 - 3
plugins/coreaudio-encoder/windows-imports.h

@@ -376,11 +376,13 @@ static bool load_from_shell_path(REFKNOWNFOLDERID rfid, const wchar_t *subpath)
 	}
 
 	wchar_t path[MAX_PATH];
-	_snwprintf(path, MAX_PATH, L"%s\\%s\\%s", sh_path, subpath,
-		   L"CoreAudioToolbox.dll");
+	_snwprintf(path, MAX_PATH, L"%s\\%s", sh_path, subpath);
 	CoTaskMemFree(sh_path);
 
-	audio_toolbox = LoadLibraryW(path);
+	SetDllDirectory(path);
+	audio_toolbox = LoadLibraryW(L"CoreAudioToolbox.dll");
+	SetDllDirectory(nullptr);
+
 	return !!audio_toolbox;
 }