From 5142d64ca5edc5499098513912959834b971e75b Mon Sep 17 00:00:00 2001 From: tobigun Date: Wed, 20 Feb 2008 18:30:46 +0000 Subject: - 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 --- Game/Code/Classes/UAudioInput_Bass.pas | 85 ++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 35 deletions(-) (limited to 'Game/Code/Classes/UAudioInput_Bass.pas') 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; -- cgit v1.2.3