diff options
author | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-02-12 12:18:57 +0000 |
---|---|---|
committer | jaybinks <jaybinks@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-02-12 12:18:57 +0000 |
commit | 00b2331d0b1a08651374c56cce898f501a2d5104 (patch) | |
tree | dccd11e07a9c7d9c87ab50d69864a300ee686401 /Game/Code/Classes | |
parent | 64cc353a1bdcc0ef181dc8bd667ea30cd0cd191d (diff) | |
download | usdx-00b2331d0b1a08651374c56cce898f501a2d5104.tar.gz usdx-00b2331d0b1a08651374c56cce898f501a2d5104.tar.xz usdx-00b2331d0b1a08651374c56cce898f501a2d5104.zip |
changed InitializeSound to be responsive to failed module initializations,
and to remove the module and try again.
EG... in my case, sound card driver problems.
ALSA is installed but wouldnt open the audio device.
now it fails, and the output module goes to the next available ( if there is any )
then gracefully fails to dummy.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@845 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | Game/Code/Classes/UMusic.pas | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas index b06e226d..8bbd297a 100644 --- a/Game/Code/Classes/UMusic.pas +++ b/Game/Code/Classes/UMusic.pas @@ -341,18 +341,14 @@ begin result := singleton_AudioDecoder;
end;
-procedure InitializeSound;
+procedure AssignSingletonObjects();
var
lTmpInterface : IInterface;
iCount : Integer;
begin
lTmpInterface := nil;
+
- singleton_AudioPlayback := nil;
- singleton_AudioInput := nil;
- singleton_AudioDecoder := nil;
- singleton_VideoPlayback := nil;
- singleton_Visualization := nil;
for iCount := 0 to AudioManager.Count - 1 do
begin
@@ -361,34 +357,34 @@ begin // if this interface is a Playback, then set it as the default used
if ( AudioManager[iCount].QueryInterface( IAudioPlayback, lTmpInterface ) = 0 ) AND
- ( true ) then
+ ( true ) then //not assigned( singleton_AudioPlayback ) ) then
begin
singleton_AudioPlayback := IAudioPlayback( lTmpInterface );
end;
// if this interface is a Input, then set it as the default used
if ( AudioManager[iCount].QueryInterface( IAudioInput, lTmpInterface ) = 0 ) AND
- ( true ) then
+ ( true ) then //not assigned( singleton_AudioInput ) ) then
begin
singleton_AudioInput := IAudioInput( lTmpInterface );
end;
// if this interface is a Decoder, then set it as the default used
if ( AudioManager[iCount].QueryInterface( IAudioDecoder, lTmpInterface ) = 0 ) AND
- ( true ) then
+ ( true ) then //not assigned( singleton_AudioDecoder ) ) then
begin
singleton_AudioDecoder := IAudioDecoder( lTmpInterface );
end;
// if this interface is a Input, then set it as the default used
if ( AudioManager[iCount].QueryInterface( IVideoPlayback, lTmpInterface ) = 0 ) AND
- ( true ) then
+ ( true ) then //not assigned( singleton_VideoPlayback ) ) then
begin
singleton_VideoPlayback := IVideoPlayback( lTmpInterface );
end;
if ( AudioManager[iCount].QueryInterface( IVideoVisualization, lTmpInterface ) = 0 ) AND
- ( true ) then
+ ( true ) then //not assigned( singleton_Visualization ) ) then
begin
singleton_Visualization := IVideoPlayback( lTmpInterface );
end;
@@ -396,6 +392,17 @@ begin end;
end;
+end;
+
+procedure InitializeSound;
+begin
+ singleton_AudioPlayback := nil;
+ singleton_AudioInput := nil;
+ singleton_AudioDecoder := nil;
+ singleton_VideoPlayback := nil;
+ singleton_Visualization := nil;
+
+ AssignSingletonObjects();
if VideoPlayback <> nil then
@@ -404,17 +411,35 @@ begin if AudioDecoder <> nil then
begin
- AudioDecoder.InitializeDecoder;
+ while not AudioDecoder.InitializeDecoder do
+ begin
+ //writeln('Initialize failed, Removing - '+ AudioDecoder.GetName );
+ AudioManager.remove( AudioDecoder );
+ singleton_AudioDecoder := nil;
+ AssignSingletonObjects();
+ end;
end;
if AudioPlayback <> nil then
begin
- AudioPlayback.InitializePlayback;
+ while not AudioPlayback.InitializePlayback do
+ begin
+ writeln('Initialize failed, Removing - '+ AudioPlayback.GetName );
+ AudioManager.remove( AudioPlayback );
+ singleton_AudioPlayback := nil;
+ AssignSingletonObjects();
+ end;
end;
if AudioInput <> nil then
begin
- AudioInput.InitializeRecord;
+ while not AudioInput.InitializeRecord do
+ begin
+ writeln('Initialize failed, Removing - '+ AudioInput.GetName );
+ AudioManager.remove( AudioInput );
+ singleton_AudioInput := nil;
+ AssignSingletonObjects();
+ end;
end;
// Load in-game sounds
|