From 3e5815948037dbbba9ee013918ddcbf9f7349b64 Mon Sep 17 00:00:00 2001 From: Monroe88 Date: Fri, 28 Apr 2017 20:36:52 -0500 Subject: [PATCH] Add WASAPI audio driver settings to the menu --- intl/msg_hash_lbl.h | 6 ++++ intl/msg_hash_us.h | 24 ++++++++++++++++ menu/cbs/menu_cbs_sublabel.c | 12 ++++++++ menu/menu_displaylist.c | 11 ++++++++ menu/menu_setting.c | 54 ++++++++++++++++++++++++++++++++++++ msg_hash.h | 4 +++ 6 files changed, 111 insertions(+) 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..35a9b3ae6b 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 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, 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 length of the buffer 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..0697137e3c 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, + true, + 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, + true, + 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, + 0, + &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),