diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-11-05 08:42:56 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-11-05 08:42:56 +0000 |
commit | 0b2c64f09561ee2eed5efde358c282a214e5ec55 (patch) | |
tree | e9d1461d34fadfb178a03040402027ded877bec9 /mediaplugin/src | |
parent | 20bf3c992909e83e5af53cf00d87b7cbaef0d1a6 (diff) | |
download | usdx-0b2c64f09561ee2eed5efde358c282a214e5ec55.tar.gz usdx-0b2c64f09561ee2eed5efde358c282a214e5ec55.tar.xz usdx-0b2c64f09561ee2eed5efde358c282a214e5ec55.zip |
- unload plugin
- module specific init/finalize
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2708 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'mediaplugin/src')
-rw-r--r-- | mediaplugin/src/base/UMain.pas | 2 | ||||
-rw-r--r-- | mediaplugin/src/media/UAudioConverterPlugin.pas | 6 | ||||
-rw-r--r-- | mediaplugin/src/media/UAudioDecoderPlugin.pas | 4 | ||||
-rw-r--r-- | mediaplugin/src/media/UMediaPlugin.pas | 48 | ||||
-rw-r--r-- | mediaplugin/src/media/UVideoDecoderPlugin.pas | 4 |
5 files changed, 55 insertions, 9 deletions
diff --git a/mediaplugin/src/base/UMain.pas b/mediaplugin/src/base/UMain.pas index 96031f89..9e72d780 100644 --- a/mediaplugin/src/base/UMain.pas +++ b/mediaplugin/src/base/UMain.pas @@ -340,6 +340,8 @@ begin Log.LogStatus('Uninitialize 3D', 'Finalization'); Finalize3D(); + UnloadMediaPlugins(); + Log.LogStatus('Finalize SDL', 'Finalization'); SDL_Quit(); diff --git a/mediaplugin/src/media/UAudioConverterPlugin.pas b/mediaplugin/src/media/UAudioConverterPlugin.pas index 5e69e8ca..b6ede1fb 100644 --- a/mediaplugin/src/media/UAudioConverterPlugin.pas +++ b/mediaplugin/src/media/UAudioConverterPlugin.pas @@ -93,18 +93,18 @@ end; function TAudioConverterPlugin.GetPriority(): integer; begin - Result := fPluginInfo.audioDecoder.priority; + Result := fPluginInfo.audioConverter.priority; end; function TAudioConverterPlugin.Init(): boolean; begin - //fPluginInfo.initialize(); + fPluginInfo.audioConverter.init(); Result := true; end; function TAudioConverterPlugin.Finalize(): boolean; begin - //fPluginInfo.finalize(); + fPluginInfo.audioConverter.finalize(); Result := true; end; diff --git a/mediaplugin/src/media/UAudioDecoderPlugin.pas b/mediaplugin/src/media/UAudioDecoderPlugin.pas index 0d23a368..e90d0781 100644 --- a/mediaplugin/src/media/UAudioDecoderPlugin.pas +++ b/mediaplugin/src/media/UAudioDecoderPlugin.pas @@ -219,13 +219,13 @@ end; function TAudioDecoderPlugin.InitializeDecoder: boolean; begin - //fPluginInfo.initialize(); + fPluginInfo.audioDecoder.init(); Result := true; end; function TAudioDecoderPlugin.FinalizeDecoder(): boolean; begin - //fPluginInfo.finalize(); + fPluginInfo.audioDecoder.finalize(); Result := true; end; diff --git a/mediaplugin/src/media/UMediaPlugin.pas b/mediaplugin/src/media/UMediaPlugin.pas index 934b22b7..277e6dda 100644 --- a/mediaplugin/src/media/UMediaPlugin.pas +++ b/mediaplugin/src/media/UMediaPlugin.pas @@ -92,6 +92,8 @@ type PAudioDecoderInfo = ^TAudioDecoderInfo; TAudioDecoderInfo = record priority: cint; + init: function(): cbool; cdecl; + finalize: function(): cbool; cdecl; open: function(filename: PAnsiChar): PAudioDecodeStream; cdecl; close: procedure(stream: PAudioDecodeStream); cdecl; getLength: function(stream: PAudioDecodeStream): double; cdecl; @@ -108,6 +110,8 @@ type PAudioConverterInfo = ^TAudioConverterInfo; TAudioConverterInfo = record priority: cint; + init: function(): cbool; cdecl; + finalize: function(): cbool; cdecl; open: function(inputFormat: PCAudioFormatInfo; outputFormat: PCAudioFormatInfo): PAudioConvertStream; cdecl; close: procedure(stream: PAudioConvertStream); cdecl; convert: function(stream: PAudioConvertStream; input, output: PCuint8; numSamples: PCint): cint; cdecl; @@ -118,6 +122,8 @@ type PVideoDecoderInfo = ^TVideoDecoderInfo; TVideoDecoderInfo = record priority: cint; + init: function(): cbool; cdecl; + finalize: function(): cbool; cdecl; open: function(filename: PAnsiChar): PVideoDecodeStream; cdecl; close: procedure(stream: PVideoDecodeStream); cdecl; setLoop: procedure(stream: PVideoDecodeStream; enable: cbool); cdecl; @@ -144,6 +150,7 @@ type TPluginRegisterFunc = function(core: PMediaPluginCore): PMediaPluginInfo; cdecl; procedure LoadMediaPlugins(); +procedure UnloadMediaPlugins(); function MediaPluginCore: PMediaPluginCore; @@ -396,6 +403,16 @@ begin end; end; +var + MediaPlugins: TList; + +type + PMediaPluginEntry = ^TMediaPluginEntry; + TMediaPluginEntry = record + Module: TModuleHandle; + Info: PMediaPluginInfo; + end; + procedure LoadMediaPlugins(); var LibPath: IPath; @@ -405,7 +422,10 @@ var Module: TModuleHandle; RegisterFunc: TPluginRegisterFunc; PluginInfo: PMediaPluginInfo; + PluginEntry: PMediaPluginEntry; begin + MediaPlugins := TList.Create; + LibPath := MediaPluginPath.Append('*.dll'); Iter := FileSystem.FileFind(LibPath, faAnyFile); while (Iter.HasNext) do @@ -434,7 +454,8 @@ begin UnloadModule(Module); Continue; end; - if (not PluginInfo.initialize()) then + if ((@PluginInfo.initialize <> nil) and + (not PluginInfo.initialize())) then begin Log.LogError('Failed to initialize media plugin: "' + PluginInfo.name + '"', 'LoadMediaPlugins'); @@ -444,7 +465,12 @@ begin Log.LogStatus('Loaded media plugin: "' + PluginInfo.name + '"', 'LoadMediaPlugins'); - + + New(PluginEntry); + PluginEntry.Module := Module; + PluginEntry.Info := PluginInfo; + MediaPlugins.Add(PluginEntry); + // register modules if (PluginInfo.audioDecoder <> nil) then MediaManager.Add(TAudioDecoderPlugin.Create(PluginInfo)); @@ -455,6 +481,24 @@ begin end; end; +procedure UnloadMediaPlugins(); +var + I: integer; + PluginEntry: PMediaPluginEntry; +begin + for I := 0 to MediaPlugins.Count - 1 do + begin + PluginEntry := MediaPlugins[I]; + if ((@PluginEntry.Info.finalize <> nil) and + (not PluginEntry.Info.finalize())) then + begin + Log.LogError('Failed to finalize media plugin: "' + PluginEntry.Info.name + '"', + 'UnloadMediaPlugins'); + end; + UnloadModule(PluginEntry.Module); + end; +end; + initialization InitializeMediaPluginCore; diff --git a/mediaplugin/src/media/UVideoDecoderPlugin.pas b/mediaplugin/src/media/UVideoDecoderPlugin.pas index 1655f325..722928d8 100644 --- a/mediaplugin/src/media/UVideoDecoderPlugin.pas +++ b/mediaplugin/src/media/UVideoDecoderPlugin.pas @@ -111,13 +111,13 @@ end; function TVideoDecoderPlugin.InitializeDecoder(): boolean; begin - //fPluginInfo.initialize(); + fPluginInfo.videoDecoder.init(); Result := true; end; function TVideoDecoderPlugin.FinalizeDecoder(): boolean; begin - //fPluginInfo.finalize(); + fPluginInfo.videoDecoder.finalize(); Result := true; end; |