mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-09-02 05:32:59 +02:00
Add audio activation settings to iOS
This commit is contained in:
@@ -283,6 +283,15 @@ static NSString const *typeLightTemp = @"typeLightTemp";
|
||||
];
|
||||
|
||||
NSArray<NSDictionary *> *audioMenu = @[
|
||||
@{
|
||||
@"header": @"Enable Audio",
|
||||
@"items": @[
|
||||
@{@"type": typeRadio, @"pref": @"GBAudioMode", @"title": @"Never", @"value": @"off",},
|
||||
@{@"type": typeRadio, @"pref": @"GBAudioMode", @"title": @"Controlled by Silent Mode", @"value": @"switch",},
|
||||
@{@"type": typeRadio, @"pref": @"GBAudioMode", @"title": @"Always", @"value": @"on",},
|
||||
],
|
||||
|
||||
},
|
||||
@{
|
||||
@"header": @"High-pass Filter",
|
||||
@"items": @[
|
||||
|
@@ -143,6 +143,13 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
||||
[self addDefaultObserver:^(id newValue) {
|
||||
GB_set_rewind_length(gb, [newValue unsignedIntValue]);
|
||||
} forKey:@"GBRewindLength"];
|
||||
[self addDefaultObserver:^(id newValue) {
|
||||
[[AVAudioSession sharedInstance] setCategory:[newValue isEqual:@"on"]? AVAudioSessionCategoryPlayback : AVAudioSessionCategorySoloAmbient
|
||||
mode:AVAudioSessionModeMeasurement // Reduces latency on BT
|
||||
routeSharingPolicy:AVAudioSessionRouteSharingPolicyDefault
|
||||
options:AVAudioSessionCategoryOptionAllowBluetoothA2DP | AVAudioSessionCategoryOptionAllowAirPlay
|
||||
error:nil];
|
||||
} forKey:@"GBAudioMode"];
|
||||
}
|
||||
|
||||
- (void)addDefaultObserver:(void(^)(id newValue))block forKey:(NSString *)key
|
||||
@@ -526,6 +533,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
||||
{
|
||||
GB_set_pixels_output(&_gb, _gbView.pixels);
|
||||
GB_set_sample_rate(&_gb, 96000);
|
||||
if (![[[NSUserDefaults standardUserDefaults] stringForKey:@"GBAudioMode"] isEqual:@"off"]) {
|
||||
_audioClient = [[GBAudioClient alloc] initWithRendererBlock:^(UInt32 sampleRate, UInt32 nFrames, GB_sample_t *buffer) {
|
||||
[_audioLock lock];
|
||||
|
||||
@@ -557,6 +565,7 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp)
|
||||
}
|
||||
[_audioLock unlock];
|
||||
} andSampleRate:96000];
|
||||
}
|
||||
|
||||
[_audioClient start];
|
||||
if (GB_has_accelerometer(&_gb)) {
|
||||
|
@@ -9,6 +9,7 @@ int main(int argc, char * argv[])
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
|
||||
@"GBFilter": @"NearestNeighbor",
|
||||
@"GBColorCorrection": @(GB_COLOR_CORRECTION_MODERN_BALANCED),
|
||||
@"GBAudioMode": @"switch",
|
||||
@"GBHighpassFilter": @(GB_HIGHPASS_ACCURATE),
|
||||
@"GBRewindLength": @(10),
|
||||
@"GBFrameBlendingMode": @(GB_FRAME_BLENDING_MODE_ACCURATE),
|
||||
|
Reference in New Issue
Block a user