aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-03 02:36:27 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-03-03 02:36:27 +0000
commit797b4d8d6323c03cd0a04c54e72853cb4876edb7 (patch)
tree1f224f8e956d6b0ebb0695ad38c856707f9aa97b /Game/Code
parent27ac24c937a9e88c6d08b157d26c2d308e4e76a6 (diff)
downloadusdx-797b4d8d6323c03cd0a04c54e72853cb4876edb7.tar.gz
usdx-797b4d8d6323c03cd0a04c54e72853cb4876edb7.tar.xz
usdx-797b4d8d6323c03cd0a04c54e72853cb4876edb7.zip
- Portaudio-Core added (at the moment just one helper function)
- Removed the version-number from the project-file (there were three different locations were version numbers were declared and one was wrong (UCore.Create stated it was beta)). I moved the USDX version number to UConfig.pas (Will be introduced in one of the following commits). git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@893 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code')
-rw-r--r--Game/Code/Classes/UAudioCore_Portaudio.pas99
-rw-r--r--Game/Code/UltraStar.dpr6
2 files changed, 101 insertions, 4 deletions
diff --git a/Game/Code/Classes/UAudioCore_Portaudio.pas b/Game/Code/Classes/UAudioCore_Portaudio.pas
new file mode 100644
index 00000000..952b211b
--- /dev/null
+++ b/Game/Code/Classes/UAudioCore_Portaudio.pas
@@ -0,0 +1,99 @@
+unit UAudioCore_Portaudio;
+
+interface
+
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
+{$I ../switches.inc}
+
+
+uses
+ Classes,
+ SysUtils,
+ portaudio;
+
+type
+ TAudioCore_Portaudio = class
+ public
+ class function GetPreferredApiIndex(): TPaHostApiIndex;
+ end;
+
+implementation
+
+uses
+ ULog;
+
+{*
+ * The default API used by Portaudio is the least common denominator
+ * and might lack efficiency. In addition it might not even work.
+ * We use an array named ApiPreferenceOrder with which we define the order of
+ * preferred APIs to use. The first API-type in the list is tried first.
+ * If it is not available the next one is tried and so on ...
+ * If none of the preferred APIs was found the default API (detected by
+ * portaudio) is used.
+ *
+ * Pascal does not permit zero-length static arrays, so you must use paDefaultApi
+ * as an array's only member if you do not have any preferences.
+ * You can also append paDefaultApi to a non-zero length preferences array but
+ * this is optional because the default API is always used as a fallback.
+ *}
+const
+ paDefaultApi = -1;
+const
+ ApiPreferenceOrder:
+{$IF Defined(MSWINDOWS)}
+ // Note1: Portmixer has no mixer support for paASIO and paWASAPI at the moment
+ // Note2: Windows Default-API is MME, but DirectSound is faster
+ array[0..0] of TPaHostApiTypeId = ( paDirectSound );
+{$ELSEIF Defined(LINUX)}
+ // Note: Portmixer has no mixer support for JACK at the moment
+ array[0..2] of TPaHostApiTypeId = ( paALSA, paJACK, paOSS );
+{$ELSEIF Defined(DARWIN)}
+ array[0..0] of TPaHostApiTypeId = ( paDefaultApi ); // paCoreAudio
+{$ELSE}
+ array[0..0] of TPaHostApiTypeId = ( paDefaultApi );
+{$IFEND}
+
+
+{ TAudioInput_Portaudio }
+
+class function TAudioCore_Portaudio.GetPreferredApiIndex(): TPaHostApiIndex;
+var
+ i: integer;
+ apiIndex: TPaHostApiIndex;
+ apiInfo: PPaHostApiInfo;
+begin
+ result := -1;
+
+ // select preferred sound-API
+ for i:= 0 to High(ApiPreferenceOrder) do
+ begin
+ if(ApiPreferenceOrder[i] <> paDefaultApi) then
+ begin
+ // check if API is available
+ apiIndex := Pa_HostApiTypeIdToHostApiIndex(ApiPreferenceOrder[i]);
+ if(apiIndex >= 0) then
+ begin
+ // we found an API but we must check if it works
+ // (on linux portaudio might detect OSS but does not provide
+ // any devices if ALSA is enabled)
+ apiInfo := Pa_GetHostApiInfo(apiIndex);
+ if (apiInfo^.deviceCount > 0) then
+ begin
+ Result := apiIndex;
+ break;
+ end;
+ end;
+ end;
+ end;
+
+ // None of the preferred APIs is available -> use default
+ if(result < 0) then
+ begin
+ result := Pa_GetDefaultHostApi();
+ end;
+end;
+
+end.
diff --git a/Game/Code/UltraStar.dpr b/Game/Code/UltraStar.dpr
index 55046af3..4acb5d1f 100644
--- a/Game/Code/UltraStar.dpr
+++ b/Game/Code/UltraStar.dpr
@@ -24,6 +24,7 @@ uses
{$ENDIF}
{$IFDEF UsePortaudio}
portaudio in 'lib\portaudio\delphi\portaudio.pas',
+ UAudioCore_Portaudio in 'Classes\UAudioCore_Portaudio.pas',
{$ENDIF}
{$IFDEF UsePortmixer}
portmixer in 'lib\portmixer\delphi\portmixer.pas',
@@ -127,7 +128,7 @@ uses
UPluginInterface in 'Classes\UPluginInterface.pas', //Interface offered by Core to Plugins
uPluginLoader in 'Classes\uPluginLoader.pas', //New Plugin Loader Module
- UParty in 'Classes\UParty.pas', // to - do : rewrite Party Manager as Module, reomplent ability to offer party Mody by Plugin
+ UParty in 'Classes\UParty.pas', // TODO: rewrite Party Manager as Module, reomplent ability to offer party Mody by Plugin
UPlatform in 'Classes\UPlatform.pas',
{$IFDEF WIN32}
UPlatformWindows in 'Classes\UPlatformWindows.pas',
@@ -233,9 +234,6 @@ uses
{$ENDIF}
SysUtils;
-const
- Version = 'UltraStar Deluxe V 1.10 Alpha Build';
-
{$IFNDEF FPC}
begin
Main;