From dbdb5b7e4fc5acd72c9283990a412fffb7bb33c3 Mon Sep 17 00:00:00 2001 From: tobigun Date: Wed, 1 Dec 2010 18:00:32 +0000 Subject: - implement Mac specific abstract UPlatform.GetMusicPath() for win and linux - add UPlatform.AddLibrarySearchPath() to be able to add new dll search paths - use AddLibrarySearchPath() for loading plugin dependencies (e.g. ffmpeg libs) from game/mediaplugins/deps git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2758 b956fd51-792f-4845-bead-9b4dfca2ff2c --- mediaplugin/src/base/UPlatform.pas | 19 ++++++++++++++++++- mediaplugin/src/base/UPlatformWindows.pas | 10 ++++++++++ mediaplugin/src/media/UMediaPlugin.pas | 6 ++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/mediaplugin/src/base/UPlatform.pas b/mediaplugin/src/base/UPlatform.pas index 6d884979..4239e21a 100644 --- a/mediaplugin/src/base/UPlatform.pas +++ b/mediaplugin/src/base/UPlatform.pas @@ -51,9 +51,11 @@ type procedure Halt; virtual; function GetLogPath: IPath; virtual; abstract; - function GetMusicPath: IPath; virtual; abstract; + function GetMusicPath: IPath; virtual; function GetGameSharedPath: IPath; virtual; abstract; function GetGameUserPath: IPath; virtual; abstract; + + procedure AddLibrarySearchPath(const DLLPath: IPath); virtual; end; function Platform(): TPlatform; @@ -113,6 +115,21 @@ begin Result := ExecDir.GetAbsolutePath(); end; +{** + * Dummy implementation (Mac specific) + *} +function TPlatform.GetMusicPath: IPath; +begin + Result := PATH_NONE; +end; + +{** + * Dummy implementation (Windows specific) + *} +procedure TPlatform.AddLibrarySearchPath(const DLLPath: IPath); +begin +end; + (** * Default TerminateIfAlreadyRunning() implementation *) diff --git a/mediaplugin/src/base/UPlatformWindows.pas b/mediaplugin/src/base/UPlatformWindows.pas index 91d3cce6..a0059687 100644 --- a/mediaplugin/src/base/UPlatformWindows.pas +++ b/mediaplugin/src/base/UPlatformWindows.pas @@ -51,6 +51,7 @@ type public procedure Init; override; function TerminateIfAlreadyRunning(var WndTitle: String): Boolean; override; + procedure AddLibrarySearchPath(const DLLPath: IPath); override; function GetLogPath: IPath; override; function GetGameSharedPath: IPath; override; @@ -63,6 +64,7 @@ uses SysUtils, ShlObj, Windows, + UPathUtils, UConfig; procedure TPlatformWindows.Init; @@ -206,4 +208,12 @@ begin Result := GetSpecialPath(CSIDL_APPDATA).Append('ultrastardx', pdAppend); end; +function SetDllDirectory(lpPathName: PWideChar): Bool; stdcall; + external kernel32 name 'SetDllDirectoryW'; + +procedure TPlatformWindows.AddLibrarySearchPath(const DLLPath: IPath); +begin + SetDllDirectory(PWideChar(DLLPath.ToWide())); +end; + end. diff --git a/mediaplugin/src/media/UMediaPlugin.pas b/mediaplugin/src/media/UMediaPlugin.pas index 4baa778a..8632b9df 100644 --- a/mediaplugin/src/media/UMediaPlugin.pas +++ b/mediaplugin/src/media/UMediaPlugin.pas @@ -168,6 +168,7 @@ uses UPath, UPathUtils, ULog, + UPlatform, UAudioDecoderPlugin, UAudioConverterPlugin, UVideoDecoderPlugin; @@ -434,6 +435,11 @@ const begin MediaPlugins := TList.Create; + {$IFDEF MSWINDOWS} + // add an additional dll search path for plugin dependencies + Platform.AddLibrarySearchPath(MediaPluginPath.Append('deps')); + {$ENDIF} + LibPath := MediaPluginPath.Append('*' + ModuleExt); Iter := FileSystem.FileFind(LibPath, faAnyFile); while (Iter.HasNext) do -- cgit v1.2.3