Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS: Add option to disable respecting silent mode (#14928) #15952

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,11 @@
#define DEFAULT_WASAPI_SH_BUFFER_LENGTH 0
#endif

#if TARGET_OS_IOS
/* Respect silent mode (false will render audio in silent mode) */
#define DEFAULT_AUDIO_RESPECT_SILENT_MODE true
#endif

/* Automatically mute audio when fast forward
* is enabled */
#define DEFAULT_AUDIO_FASTFORWARD_MUTE false
Expand Down
3 changes: 3 additions & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,9 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("audio_mute_enable", audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE), true, false, false);
#ifdef HAVE_AUDIOMIXER
SETTING_BOOL("audio_mixer_mute_enable", audio_get_bool_ptr(AUDIO_ACTION_MIXER_MUTE_ENABLE), true, false, false);
#endif
#if TARGET_OS_IOS
SETTING_BOOL("audio_respect_silent_mode", &settings->bools.audio_respect_silent_mode, true, DEFAULT_AUDIO_RESPECT_SILENT_MODE, false);
#endif
SETTING_BOOL("audio_fastforward_mute", &settings->bools.audio_fastforward_mute, true, DEFAULT_AUDIO_FASTFORWARD_MUTE, false);
SETTING_BOOL("audio_fastforward_speedup", &settings->bools.audio_fastforward_speedup, true, DEFAULT_AUDIO_FASTFORWARD_SPEEDUP, false);
Expand Down
3 changes: 3 additions & 0 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ typedef struct settings
bool audio_rate_control;
bool audio_fastforward_mute;
bool audio_fastforward_speedup;
#ifdef TARGET_OS_IOS
bool audio_respect_silent_mode;
#endif

#ifdef HAVE_WASAPI
bool audio_wasapi_exclusive_mode;
Expand Down
4 changes: 4 additions & 0 deletions intl/msg_hash_lbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ MSG_HASH(
MENU_ENUM_LABEL_AUDIO_MUTE,
"audio_mute_enable"
)
MSG_HASH(
MENU_ENUM_LABEL_AUDIO_RESPECT_SILENT_MODE,
"audio_respect_silent_mode"
)
MSG_HASH(
MENU_ENUM_LABEL_AUDIO_FASTFORWARD_MUTE,
"audio_fastforward_mute"
Expand Down
8 changes: 8 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -2633,6 +2633,14 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_AUDIO_MIXER_MUTE,
"Mute mixer audio."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_AUDIO_RESPECT_SILENT_MODE,
"Respect Silent Mode"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_AUDIO_RESPECT_SILENT_MODE,
"Mute all audio in Silent Mode."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_AUDIO_FASTFORWARD_MUTE,
"Mute When Fast-Forwarding"
Expand Down
8 changes: 8 additions & 0 deletions menu/cbs/menu_cbs_sublabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_mute, MENU_
#ifdef HAVE_AUDIOMIXER
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_mixer_mute, MENU_ENUM_SUBLABEL_AUDIO_MIXER_MUTE)
#endif
#if TARGET_OS_IOS
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_respect_silent_mode, MENU_ENUM_SUBLABEL_AUDIO_RESPECT_SILENT_MODE)
#endif
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_fastforward_mute, MENU_ENUM_SUBLABEL_AUDIO_FASTFORWARD_MUTE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_audio_fastforward_speedup, MENU_ENUM_SUBLABEL_AUDIO_FASTFORWARD_SPEEDUP)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_camera_allow, MENU_ENUM_SUBLABEL_CAMERA_ALLOW)
Expand Down Expand Up @@ -4512,6 +4515,11 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_mixer_mute);
#endif
break;
#if TARGET_OS_IOS
case MENU_ENUM_LABEL_AUDIO_RESPECT_SILENT_MODE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_respect_silent_mode);
break;
#endif
case MENU_ENUM_LABEL_AUDIO_FASTFORWARD_MUTE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_fastforward_mute);
break;
Expand Down
1 change: 1 addition & 0 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -7292,6 +7292,7 @@ unsigned menu_displaylist_build_list(
{MENU_ENUM_LABEL_MENU_SOUNDS, PARSE_ACTION, true },
{MENU_ENUM_LABEL_AUDIO_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_MIXER_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_RESPECT_SILENT_MODE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_FASTFORWARD_MUTE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_FASTFORWARD_SPEEDUP, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_AUDIO_VOLUME, PARSE_ONLY_FLOAT, false },
Expand Down
20 changes: 20 additions & 0 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -13774,6 +13774,26 @@ static bool setting_append_list(
SD_FLAG_LAKKA_ADVANCED
);
#endif

#if TARGET_OS_IOS
CONFIG_BOOL(
list, list_info,
&settings->bools.audio_respect_silent_mode,
MENU_ENUM_LABEL_AUDIO_RESPECT_SILENT_MODE,
MENU_ENUM_LABEL_VALUE_AUDIO_RESPECT_SILENT_MODE,
DEFAULT_AUDIO_RESPECT_SILENT_MODE,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE
);

#endif

CONFIG_BOOL(
list, list_info,
&settings->bools.audio_fastforward_mute,
Expand Down
1 change: 1 addition & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,7 @@ enum msg_hash_enums
MENU_LABEL(AUDIO_DSP_PLUGIN_REMOVE),
MENU_LABEL(AUDIO_MUTE),
MENU_LABEL(AUDIO_MIXER_MUTE),
MENU_LABEL(AUDIO_RESPECT_SILENT_MODE),
MENU_LABEL(AUDIO_FASTFORWARD_MUTE),
MENU_LABEL(AUDIO_FASTFORWARD_SPEEDUP),
MENU_LABEL(AUDIO_SYNC),
Expand Down
8 changes: 6 additions & 2 deletions ui/drivers/ui_cocoatouch.m
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ - (void)handleAudioSessionInterruption:(NSNotification *)notification

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
NSError *error;
char arguments[] = "retroarch";
char *argv[] = {arguments, NULL};
int argc = 1;
Expand All @@ -471,7 +470,6 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];

[self refreshSystemConfig];
Expand Down Expand Up @@ -507,9 +505,15 @@ - (void)applicationWillTerminate:(UIApplication *)application
- (void)applicationDidBecomeActive:(UIApplication *)application
{
rarch_start_draw_observer();
NSError *error;
settings_t *settings = config_get_ptr();
bool ui_companion_start_on_boot = settings->bools.ui_companion_start_on_boot;

if (settings->bools.audio_respect_silent_mode)
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error];
else
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];

if (!ui_companion_start_on_boot)
[self showGameView];
}
Expand Down
Loading