diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-05-10 10:37:22 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-05-10 10:37:22 +0000 |
commit | 8af89b5940bd15b013e3f48536888e352eb1c43b (patch) | |
tree | 719494bd328bff489b8e566ab620850b65ae1769 /Game/Code/Classes | |
parent | b122ec521106f9424ead8058cb3b4ab5cc7ac8a3 (diff) | |
download | usdx-8af89b5940bd15b013e3f48536888e352eb1c43b.tar.gz usdx-8af89b5940bd15b013e3f48536888e352eb1c43b.tar.xz usdx-8af89b5940bd15b013e3f48536888e352eb1c43b.zip |
Update to Bass 2.4. Do not forget to replace the old with the new dll.
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1080 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r-- | Game/Code/Classes/UAudioCore_Bass.pas | 46 | ||||
-rw-r--r-- | Game/Code/Classes/UAudioCore_Portaudio.pas | 5 | ||||
-rw-r--r-- | Game/Code/Classes/UAudioInput_Bass.pas | 90 | ||||
-rw-r--r-- | Game/Code/Classes/UAudioPlayback_Bass.pas | 118 | ||||
-rw-r--r-- | Game/Code/Classes/UCommon.pas | 19 |
5 files changed, 168 insertions, 110 deletions
diff --git a/Game/Code/Classes/UAudioCore_Bass.pas b/Game/Code/Classes/UAudioCore_Bass.pas index 442c999b..1d045b88 100644 --- a/Game/Code/Classes/UAudioCore_Bass.pas +++ b/Game/Code/Classes/UAudioCore_Bass.pas @@ -9,36 +9,50 @@ interface {$I switches.inc}
uses
- {$IFDEF MSWINDOWS}
- Windows,
- {$ENDIF}
Classes,
SysUtils,
- UMusic;
+ UMusic,
+ bass; // (Note: DWORD is defined here)
type
TAudioCore_Bass = class
private
+ constructor Create(); public
- class function ErrorGetString(): string; overload;
- class function ErrorGetString(errCode: integer): string; overload;
- class function ConvertAudioFormatToBASSFlags(Format: TAudioSampleFormat; out Flags: DWORD): boolean;
+ class function GetInstance(): TAudioCore_Bass;
+ function ErrorGetString(): string; overload;
+ function ErrorGetString(errCode: integer): string; overload;
+ function ConvertAudioFormatToBASSFlags(Format: TAudioSampleFormat; out Flags: DWORD): boolean;
end;
-
+
implementation
uses
UMain,
- ULog,
- bass;
+ ULog;
+
+var
+ Instance: TAudioCore_Bass;
+
+constructor TAudioCore_Bass.Create();
+begin + inherited; +end; +
+class function TAudioCore_Bass.GetInstance(): TAudioCore_Bass;
+begin + if not assigned(Instance) then + Instance := TAudioCore_Bass.Create(); + Result := Instance; +end; -class function TAudioCore_Bass.ErrorGetString(): string;
+function TAudioCore_Bass.ErrorGetString(): string;
begin
Result := ErrorGetString(BASS_ErrorGetCode());
end;
-class function TAudioCore_Bass.ErrorGetString(errCode: integer): string;
+function TAudioCore_Bass.ErrorGetString(errCode: integer): string;
begin
case errCode of
BASS_OK:
@@ -63,8 +77,6 @@ begin result := 'Paused/stopped';
BASS_ERROR_ALREADY:
result := 'Already created/used';
- BASS_ERROR_NOPAUSE:
- result := 'No pause';
BASS_ERROR_NOCHAN:
result := 'No free channels';
BASS_ERROR_ILLTYPE:
@@ -93,8 +105,6 @@ begin result := 'Creation error';
BASS_ERROR_NOFX:
result := 'DX8 effects unavailable';
- BASS_ERROR_PLAYING:
- result := 'Channel is playing';
BASS_ERROR_NOTAVAIL:
result := 'Not available';
BASS_ERROR_DECODE:
@@ -111,6 +121,8 @@ begin result := 'Version error';
BASS_ERROR_CODEC:
result := 'Codec not available/supported';
+ BASS_ERROR_ENDED:
+ result := 'The channel/file has ended';
BASS_ERROR_UNKNOWN:
result := 'Unknown error';
else
@@ -118,7 +130,7 @@ begin end;
end;
-class function TAudioCore_Bass.ConvertAudioFormatToBASSFlags(Format: TAudioSampleFormat; out Flags: DWORD): boolean;
+function TAudioCore_Bass.ConvertAudioFormatToBASSFlags(Format: TAudioSampleFormat; out Flags: DWORD): boolean;
begin
case Format of
asfS16:
diff --git a/Game/Code/Classes/UAudioCore_Portaudio.pas b/Game/Code/Classes/UAudioCore_Portaudio.pas index cd228982..90395cb8 100644 --- a/Game/Code/Classes/UAudioCore_Portaudio.pas +++ b/Game/Code/Classes/UAudioCore_Portaudio.pas @@ -60,11 +60,12 @@ const array[0..0] of TPaHostApiTypeId = ( paDefaultApi ); {$IFEND} -var - Instance: TAudioCore_Portaudio; { TAudioInput_Portaudio } +var + Instance: TAudioCore_Portaudio; + constructor TAudioCore_Portaudio.Create(); begin inherited; diff --git a/Game/Code/Classes/UAudioInput_Bass.pas b/Game/Code/Classes/UAudioInput_Bass.pas index db49749e..b4d0e52b 100644 --- a/Game/Code/Classes/UAudioInput_Bass.pas +++ b/Game/Code/Classes/UAudioInput_Bass.pas @@ -22,8 +22,11 @@ uses UIni, ULog, UAudioCore_Bass, - Windows, - bass; + UCommon, // (Note: for MakeLong on non-windows platforms) + {$IFDEF MSWINDOWS} + Windows, // (Note: for MakeLong) + {$ENDIF} + bass; // (Note: DWORD is redefined here -> insert after Windows-unit) type TAudioInput_Bass = class(TAudioInputBase) @@ -41,8 +44,6 @@ type BassDeviceID: DWORD; // DeviceID used by BASS SingleIn: boolean; - DeviceIndex: integer; // index in TAudioInputProcessor.Device[] - function SetInputSource(SourceIndex: integer): boolean; function GetInputSource(): integer; public @@ -56,6 +57,7 @@ type end; var + AudioCore: TAudioCore_Bass; singleton_AudioInputBass : IAudioInput; @@ -70,10 +72,9 @@ var * user - players associated with left/right channels *} function MicrophoneCallback(stream: HSTREAM; buffer: Pointer; - len: Cardinal; Card: Cardinal): boolean; stdcall; + len: Cardinal; inputDevice: Pointer): boolean; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} begin - AudioInputProcessor.HandleMicrophoneData(buffer, len, - AudioInputProcessor.DeviceList[Card]); + AudioInputProcessor.HandleMicrophoneData(buffer, len, inputDevice); Result := true; end; @@ -84,6 +85,7 @@ function TBassInputDevice.GetInputSource(): integer; var SourceCnt: integer; i: integer; + flags: DWORD; begin // get input-source config (subtract virtual device to get BASS indices) SourceCnt := Length(Source)-1; @@ -92,8 +94,16 @@ begin Result := -1; for i := 0 to SourceCnt-1 do begin + // get input settings + flags := BASS_RecordGetInput(i, PSingle(nil)^); + if (flags = -1) then + begin + Log.LogError('BASS_RecordGetInput: ' + AudioCore.ErrorGetString(), 'TBassInputDevice.GetInputSource'); + Exit; + end; + // check if current source is selected - if ((BASS_RecordGetInput(i) and BASS_INPUT_OFF) = 0) then + if ((flags and BASS_INPUT_OFF) = 0) then begin // selected source found Result := i; @@ -106,6 +116,7 @@ function TBassInputDevice.SetInputSource(SourceIndex: integer): boolean; var SourceCnt: integer; i: integer; + flags: DWORD; begin Result := false; @@ -117,9 +128,9 @@ begin SourceCnt := Length(Source)-1; // turn on selected source (turns off the others for single-in devices) - if (not BASS_RecordSetInput(SourceIndex, BASS_INPUT_ON)) then + if (not BASS_RecordSetInput(SourceIndex, BASS_INPUT_ON, -1)) then begin - Log.LogError('BASS_RecordSetInput: ' + TAudioCore_Bass.ErrorGetString(), 'TBassInputDevice.Start'); + Log.LogError('BASS_RecordSetInput: ' + AudioCore.ErrorGetString(), 'TBassInputDevice.Start'); Exit; end; @@ -130,9 +141,16 @@ begin begin if (i = SourceIndex) then continue; + // get input settings + flags := BASS_RecordGetInput(i, PSingle(nil)^); + if (flags = -1) then + begin + Log.LogError('BASS_RecordGetInput: ' + AudioCore.ErrorGetString(), 'TBassInputDevice.GetInputSource'); + Exit; + end; // deselect source if selected - if ((BASS_RecordGetInput(i) and BASS_INPUT_OFF) = 0) then - BASS_RecordSetInput(i, BASS_INPUT_OFF); + if ((flags and BASS_INPUT_OFF) = 0) then + BASS_RecordSetInput(i, BASS_INPUT_OFF, -1); end; end; @@ -148,14 +166,14 @@ const begin Result := false; - if not BASS_RecordInit(BassDeviceID) then + if (not BASS_RecordInit(BassDeviceID)) then begin - Log.LogError('BASS_RecordInit[device:'+IntToStr(DeviceIndex)+']: ' + - TAudioCore_Bass.ErrorGetString(), 'TBassInputDevice.Open'); + Log.LogError('BASS_RecordInit['+Name+']: ' + + AudioCore.ErrorGetString(), 'TBassInputDevice.Open'); Exit; end; - if (not TAudioCore_Bass.ConvertAudioFormatToBASSFlags(AudioFormat.Format, FormatFlags)) then + if (not AudioCore.ConvertAudioFormatToBASSFlags(AudioFormat.Format, FormatFlags)) then begin Log.LogError('Unhandled sample-format', 'TBassInputDevice.Open'); Exit; @@ -164,10 +182,10 @@ begin // start capturing in paused state RecordStream := BASS_RecordStart(Round(AudioFormat.SampleRate), AudioFormat.Channels, MakeLong(FormatFlags or BASS_RECORD_PAUSE, latency), - @MicrophoneCallback, DeviceIndex); + @MicrophoneCallback, Self); if (RecordStream = 0) then begin - Log.LogError('BASS_RecordStart: ' + TAudioCore_Bass.ErrorGetString(), 'TBassInputDevice.Open'); + Log.LogError('BASS_RecordStart: ' + AudioCore.ErrorGetString(), 'TBassInputDevice.Open'); BASS_RecordFree; Exit; end; @@ -204,7 +222,7 @@ begin if (not BASS_ChannelPlay(RecordStream, true)) then begin - Log.LogError('BASS_ChannelPlay: ' + TAudioCore_Bass.ErrorGetString(), 'TBassInputDevice.Start'); + Log.LogError('BASS_ChannelPlay: ' + AudioCore.ErrorGetString(), 'TBassInputDevice.Start'); Exit; end; @@ -223,7 +241,7 @@ begin if (not BASS_ChannelStop(RecordStream)) then begin - Log.LogError('BASS_ChannelStop: ' + TAudioCore_Bass.ErrorGetString(), 'TBassInputDevice.Stop'); + Log.LogError('BASS_ChannelStop: ' + AudioCore.ErrorGetString(), 'TBassInputDevice.Stop'); end; // TODO: Do not close the device here (takes too much time). @@ -241,7 +259,7 @@ begin // free data if (not BASS_RecordFree()) then begin - Log.LogError('BASS_RecordFree: ' + TAudioCore_Bass.ErrorGetString(), 'TBassInputDevice.Close'); + Log.LogError('BASS_RecordFree: ' + AudioCore.ErrorGetString(), 'TBassInputDevice.Close'); Result := false; end else @@ -255,20 +273,25 @@ end; function TBassInputDevice.GetVolume(): integer; var SourceIndex: integer; + lVolume: Single; begin + Result := 0; + SourceIndex := Ini.InputDeviceConfig[CfgIndex].Input-1; if (SourceIndex = -1) then begin // if default source used find selected source SourceIndex := GetInputSource(); if (SourceIndex = -1) then - begin - Result := 0; Exit; - end; end; - Result := LOWORD(BASS_RecordGetInput(SourceIndex)); + if (BASS_RecordGetInput(SourceIndex, lVolume) = -1) then + begin + Log.LogError('BASS_RecordGetInput: ' + AudioCore.ErrorGetString() , 'TBassInputDevice.GetVolume'); + Exit; + end; + Result := Round(lVolume * 100); end; procedure TBassInputDevice.SetVolume(Volume: integer); @@ -290,7 +313,10 @@ begin else if (Volume < 0) then Volume := 0; - BASS_RecordSetInput(SourceIndex, BASS_INPUT_LEVEL or Volume); + if (not BASS_RecordSetInput(SourceIndex, 0, Volume/100)) then + begin + Log.LogError('BASS_RecordSetInput: ' + AudioCore.ErrorGetString() , 'TBassInputDevice.SetVolume'); + end; end; @@ -309,6 +335,7 @@ var BassDeviceID: integer; BassDevice: TBassInputDevice; DeviceIndex: integer; + DeviceInfo: BASS_DEVICEINFO; SourceIndex: integer; RecordInfo: BASS_RECORDINFO; SelectedSourceIndex: integer; @@ -322,8 +349,7 @@ begin // checks for recording devices and puts them into an array while true do begin - Descr := BASS_RecordGetDeviceDescription(BassDeviceID); - if (Descr = nil) then + if (not BASS_RecordGetDeviceInfo(BassDeviceID, DeviceInfo)) then break; // try to initialize the device @@ -340,10 +366,13 @@ begin BassDevice := TBassInputDevice.Create(); AudioInputProcessor.DeviceList[DeviceIndex] := BassDevice; - BassDevice.DeviceIndex := DeviceIndex; + Descr := DeviceInfo.name; + BassDevice.BassDeviceID := BassDeviceID; BassDevice.Name := UnifyDeviceName(Descr, DeviceIndex); + // zero info-struct as some fields might not be set (e.g. freq is just set on Vista and MacOSX) + FillChar(RecordInfo, SizeOf(RecordInfo), 0); // retrieve recording device info BASS_RecordGetInfo(RecordInfo); @@ -410,7 +439,7 @@ begin BassDevice.Source[SourceIndex].Name := SourceName; // get input-source info - Flags := BASS_RecordGetInput(SourceIndex); + Flags := BASS_RecordGetInput(SourceIndex, PSingle(nil)^); if (Flags <> -1) then begin // is the current source a mic-source? @@ -436,6 +465,7 @@ end; function TAudioInput_Bass.InitializeRecord(): boolean; begin + AudioCore := TAudioCore_Bass.GetInstance(); Result := EnumDevices(); end; diff --git a/Game/Code/Classes/UAudioPlayback_Bass.pas b/Game/Code/Classes/UAudioPlayback_Bass.pas index 0fca9c72..2667bf6f 100644 --- a/Game/Code/Classes/UAudioPlayback_Bass.pas +++ b/Game/Code/Classes/UAudioPlayback_Bass.pas @@ -92,6 +92,7 @@ type end; var + AudioCore: TAudioCore_Bass; singleton_AudioPlaybackBass : IAudioPlayback; @@ -137,7 +138,7 @@ begin BASS_ChannelPlay(Handle, true); // start fade-in: slide from fadeStart- to fadeEnd-volume in FadeInTime - BASS_ChannelSlideAttributes(Handle, -1, TargetVolume, -101, Trunc(Time * 1000)); + BASS_ChannelSlideAttribute(Handle, BASS_ATTRIB_VOL, TargetVolume/100, Trunc(Time * 1000)); end; procedure TBassPlaybackStream.Pause(); @@ -157,10 +158,16 @@ end; function TBassPlaybackStream.GetVolume(): integer; var - volume: cardinal; + lVolume: single; begin - BASS_ChannelGetAttributes(Handle, PCardinal(nil)^, volume, PInteger(nil)^); - Result := volume; + if (not BASS_ChannelGetAttribute(Handle, BASS_ATTRIB_VOL, lVolume)) then + begin + Log.LogError('BASS_ChannelGetAttribute: ' + AudioCore.ErrorGetString(), + 'TBassPlaybackStream.GetVolume'); + Result := 0; + Exit; + end; + Result := Round(lVolume * 100); end; procedure TBassPlaybackStream.SetVolume(volume: integer); @@ -171,30 +178,30 @@ begin if volume > 100 then volume := 100; // set volume - BASS_ChannelSetAttributes(Handle, -1, volume, -101); + BASS_ChannelSetAttribute(Handle, BASS_ATTRIB_VOL, volume/100); end; function TBassPlaybackStream.GetPosition: real; var - bytes: integer; + bytes: QWORD; begin - bytes := BASS_ChannelGetPosition(Handle); + bytes := BASS_ChannelGetPosition(Handle, BASS_POS_BYTE); Result := BASS_ChannelBytes2Seconds(Handle, bytes); end; procedure TBassPlaybackStream.SetPosition(Time: real); var - bytes: integer; + bytes: QWORD; begin bytes := BASS_ChannelSeconds2Bytes(Handle, Time); - BASS_ChannelSetPosition(Handle, bytes); + BASS_ChannelSetPosition(Handle, bytes, BASS_POS_BYTE); end; function TBassPlaybackStream.GetLength(): real; var - bytes: integer; + bytes: QWORD; begin - bytes := BASS_ChannelGetLength(Handle); + bytes := BASS_ChannelGetLength(Handle, BASS_POS_BYTE); Result := BASS_ChannelBytes2Seconds(Handle, bytes); end; @@ -219,43 +226,38 @@ end; function TBassPlaybackStream.GetLoop(): boolean; var - info: BASS_CHANNELINFO; + flags: DWORD; begin - if not BASS_ChannelGetInfo(Handle, info) then + // retrieve channel flags + flags := BASS_ChannelFlags(Handle, 0, 0); + if (flags = -1) then begin - Log.LogError('BASS_ChannelGetInfo: ' + TAudioCore_Bass.ErrorGetString(), 'TBassPlaybackStream.GetLoop'); + Log.LogError('BASS_ChannelFlags: ' + AudioCore.ErrorGetString(), 'TBassPlaybackStream.GetLoop'); Result := false; Exit; end; - Result := (info.flags and BASS_SAMPLE_LOOP) <> 0; + Result := (flags and BASS_SAMPLE_LOOP) <> 0; end; procedure TBassPlaybackStream.SetLoop(Enabled: boolean); var - info: BASS_CHANNELINFO; + flags: DWORD; begin - // retrieve old flag-bits - if not BASS_ChannelGetInfo(Handle, info) then - begin - Log.LogError('BASS_ChannelGetInfo:' + TAudioCore_Bass.ErrorGetString(), 'TBassPlaybackStream.SetLoop'); - Exit; - end; - // set/unset loop-flag if (Enabled) then - info.flags := info.flags or BASS_SAMPLE_LOOP + flags := BASS_SAMPLE_LOOP else - info.flags := info.flags and not BASS_SAMPLE_LOOP; + flags := 0; // set new flag-bits - if not BASS_ChannelSetFlags(Handle, info.flags) then + if (BASS_ChannelFlags(Handle, flags, BASS_SAMPLE_LOOP) = -1) then begin - Log.LogError('BASS_ChannelSetFlags: ' + TAudioCore_Bass.ErrorGetString(), 'TBassPlaybackStream.SetLoop'); + Log.LogError('BASS_ChannelFlags: ' + AudioCore.ErrorGetString(), 'TBassPlaybackStream.SetLoop'); Exit; end; end; -procedure DSPProcHandler(handle: HDSP; channel: DWORD; buffer: Pointer; length: DWORD; user: DWORD); stdcall; +procedure DSPProcHandler(handle: HDSP; channel: DWORD; buffer: Pointer; length: DWORD; user: Pointer); {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} var effect: TSoundEffect; begin @@ -274,11 +276,10 @@ begin Exit; end; - // FIXME: casting of a pointer to Uint32 will fail on 64bit systems - dspHandle := BASS_ChannelSetDSP(Handle, @DSPProcHandler, DWORD(effect), 0); + dspHandle := BASS_ChannelSetDSP(Handle, @DSPProcHandler, effect, 0); if (dspHandle = 0) then begin - Log.LogError(TAudioCore_Bass.ErrorGetString(), 'TBassPlaybackStream.AddSoundEffect'); + Log.LogError(AudioCore.ErrorGetString(), 'TBassPlaybackStream.AddSoundEffect'); Exit; end; @@ -296,7 +297,7 @@ begin if not BASS_ChannelRemoveDSP(Handle, PHDSP(effect.EngineData)^) then begin - Log.LogError(TAudioCore_Bass.ErrorGetString(), 'TBassPlaybackStream.RemoveSoundEffect'); + Log.LogError(AudioCore.ErrorGetString(), 'TBassPlaybackStream.RemoveSoundEffect'); Exit; end; @@ -321,11 +322,10 @@ var begin Result := 0; - // Get Channel Data Mono and 256 Values - BASS_ChannelGetInfo(Handle, info); FillChar(data, sizeof(TPCMData), 0); // no support for non-stereo files at the moment + BASS_ChannelGetInfo(Handle, info); if (info.chans <> 2) then Exit; @@ -406,7 +406,7 @@ var BassDeviceID: DWORD; DeviceIndex: integer; Device: TBassOutputDevice; - Description: PChar; + DeviceInfo: BASS_DEVICEINFO; begin ClearOutputDeviceList(); @@ -416,13 +416,12 @@ begin while true do begin // Check for device - Description := BASS_GetDeviceDescription(BassDeviceID); - if (Description = nil) then + if (not BASS_GetDeviceInfo(BassDeviceID, DeviceInfo)) then break; // Set device info Device := TBassOutputDevice.Create(); - Device.Name := Description; + Device.Name := DeviceInfo.name; Device.BassDeviceID := BassDeviceID; // Add device to list @@ -440,14 +439,16 @@ var begin result := false; + AudioCore := TAudioCore_Bass.GetInstance(); + EnumDevices(); //Log.BenchmarkStart(4); //Log.LogStatus('Initializing Playback Subsystem', 'Music Initialize'); - if not BASS_Init(1, 44100, 0, 0, nil) then + if not BASS_Init(-1, 44100, 0, 0, nil) then begin - Log.LogError('Could not initialize BASS', 'Error'); + Log.LogError('Could not initialize BASS', 'TAudioPlayback_Bass.InitializePlayback'); Exit; end; @@ -460,7 +461,15 @@ begin result := true; end; -function DecodeStreamHandler(handle: HSTREAM; buffer: Pointer; length: DWORD; user: DWORD): DWORD; stdcall; +function TAudioPlayback_Bass.FinalizePlayback(): boolean; +begin + Close; + BASS_Free; + inherited FinalizePlayback(); + Result := true; +end; + +function DecodeStreamHandler(handle: HSTREAM; buffer: Pointer; length: DWORD; user: Pointer): DWORD; {$IFDEF MSWINDOWS}stdcall;{$ELSE}cdecl;{$ENDIF} var decodeStream: TAudioDecodeStream; bytes: integer; @@ -477,17 +486,8 @@ begin Result := bytes; end; -function TAudioPlayback_Bass.FinalizePlayback(): boolean; -begin - Close; - BASS_Free; - inherited FinalizePlayback(); - Result := true; -end; - function TAudioPlayback_Bass.OpenStream(const Filename: string): TAudioPlaybackStream; var - L: Integer; stream: HSTREAM; playbackStream: TBassExtDecoderPlaybackStream; decodeStream: TAudioDecodeStream; @@ -499,6 +499,8 @@ begin Result := nil; //Log.LogStatus('Loading Sound: "' + Filename + '"', 'LoadSoundFromFile'); + // TODO: use BASS_STREAM_PRESCAN for accurate seeking in VBR-files? + // disadvantage: seeking will slow down. stream := BASS_StreamCreateFile(False, PChar(Filename), 0, 0, 0); // check if BASS opened some erroneously recognized file-formats @@ -507,7 +509,8 @@ begin if BASS_ChannelGetInfo(stream, channelInfo) then begin fileExt := ExtractFileExt(Filename); - // BASS opens FLV-files although it cannot handle them + // BASS opens FLV-files (maybe others too) although it cannot handle them. + // Setting BASS_CONFIG_VERIFY to the max. value (100000) does not help. if ((fileExt = '.flv') and (channelInfo.ctype = BASS_CTYPE_STREAM_MP1)) then begin BASS_StreamFree(stream); @@ -526,7 +529,7 @@ begin if (AudioDecoder = nil) then begin Log.LogError('Failed to open "' + Filename + '", ' + - TAudioCore_Bass.ErrorGetString(BASS_ErrorGetCode()), 'TAudioPlayback_Bass.Load'); + AudioCore.ErrorGetString(), 'TAudioPlayback_Bass.Load'); Exit; end; @@ -538,20 +541,19 @@ begin end; formatInfo := decodeStream.GetAudioFormatInfo(); - if (not TAudioCore_Bass.ConvertAudioFormatToBASSFlags(formatInfo.Format, formatFlags)) then + if (not AudioCore.ConvertAudioFormatToBASSFlags(formatInfo.Format, formatFlags)) then begin Log.LogError('Unhandled sample-format in "' + Filename + '"', 'TAudioPlayback_Bass.Load'); FreeAndNil(decodeStream); Exit; end; - // FIXME: casting of a pointer to Uint32 will fail on 64bit systems stream := BASS_StreamCreate(Round(formatInfo.SampleRate), formatInfo.Channels, formatFlags, - @DecodeStreamHandler, DWORD(decodeStream)); + @DecodeStreamHandler, decodeStream); if (stream = 0) then begin Log.LogError('Failed to open "' + Filename + '", ' + - TAudioCore_Bass.ErrorGetString(BASS_ErrorGetCode()), 'TAudioPlayback_Bass.Load'); + AudioCore.ErrorGetString(BASS_ErrorGetCode()), 'TAudioPlayback_Bass.Load'); FreeAndNil(decodeStream); Exit; end; @@ -576,8 +578,8 @@ end; procedure TAudioPlayback_Bass.SetAppVolume(Volume: integer); begin - // Sets Volume only for this Application - BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume); + // Sets Volume only for this Application (now ranges from 0..10000) + BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, Volume*100); end; diff --git a/Game/Code/Classes/UCommon.pas b/Game/Code/Classes/UCommon.pas index 026c2850..94f43d06 100644 --- a/Game/Code/Classes/UCommon.pas +++ b/Game/Code/Classes/UCommon.pas @@ -53,8 +53,16 @@ procedure DisableFloatingPointExceptions(); procedure SetDefaultNumericLocale();
procedure RestoreNumericLocale();
-{$IFNDEF win32}
+{$IFNDEF MSWINDOWS}
procedure ZeroMemory( Destination: Pointer; Length: DWORD );
+ function MakeLong(a, b: Word): Longint;
+ (*
+ #define LOBYTE(a) (BYTE)(a)
+ #define HIBYTE(a) (BYTE)((a)>>8)
+ #define LOWORD(a) (WORD)(a)
+ #define HIWORD(a) (WORD)((a)>>16)
+ #define MAKEWORD(a,b) (WORD)(((a)&0xff)|((b)<<8))
+ *)
{$ENDIF}
function FileExistsInsensitive(var FileName: string): boolean;
@@ -233,7 +241,12 @@ end; procedure ZeroMemory( Destination: Pointer; Length: DWORD );
begin
FillChar( Destination^, Length, 0 );
-end; //ZeroMemory
+end;
+
+function MakeLong(A, B: Word): Longint;
+begin + Result := (LongInt(B) shl 16) + A; +end; (*
function QueryPerformanceCounter(lpPerformanceCount:TLARGEINTEGER):Bool;
@@ -755,7 +768,7 @@ end; * be ordered by title. In contrast to this an unstable algorithm (like QuickSort)
* may destroy an existing order, so the songs of an artist will not be ordered
* by title anymore after sorting by artist in the previous example.
- * If you do not need a stable algorithm, use TList.Sort() instead.
+ * If you do not need a stable algorithm, use TList.Sort() instead.
*)
procedure MergeSort(List: TList; CompareFunc: TListSortCompare);
var
|