diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-05-08 22:46:29 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-05-08 22:46:29 +0000 |
commit | 69cd34b1a50914fad7e5befaa848a6a2c537b4ac (patch) | |
tree | 2af1f9f588faa82c445026c212250f9cf38d26a2 /src/base/URecord.pas | |
parent | 4ae6069e48c8b30610cec32c7508e2a7400d4d35 (diff) | |
download | usdx-69cd34b1a50914fad7e5befaa848a6a2c537b4ac.tar.gz usdx-69cd34b1a50914fad7e5befaa848a6a2c537b4ac.tar.xz usdx-69cd34b1a50914fad7e5befaa848a6a2c537b4ac.zip |
validate microphone settings when leaving the record options and when USDX is started:
- check if a user is assigned to multiple devices. If this is the case either do not leave the record options (if we already are there) or enter the record options (if USDX was started)
- the check is performed by calling TAudioInputProcessor.ValidateSettings()
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2346 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/base/URecord.pas')
-rw-r--r-- | src/base/URecord.pas | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/base/URecord.pas b/src/base/URecord.pas index 245d85a6..c183875c 100644 --- a/src/base/URecord.pas +++ b/src/base/URecord.pas @@ -133,6 +133,7 @@ type destructor Destroy; override; procedure UpdateInputDeviceConfig; + function ValidateSettings: boolean; // handle microphone input procedure HandleMicrophoneData(Buffer: PByteArray; Size: integer; @@ -162,6 +163,8 @@ implementation uses ULog, + UGraphic, + ULanguage, UNote; var @@ -594,6 +597,50 @@ begin end; end; +function TAudioInputProcessor.ValidateSettings: boolean; +const + MAX_PLAYER_COUNT = 6; // FIXME: there should be a global variable for this +var + I, J: integer; + PlayerID: integer; + PlayerMap: array [0 .. MAX_PLAYER_COUNT] of boolean; + InputDevice: TAudioInputDevice; + InputDeviceCfg: PInputDeviceConfig; +begin + // mark all players as unassigned + for I := 0 to High(PlayerMap) do + PlayerMap[I] := false; + + // iterate over all active devices + for I := 0 to High(DeviceList) do + begin + InputDevice := DeviceList[I]; + InputDeviceCfg := @Ini.InputDeviceConfig[InputDevice.CfgIndex]; + // iterate over all channels of the current devices + for J := 0 to High(InputDeviceCfg.ChannelToPlayerMap) do + begin + // get player that was mapped to the current device channel + PlayerID := InputDeviceCfg.ChannelToPlayerMap[J]; + if (PlayerID <> 0) then + begin + // check if player is already assigned to another device/channel + if (PlayerMap[PlayerID]) then + begin + ScreenPopupError.ShowPopup( + Format(Language.Translate('ERROR_PLAYER_DEVICE_ASSIGNMENT'), + [PlayerID])); + Result := false; + Exit; + end; + + // mark player as assigned to a device + PlayerMap[PlayerID] := true; + end; + end; + end; + Result := true; +end; + {* * Handles captured microphone input data. * Params: |