diff --git a/config.def.h b/config.def.h index 1dbb541ca9..afdb4150a5 100644 --- a/config.def.h +++ b/config.def.h @@ -792,6 +792,13 @@ static const float max_timing_skew = 0.05; /* Default audio volume in dB. (0.0 dB == unity gain). */ static const float audio_volume = 0.0; +#ifdef HAVE_WASAPI +/* WASAPI defaults */ +static const bool wasapi_exclusive_mode = true; +static const bool wasapi_float_format = false; +static const unsigned wasapi_sh_buffer_length = 0; +#endif + /* MISC */ /* Enables displaying the current frames per second. */ diff --git a/configuration.c b/configuration.c index e3486ce5d3..a5f9ac975a 100644 --- a/configuration.c +++ b/configuration.c @@ -876,8 +876,8 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("input_autodetect_enable", &settings->bools.input_autodetect_enable, true, input_autodetect_enable, false); SETTING_BOOL("audio_rate_control", &settings->bools.audio_rate_control, true, rate_control, false); #ifdef HAVE_WASAPI - SETTING_BOOL("audio_wasapi_exclusive_mode", &settings->bools.audio_wasapi_exclusive_mode, true, true, false); - SETTING_BOOL("audio_wasapi_float_format", &settings->bools.audio_wasapi_float_format, true, false, false); + SETTING_BOOL("audio_wasapi_exclusive_mode", &settings->bools.audio_wasapi_exclusive_mode, true, wasapi_exclusive_mode, false); + SETTING_BOOL("audio_wasapi_float_format", &settings->bools.audio_wasapi_float_format, true, wasapi_float_format, false); #endif if (global) @@ -990,7 +990,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("bundle_assets_extract_version_current", &settings->uints.bundle_assets_extract_version_current, true, 0, false); SETTING_UINT("bundle_assets_extract_last_version", &settings->uints.bundle_assets_extract_last_version, true, 0, false); #ifdef HAVE_WASAPI - SETTING_UINT("audio_wasapi_sh_buffer_length", &settings->uints.audio_wasapi_sh_buffer_length, true, 0, false); + SETTING_UINT("audio_wasapi_sh_buffer_length", &settings->uints.audio_wasapi_sh_buffer_length, true, wasapi_sh_buffer_length, false); #endif *size = count; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index a08868599e..8089e36014 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -50,6 +50,12 @@ MSG_HASH(MENU_ENUM_LABEL_AUDIO_SYNC, "audio_sync") MSG_HASH(MENU_ENUM_LABEL_AUDIO_VOLUME, "audio_volume") +MSG_HASH(MENU_ENUM_LABEL_AUDIO_WASAPI_EXCLUSIVE_MODE, + "audio_wasapi_exclusive_mode") +MSG_HASH(MENU_ENUM_LABEL_AUDIO_WASAPI_FLOAT_FORMAT, + "audio_wasapi_float_format") +MSG_HASH(MENU_ENUM_LABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH, + "audio_wasapi_sh_buffer_length") MSG_HASH(MENU_ENUM_LABEL_AUTOSAVE_INTERVAL, "autosave_interval") MSG_HASH(MENU_ENUM_LABEL_AUTO_OVERRIDES_ENABLE, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 80c51041ed..b1e12ad5ba 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -274,6 +274,18 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_VOLUME, "Audio Volume Level (dB)" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_EXCLUSIVE_MODE, + "WASAPI Exclusive Mode" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_FLOAT_FORMAT, + "WASAPI Float Format" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_SH_BUFFER_LENGTH, + "WASAPI Shared Buffer Length" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUTOSAVE_INTERVAL, "SaveRAM Autosave Interval" @@ -2235,6 +2247,18 @@ MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_VOLUME, "Audio volume (in dB). 0 dB is normal volume, and no gain is applied." ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_WASAPI_EXCLUSIVE_MODE, + "Allow the WASAPI driver to take exclusive control of the audio device. If disabled, it will use shared mode instead." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_WASAPI_FLOAT_FORMAT, + "Use float format for the WASAPI driver, if supported by your audio device." + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH, + "The audio buffer length when using the WASAPI driver in shared mode." + ) MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_SYNC, "Synchronize audio. Recommended." diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 8ae1bd9cbd..7613471097 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -180,6 +180,9 @@ default_sublabel_macro(action_bind_sublabel_dynamic_wallpaper, MENU_ default_sublabel_macro(action_bind_sublabel_audio_device, MENU_ENUM_SUBLABEL_AUDIO_DEVICE) default_sublabel_macro(action_bind_sublabel_audio_output_rate, MENU_ENUM_SUBLABEL_AUDIO_OUTPUT_RATE) default_sublabel_macro(action_bind_sublabel_audio_dsp_plugin, MENU_ENUM_SUBLABEL_AUDIO_DSP_PLUGIN) +default_sublabel_macro(action_bind_sublabel_audio_wasapi_exclusive_mode, MENU_ENUM_SUBLABEL_AUDIO_WASAPI_EXCLUSIVE_MODE) +default_sublabel_macro(action_bind_sublabel_audio_wasapi_float_format, MENU_ENUM_SUBLABEL_AUDIO_WASAPI_FLOAT_FORMAT) +default_sublabel_macro(action_bind_sublabel_audio_wasapi_sh_buffer_length, MENU_ENUM_SUBLABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH) default_sublabel_macro(action_bind_sublabel_overlay_opacity, MENU_ENUM_SUBLABEL_OVERLAY_OPACITY) default_sublabel_macro(action_bind_sublabel_overlay_scale, MENU_ENUM_SUBLABEL_OVERLAY_SCALE) default_sublabel_macro(action_bind_sublabel_overlay_enable, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_ENABLE) @@ -799,6 +802,15 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_AUDIO_DEVICE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_device); break; + case MENU_ENUM_LABEL_AUDIO_WASAPI_EXCLUSIVE_MODE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_wasapi_exclusive_mode); + break; + case MENU_ENUM_LABEL_AUDIO_WASAPI_FLOAT_FORMAT: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_wasapi_float_format); + break; + case MENU_ENUM_LABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_wasapi_sh_buffer_length); + break; case MENU_ENUM_LABEL_MENU_WALLPAPER: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_wallpaper); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index bdd7d00d55..8c57b5acc9 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5299,6 +5299,17 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, PARSE_ONLY_PATH, false); +#ifdef HAVE_WASAPI + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_AUDIO_WASAPI_EXCLUSIVE_MODE, + PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_AUDIO_WASAPI_FLOAT_FORMAT, + PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH, + PARSE_ONLY_UINT, false); +#endif info->need_refresh = true; info->need_push = true; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 9a851fd4ac..57b249cf9a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1680,6 +1680,9 @@ void general_write_handler(void *data) case MENU_ENUM_LABEL_AUDIO_LATENCY: case MENU_ENUM_LABEL_AUDIO_DEVICE: case MENU_ENUM_LABEL_AUDIO_OUTPUT_RATE: + case MENU_ENUM_LABEL_AUDIO_WASAPI_EXCLUSIVE_MODE: + case MENU_ENUM_LABEL_AUDIO_WASAPI_FLOAT_FORMAT: + case MENU_ENUM_LABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH: rarch_cmd = CMD_EVENT_AUDIO_REINIT; break; case MENU_ENUM_LABEL_PAL60_ENABLE: @@ -3920,6 +3923,57 @@ static bool setting_append_list( menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_DSP_FILTER_INIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); +#ifdef HAVE_WASAPI + if (memcmp(settings->arrays.audio_driver, "wasapi", 6) == 0) + { + CONFIG_BOOL( + list, list_info, + &settings->bools.audio_wasapi_exclusive_mode, + MENU_ENUM_LABEL_AUDIO_WASAPI_EXCLUSIVE_MODE, + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_EXCLUSIVE_MODE, + wasapi_exclusive_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 + ); + + CONFIG_BOOL( + list, list_info, + &settings->bools.audio_wasapi_float_format, + MENU_ENUM_LABEL_AUDIO_WASAPI_FLOAT_FORMAT, + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_FLOAT_FORMAT, + wasapi_float_format, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_ADVANCED + ); + + CONFIG_UINT( + list, list_info, + &settings->uints.audio_wasapi_sh_buffer_length, + MENU_ENUM_LABEL_AUDIO_WASAPI_SH_BUFFER_LENGTH, + MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_SH_BUFFER_LENGTH, + wasapi_sh_buffer_length, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + menu_settings_list_current_add_range(list, list_info, 0, 1024, 16.0, true, true); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); + } +#endif + END_SUB_GROUP(list, list_info, parent_group); END_GROUP(list, list_info, parent_group); break; diff --git a/msg_hash.h b/msg_hash.h index 4b26ef75e7..3bda5f6ee1 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -960,6 +960,10 @@ enum msg_hash_enums MENU_LABEL(AUDIO_VOLUME), MENU_LABEL(AUDIO_RATE_CONTROL_DELTA), MENU_LABEL(AUDIO_LATENCY), + MENU_LABEL(AUDIO_WASAPI_EXCLUSIVE_MODE), + MENU_LABEL(AUDIO_WASAPI_FLOAT_FORMAT), + MENU_LABEL(AUDIO_WASAPI_SH_BUFFER_LENGTH), + MENU_LABEL(SAVE_STATE), MENU_LABEL(LOAD_STATE), MENU_LABEL(UNDO_LOAD_STATE),