aboutsummaryrefslogtreecommitdiffstats
path: root/mediaplugin/src/base
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-11-02 23:58:34 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-11-02 23:58:34 +0000
commit20bf3c992909e83e5af53cf00d87b7cbaef0d1a6 (patch)
tree0120d448ed644678411423a38e02a42fa2b017ae /mediaplugin/src/base
parent5000060b04bed23cbbd88ba43ed546220c4b7c69 (diff)
downloadusdx-20bf3c992909e83e5af53cf00d87b7cbaef0d1a6.tar.gz
usdx-20bf3c992909e83e5af53cf00d87b7cbaef0d1a6.tar.xz
usdx-20bf3c992909e83e5af53cf00d87b7cbaef0d1a6.zip
- Support for media interface priorities
- all media interfaces classes have to explicitly implement IMediaInterface, otherwise access to the priority and name will fail git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2707 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--mediaplugin/src/base/UMusic.pas66
-rw-r--r--mediaplugin/src/base/URecord.pas2
2 files changed, 50 insertions, 18 deletions
diff --git a/mediaplugin/src/base/UMusic.pas b/mediaplugin/src/base/UMusic.pas
index e93a1037..1f7c8e8f 100644
--- a/mediaplugin/src/base/UMusic.pas
+++ b/mediaplugin/src/base/UMusic.pas
@@ -738,7 +738,35 @@ begin
Result := DefaultAudioConverter;
end;
-procedure FilterInterfaceList(const IID: TGUID; InList, OutList: TInterfaceList);
+{**
+ * Sort media interfaces in the order of their priority.
+ * The highest priority interface will be the first in list.
+ *}
+procedure SortMediaIFacesByPrio(List: TInterfaceList);
+var
+ I, N: integer;
+ Sorted: boolean;
+ IFace1, IFace2: IMediaInterface;
+begin
+ // this is not time critical, use a simple Bubblesort
+ N := List.Count - 1;
+ repeat
+ Sorted := true;
+ for I := 1 to N do
+ begin
+ IFace1 := (List[I-1] as IMediaInterface);
+ IFace2 := (List[I] as IMediaInterface);
+ if (IFace1.GetPriority < IFace2.GetPriority) then
+ begin
+ List.Exchange(I-1, I);
+ Sorted := false;
+ end;
+ end;
+ Dec(N);
+ until Sorted;
+end;
+
+procedure FilterMediaIFaceList(const IID: TGUID; InList, OutList: TInterfaceList);
var
i: integer;
obj: IInterface;
@@ -756,6 +784,7 @@ begin
OutList.Add(obj);
end;
end;
+ SortMediaIFacesByPrio(OutList);
end;
procedure InitializeSound;
@@ -771,7 +800,7 @@ begin
InterfaceList := TInterfaceList.Create();
// initialize all audio-decoders first
- FilterInterfaceList(IAudioDecoder, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IAudioDecoder, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
begin
CurrentAudioDecoder := InterfaceList[i] as IAudioDecoder;
@@ -784,11 +813,11 @@ begin
// create and setup decoder-list (see AudioDecoders())
AudioDecoderList := TInterfaceList.Create;
- FilterInterfaceList(IAudioDecoder, MediaManager, AudioDecoders);
+ FilterMediaIFaceList(IAudioDecoder, MediaManager, AudioDecoders);
// find and initialize playback interface
DefaultAudioPlayback := nil;
- FilterInterfaceList(IAudioPlayback, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IAudioPlayback, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
begin
CurrentAudioPlayback := InterfaceList[i] as IAudioPlayback;
@@ -803,7 +832,7 @@ begin
// find and initialize converter interface
DefaultAudioConverter := nil;
- FilterInterfaceList(IAudioConverter, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IAudioConverter, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
begin
CurrentAudioConverter := InterfaceList[i] as IAudioConverter;
@@ -818,7 +847,7 @@ begin
// find and initialize input interface
DefaultAudioInput := nil;
- FilterInterfaceList(IAudioInput, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IAudioInput, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
begin
CurrentAudioInput := InterfaceList[i] as IAudioInput;
@@ -852,14 +881,17 @@ begin
// initialize and set video-playback singleton
DefaultVideoPlayback := nil;
- FilterInterfaceList(IVideoPlayback, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IVideoPlayback, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
begin
VideoInterface := InterfaceList[i] as IVideoPlayback;
+ // ignore visualizations
+ if (Supports(VideoInterface, IVideoVisualization)) then
+ Continue;
if (VideoInterface.Init()) then
begin
DefaultVideoPlayback := VideoInterface;
- break;
+ Break;
end;
Log.LogError('Initialize failed, Removing - '+ VideoInterface.GetName);
MediaManager.Remove(VideoInterface);
@@ -867,7 +899,7 @@ begin
// initialize and set video-decoder singleton
DefaultVideoDecoder := nil;
- FilterInterfaceList(IVideoDecoder, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IVideoDecoder, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
begin
VideoDecoderInterface := InterfaceList[i] as IVideoDecoder;
@@ -882,7 +914,7 @@ begin
// initialize and set visualization singleton
DefaultVisualization := nil;
- FilterInterfaceList(IVideoVisualization, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IVideoVisualization, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
begin
VisualInterface := InterfaceList[i] as IVideoVisualization;
@@ -923,37 +955,37 @@ begin
InterfaceList := TInterfaceList.Create();
// finalize audio playback interfaces (should be done before the decoders)
- FilterInterfaceList(IAudioPlayback, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IAudioPlayback, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
(InterfaceList[i] as IAudioPlayback).FinalizePlayback();
// finalize audio input interfaces
- FilterInterfaceList(IAudioInput, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IAudioInput, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
(InterfaceList[i] as IAudioInput).FinalizeRecord();
// finalize audio decoder interfaces
- FilterInterfaceList(IAudioDecoder, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IAudioDecoder, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
(InterfaceList[i] as IAudioDecoder).FinalizeDecoder();
// finalize audio converter interfaces
- FilterInterfaceList(IAudioConverter, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IAudioConverter, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
(InterfaceList[i] as IAudioConverter).Finalize();
// finalize video interfaces
- FilterInterfaceList(IVideoPlayback, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IVideoPlayback, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
(InterfaceList[i] as IVideoPlayback).Finalize();
// finalize video decoder interfaces
- FilterInterfaceList(IVideoDecoder, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IVideoDecoder, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
(InterfaceList[i] as IVideoDecoder).FinalizeDecoder();
// finalize visualization interfaces
- FilterInterfaceList(IVideoVisualization, MediaManager, InterfaceList);
+ FilterMediaIFaceList(IVideoVisualization, MediaManager, InterfaceList);
for i := 0 to InterfaceList.Count-1 do
(InterfaceList[i] as IVideoVisualization).Finalize();
diff --git a/mediaplugin/src/base/URecord.pas b/mediaplugin/src/base/URecord.pas
index de567aba..d2cfccab 100644
--- a/mediaplugin/src/base/URecord.pas
+++ b/mediaplugin/src/base/URecord.pas
@@ -169,7 +169,7 @@ type
InputDevice: TAudioInputDevice);
end;
- TAudioInputBase = class( TInterfacedObject, IAudioInput )
+ TAudioInputBase = class(TInterfacedObject, IMediaInterface, IAudioInput)
private
Started: boolean;
protected