feat: duck other apps switch in audio section

This commit is contained in:
TrueZhuanjia
2025-11-03 11:25:57 +08:00
parent ff40e55cd1
commit a3f9e07cf7
13 changed files with 130 additions and 7 deletions
+25 -3
View File
@@ -1360,16 +1360,16 @@
</constraints>
</stackView>
<stackView verifyAmbiguity="off" opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="Oyk-L5-WTt" userLabel="singleTapSensitivityStack">
<rect key="frame" x="440" y="307" width="668" height="55.5"/>
<rect key="frame" x="440" y="307" width="692" height="55.5"/>
<subviews>
<label verifyAmbiguity="off" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Single Tap Sensitivity" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SuN-S2-8hj">
<rect key="frame" x="0.0" y="0.0" width="668" height="20.5"/>
<rect key="frame" x="0.0" y="0.0" width="692" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<slider verifyAmbiguity="off" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="2" minValue="0.0" maxValue="5" minimumValueImage="0.square" catalog="system" maximumValueImage="5.square" translatesAutoresizingMaskIntoConstraints="NO" id="j4n-De-TRX" userLabel="Single Tap Sensitivity Slider">
<rect key="frame" x="-2" y="25.5" width="672" height="31"/>
<rect key="frame" x="-2" y="25.5" width="696" height="31"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="qOF-42-hPO"/>
</constraints>
@@ -1494,6 +1494,26 @@
<constraint firstAttribute="height" constant="31" id="m8h-w7-JRF"/>
</constraints>
</stackView>
<stackView verifyAmbiguity="off" opaque="NO" contentMode="scaleToFill" ambiguous="YES" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="gBG-8F-6F8">
<rect key="frame" x="432" y="2349" width="281" height="31"/>
<subviews>
<label verifyAmbiguity="off" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Duck Other Apps" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.64999997615814209" adjustsLetterSpacingToFitWidth="YES" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YPA-7E-Cdl" userLabel="uiLabel">
<rect key="frame" x="0.0" y="0.0" width="131" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YEv-1B-97I">
<rect key="frame" x="151" y="0.0" width="132" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="130" id="LXO-Pc-PnJ"/>
</constraints>
</switch>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="31" id="6TQ-fK-dDd"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
@@ -1521,6 +1541,8 @@
<outlet property="codecSelector" destination="aFy-0w-YPe" id="DlU-0l-gwz"/>
<outlet property="codecStack" destination="gWg-BF-yDI" id="GGc-JQ-N8y"/>
<outlet property="customResolutionSwitch" destination="E5w-kK-dOo" id="hrt-v2-8dY"/>
<outlet property="duckOtherAppStack" destination="gBG-8F-6F8" id="T9P-ys-pHB"/>
<outlet property="duckOtherAppSwitch" destination="YEv-1B-97I" id="o3Q-yt-74a"/>
<outlet property="edgeSlidingSensitivitySlider" destination="41s-BD-8rZ" id="ytk-Y5-Alq"/>
<outlet property="edgeSlidingSensitivityStack" destination="CVS-fB-e0q" id="tGR-K2-Jwq"/>
<outlet property="emulatedControllerTypeSelector" destination="JaY-XA-1V6" id="aU2-ps-esq"/>
+25 -3
View File
@@ -2214,16 +2214,16 @@
</constraints>
</stackView>
<stackView verifyAmbiguity="off" opaque="NO" contentMode="scaleToFill" ambiguous="YES" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="N0i-z6-WgC" userLabel="singleTapSensitivityStack">
<rect key="frame" x="437" y="2383" width="412" height="55.5"/>
<rect key="frame" x="437" y="2383" width="424" height="55.5"/>
<subviews>
<label verifyAmbiguity="off" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Single Tap Sensitivity" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WzD-wo-Wum">
<rect key="frame" x="0.0" y="0.0" width="412" height="20.5"/>
<rect key="frame" x="0.0" y="0.0" width="424" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<slider verifyAmbiguity="off" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="2" minValue="0.0" maxValue="5" minimumValueImage="0.square" catalog="system" maximumValueImage="5.square" translatesAutoresizingMaskIntoConstraints="NO" id="uCa-Oa-7mv" userLabel="Single Tap Sensitivity Slider">
<rect key="frame" x="-2" y="25.5" width="416" height="31"/>
<rect key="frame" x="-2" y="25.5" width="428" height="31"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="XXP-GP-uhn"/>
</constraints>
@@ -2277,6 +2277,26 @@
<constraint firstAttribute="height" constant="31" id="Ak8-3f-rpG"/>
</constraints>
</stackView>
<stackView verifyAmbiguity="off" opaque="NO" contentMode="scaleToFill" ambiguous="YES" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="FkE-Sc-6kA">
<rect key="frame" x="437" y="965" width="281" height="31"/>
<subviews>
<label verifyAmbiguity="off" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Duck Other Apps" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.64999997615814209" adjustsLetterSpacingToFitWidth="YES" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="CEd-Wx-Gml" userLabel="uiLabel">
<rect key="frame" x="0.0" y="0.0" width="131" height="31"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="71J-Gt-A3D">
<rect key="frame" x="151" y="0.0" width="132" height="31"/>
<constraints>
<constraint firstAttribute="width" constant="130" id="vb6-Ir-uLe"/>
</constraints>
</switch>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="31" id="ODv-4K-0el"/>
</constraints>
</stackView>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
@@ -2304,6 +2324,8 @@
<outlet property="codecSelector" destination="5Y7-To-ca2" id="Kmt-sp-eXj"/>
<outlet property="codecStack" destination="cVe-Uk-gXv" id="826-Tv-rMl"/>
<outlet property="customResolutionSwitch" destination="kRO-HO-zKO" id="ZUP-Yd-QDY"/>
<outlet property="duckOtherAppStack" destination="FkE-Sc-6kA" id="YUO-j1-Bdv"/>
<outlet property="duckOtherAppSwitch" destination="71J-Gt-A3D" id="3iT-jh-hWx"/>
<outlet property="edgeSlidingSensitivitySlider" destination="KRf-2B-Reb" id="UaG-GM-wkO"/>
<outlet property="edgeSlidingSensitivityStack" destination="Nfo-3b-3IK" id="AO3-5B-yyQ"/>
<outlet property="emulatedControllerTypeSelector" destination="q6v-Jb-ysy" id="o1B-2n-vOR"/>
+1
View File
@@ -127,6 +127,7 @@ typedef NS_ENUM(NSInteger, WidgetSizeTransition) {
edgeSlidingSensitivity:(CGFloat)edgeSlidingSensitivity
audioEngine:(NSInteger)audioEngine
appendLeftClick:(BOOL)appendLeftClick
duckOtherApps:(BOOL)duckOtherApps
backgroundSessionTimer:(NSInteger)backgroundSessionTimer;
- (NSArray*) getHosts;
+2
View File
@@ -110,6 +110,7 @@
edgeSlidingSensitivity:(CGFloat)edgeSlidingSensitivity
audioEngine:(NSInteger)audioEngine
appendLeftClick:(BOOL)appendLeftClick
duckOtherApps:(BOOL)duckOtherApps
backgroundSessionTimer:(NSInteger)backgroundSessionTimer{
[_managedObjectContext performBlockAndWait:^{
@@ -170,6 +171,7 @@
settingsToSave.edgeSlidingSensitivity = [NSNumber numberWithFloat:edgeSlidingSensitivity];
settingsToSave.audioEngine = [NSNumber numberWithInteger:audioEngine];
settingsToSave.appendLeftClick = appendLeftClick;
settingsToSave.duckOtherApps = duckOtherApps;
settingsToSave.rememberFoldState = rememberFoldState;
[self saveData];
}];
+1
View File
@@ -84,6 +84,7 @@
@property (nonatomic, retain) NSNumber * edgeSlidingSensitivity;
@property (nonatomic, retain) NSNumber * audioEngine;
@property (nonatomic) BOOL appendLeftClick;
@property (nonatomic) BOOL duckOtherApps;
@property (nonatomic, retain) NSNumber * framePacingMode;
- (id) initFromSettings:(Settings*)settings;
+1
View File
@@ -141,6 +141,7 @@
self.uniqueId = settings.uniqueId;
self.audioEngine = settings.audioEngine;
self.appendLeftClick = settings.appendLeftClick;
self.duckOtherApps = settings.duckOtherApps;
#endif
return self;
@@ -31,6 +31,7 @@
<attribute name="btMouseSupport" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="buttonVisualFeedback" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="deviceGyroMode" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="duckOtherApps" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
<attribute name="edgeSlidingSensitivity" optional="YES" attributeType="Float" defaultValueString="22" usesScalarValueType="NO" syncable="YES"/>
<attribute name="emulatedControllerType" optional="YES" attributeType="Integer 16" defaultValueString="2" usesScalarValueType="NO" syncable="YES"/>
<attribute name="enableGraphs" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
+5 -1
View File
@@ -284,16 +284,20 @@ int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, v
// Start playback
SDL_PauseAudioDevice(audioDevice, 0);
// [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
// return 0;
// System audio engine initialization
DataManager* dataMan = [[DataManager alloc] init];
TemporarySettings* tempSettings = [dataMan getSettings];
bool useBluetoothD2P = tempSettings.useBuiltinMic || !tempSettings.redirectMic;
AVAudioSessionCategoryOptions bluetoothAudioOption = useBluetoothD2P ? AVAudioSessionCategoryOptionAllowBluetoothA2DP : AVAudioSessionCategoryOptionAllowBluetooth;
AVAudioSessionCategoryOptions volumeMixOption = tempSettings.duckOtherApps ? AVAudioSessionCategoryOptionDuckOthers : AVAudioSessionCategoryOptionMixWithOthers;
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:tempSettings.redirectMic ? AVAudioSessionCategoryPlayAndRecord : AVAudioSessionCategoryPlayback
mode:AVAudioSessionModeDefault
options:AVAudioSessionCategoryOptionMixWithOthers|AVAudioSessionCategoryOptionDefaultToSpeaker|bluetoothAudioOption
options:volumeMixOption|bluetoothAudioOption
error:nil];
if(tempSettings.redirectMic) if(@available(iOS 13.0, *)) [session setAllowHapticsAndSystemSoundsDuringRecording:YES error:nil];
[session setActive:YES error:nil];
@@ -1192,6 +1192,7 @@ static NSMutableSet* hostList;
[settingsViewController setHidden:_settingsExpandedInStreamView forStack:settingsViewController.citrixX1MouseStack];
[settingsViewController setHidden:_settingsExpandedInStreamView forStack:settingsViewController.externalDisplayModeStack];
[settingsViewController setHidden:_settingsExpandedInStreamView forStack:settingsViewController.audioConfigStack];
[settingsViewController setHidden:_settingsExpandedInStreamView forStack:settingsViewController.duckOtherAppStack];
[settingsViewController setHidden:_settingsExpandedInStreamView forStack:settingsViewController.pipStack];
[settingsViewController setHidden:_settingsExpandedInStreamView forStack:settingsViewController.appThemeStack];
[settingsViewController.renderingBackendSelector setEnabled:!_settingsExpandedInStreamView];
@@ -184,6 +184,9 @@
@property (strong, nonatomic) IBOutlet UIStackView *appendLeftClickStack;
@property (strong, nonatomic) IBOutlet UISwitch *appendLeftClickSwitch;
@property (strong, nonatomic) IBOutlet UIStackView *duckOtherAppStack;
@property (strong, nonatomic) IBOutlet UISwitch *duckOtherAppSwitch;
@property (strong, nonatomic) IBOutlet UIStackView *testStack;
@property (nonatomic, strong) MicHandler *micHandler;
@@ -791,6 +791,7 @@ BOOL isCustomResolution(int resolutionSelected) {
[self addSetting:self.redirectMicStack ofId:@"redirectMicStack" withInfoTag:YES withDynamicLabel:NO to:audioSection];
[self addSetting:self.useBuiltinMicStack ofId:@"useBuiltinMicStack" withInfoTag:YES withDynamicLabel:NO to:audioSection];
[self addSetting:self.micVolumeStack ofId:@"micVolumeStack" withInfoTag:NO withDynamicLabel:YES to:audioSection];
[self addSetting:self.duckOtherAppStack ofId:@"duckOtherAppStack" withInfoTag:NO withDynamicLabel:NO to:audioSection];
// [self addSetting:self.audioEngineStack ofId:@"audioEngineStack" withInfoTag:YES withDynamicLabel:NO to:audioSection];
// cancel audio engine selector due to system engine is unable to playback multi-channel audio
[self addSetting:self.audioConfigStack ofId:@"audioConfigStack" withInfoTag:NO withDynamicLabel:NO to:audioSection];
@@ -1715,6 +1716,8 @@ BOOL isCustomResolution(int resolutionSelected) {
[self.localVolumeSlider addTarget:self action:@selector(localVolumeSliderMoved:) forControlEvents:UIControlEventValueChanged];
[self localVolumeSliderMoved:self.localVolumeSlider];
[self.duckOtherAppSwitch setOn:self->tempSettings.duckOtherApps];
[self.micVolumeSlider setValue:self->tempSettings.micVolume.floatValue*100];
[self.micVolumeSlider addTarget:self action:@selector(micVolumeSliderMoved:) forControlEvents:UIControlEventValueChanged];
[self micVolumeSliderMoved:self.self.micVolumeSlider];
@@ -2871,6 +2874,7 @@ BOOL isCustomResolution(int resolutionSelected) {
CGFloat edgeSlidingSensitivity = self.edgeSlidingSensitivitySlider.value;
NSInteger audioEngine = self.audioEngineSelector.selectedSegmentIndex;
BOOL appendLeftClick = self.appendLeftClickSwitch.isOn;
BOOL duckOtherApps = self.duckOtherAppSwitch.isOn;
NSInteger backgroundSessionTimer = self.backgroundSessionTimerSlider.value == self.backgroundSessionTimerSlider.maximumValue ? (uint32_t) INT16_MAX : (uint32_t)self.backgroundSessionTimerSlider.value;
[dataMan saveSettingsWithBitrate:_bitrate
@@ -2927,6 +2931,7 @@ BOOL isCustomResolution(int resolutionSelected) {
edgeSlidingSensitivity:edgeSlidingSensitivity
audioEngine:audioEngine
appendLeftClick:appendLeftClick
duckOtherApps:duckOtherApps
backgroundSessionTimer:backgroundSessionTimer];
}
+30
View File
@@ -4663,6 +4663,36 @@
}
}
},
"YPA-7E-Cdl.text" : {
"comment" : "Class = \"UILabel\"; text = \"Duck Other Apps\"; ObjectID = \"YPA-7E-Cdl\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Duck Other Apps"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "降低其他App音量"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "降低其他App音量"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "降低其他App音量"
}
}
}
},
"yY7-Sf-Zes.segmentTitles[0]" : {
"comment" : "Class = \"UISegmentedControl\"; yY7-Sf-Zes.segmentTitles[0] = \"Slide From Left Edge\"; ObjectID = \"yY7-Sf-Zes\";",
"extractionState" : "extracted_with_value",
+30
View File
@@ -1447,6 +1447,36 @@
}
}
},
"CEd-Wx-Gml.text" : {
"comment" : "Class = \"UILabel\"; text = \"Duck Other Apps\"; ObjectID = \"CEd-Wx-Gml\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Duck Other Apps"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "降低其他App音量"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "降低其他App音量"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "translated",
"value" : "降低其他App音量"
}
}
}
},
"ci6-ak-aCa.text" : {
"comment" : "Class = \"UILabel\"; text = \"Custom Resolution\"; ObjectID = \"ci6-ak-aCa\";",
"extractionState" : "extracted_with_value",