diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-02-20 18:30:46 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-02-20 18:30:46 +0000 |
commit | 5142d64ca5edc5499098513912959834b971e75b (patch) | |
tree | 7c8a6944b693dab8c99fec215e696fc16551f178 /Game/Code/Classes/UAudioInput_Bass.pas | |
parent | 0e0f6fcc1b26fdb551789b1a2d4d2dc62242ac4d (diff) | |
download | usdx-5142d64ca5edc5499098513912959834b971e75b.tar.gz usdx-5142d64ca5edc5499098513912959834b971e75b.tar.xz usdx-5142d64ca5edc5499098513912959834b971e75b.zip |
- Resampling support added
- DecodeStreams are closed now if they are not used anymore
- Fixed the crash that occured when USDX was closed
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@875 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | Game/Code/Classes/UAudioInput_Bass.pas | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/Game/Code/Classes/UAudioInput_Bass.pas b/Game/Code/Classes/UAudioInput_Bass.pas index 6d661258..f99b0885 100644 --- a/Game/Code/Classes/UAudioInput_Bass.pas +++ b/Game/Code/Classes/UAudioInput_Bass.pas @@ -144,43 +144,58 @@ begin if (Descr = nil) then
break;
- SetLength(AudioInputProcessor.Device, DeviceIndex+1);
-
- // TODO: free object on termination
- BassDevice := TBassInputDevice.Create();
- AudioInputProcessor.Device[DeviceIndex] := BassDevice;
-
- BassDevice.DeviceIndex := DeviceIndex;
- BassDevice.BassDeviceID := BassDeviceID;
- BassDevice.Description := UnifyDeviceName(Descr, DeviceIndex);
-
- // get input sources
- SourceIndex := 0;
- BASS_RecordInit(BassDeviceID);
- BassDevice.MicInput := 0;
-
- // process each input
- while true do
+ // try to intialize the device
+ if not BASS_RecordInit(BassDeviceID) then
begin
- SourceName := BASS_RecordGetInputName(SourceIndex);
- if (SourceName = nil) then
- break;
-
- SetLength(BassDevice.Source, SourceIndex+1);
- BassDevice.Source[SourceIndex].Name :=
- UnifyDeviceSourceName(SourceName, BassDevice.Description);
-
- // set mic index
- Flags := BASS_RecordGetInput(SourceIndex);
- if ((Flags and BASS_INPUT_TYPE_MIC) <> 0) then
- BassDevice.MicInput := SourceIndex;
-
- Inc(SourceIndex);
+ Log.LogStatus('Failed to initialize BASS Capture-Device['+inttostr(BassDeviceID)+']',
+ 'TAudioInput_Bass.InitializeRecord');
+ end
+ else
+ begin
+ SetLength(AudioInputProcessor.Device, DeviceIndex+1);
+
+ // TODO: free object on termination
+ BassDevice := TBassInputDevice.Create();
+ AudioInputProcessor.Device[DeviceIndex] := BassDevice;
+
+ BassDevice.DeviceIndex := DeviceIndex;
+ BassDevice.BassDeviceID := BassDeviceID;
+ BassDevice.Description := UnifyDeviceName(Descr, DeviceIndex);
+
+ // get input sources
+ SourceIndex := 0;
+ BassDevice.MicInput := 0;
+
+ // process each input
+ while true do
+ begin
+ SourceName := BASS_RecordGetInputName(SourceIndex);
+ if (SourceName = nil) then
+ break;
+
+ SetLength(BassDevice.Source, SourceIndex+1);
+ BassDevice.Source[SourceIndex].Name :=
+ UnifyDeviceSourceName(SourceName, BassDevice.Description);
+
+ // set mic index
+ Flags := BASS_RecordGetInput(SourceIndex);
+ if ((Flags <> -1) and ((Flags and BASS_INPUT_TYPE_MIC) <> 0)) then
+ begin
+ BassDevice.MicInput := SourceIndex;
+ end;
+
+ Inc(SourceIndex);
+ end;
+
+ //Writeln('BASS_RecordFree');
+ // FIXME: this call hangs in FPC (windows) every 2nd time USDX is called.
+ // Maybe because the sound-device was not released properly?
+ BASS_RecordFree;
+ //Writeln('BASS_RecordFree - Done');
+
+ Inc(DeviceIndex);
end;
-
- BASS_RecordFree;
-
- Inc(DeviceIndex);
+
Inc(BassDeviceID);
end;
|