From a02fadeb9432639347f40be02b4280ee55663a30 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 19 Oct 2020 11:30:28 +0100 Subject: [PATCH] Add 'Remove DSP Plugin' menu entry --- intl/msg_hash_lbl.h | 4 ++++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_ok.c | 27 +++++++++++++++++++++++++++ menu/cbs/menu_cbs_start.c | 28 ++++++++++++++++++++++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/drivers/materialui.c | 1 + menu/drivers/ozone/ozone_texture.c | 1 + menu/drivers/xmb.c | 1 + menu/menu_displaylist.c | 20 ++++++++++++++++---- menu/menu_driver.h | 1 + msg_hash.h | 1 + 11 files changed, 92 insertions(+), 4 deletions(-) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index cea600a9e2..e1841f74f9 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -86,6 +86,10 @@ MSG_HASH( MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, "audio_dsp_plugin" ) +MSG_HASH( + MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN_REMOVE, + "audio_dsp_plugin_remove" + ) MSG_HASH( MENU_ENUM_LABEL_AUDIO_ENABLE, "audio_enable" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 91222ed601..901e10653b 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1813,6 +1813,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_AUDIO_DSP_PLUGIN, "Audio DSP plugin that processes audio before it's sent to the driver." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_AUDIO_DSP_PLUGIN_REMOVE, + "Remove DSP Plugin" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_AUDIO_DSP_PLUGIN_REMOVE, + "Unload any active audio DSP plugin." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_AUDIO_WASAPI_EXCLUSIVE_MODE, "WASAPI Exclusive Mode" diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 58380227d9..c4d64c3718 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2990,6 +2990,30 @@ static int action_ok_video_filter_remove(const char *path, return 0; } +static int action_ok_audio_dsp_plugin_remove(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + settings_t *settings = config_get_ptr(); + + if (!settings) + return menu_cbs_exit(); + + if (!string_is_empty(settings->paths.path_audio_dsp_plugin)) + { + bool refresh = false; + + /* Unload dsp plugin filter */ + settings->paths.path_audio_dsp_plugin[0] = '\0'; + command_event(CMD_EVENT_DSP_FILTER_INIT, NULL); + + /* Refresh menu */ + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); + menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); + } + + return 0; +} + #ifdef HAVE_CHEATS static void menu_input_st_string_cb_cheat_file_save_as( void *userdata, const char *str) @@ -8027,6 +8051,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, case MENU_SETTING_ACTION_VIDEO_FILTER_REMOVE: BIND_ACTION_OK(cbs, action_ok_video_filter_remove); break; + case MENU_SETTING_ACTION_AUDIO_DSP_PLUGIN_REMOVE: + BIND_ACTION_OK(cbs, action_ok_audio_dsp_plugin_remove); + break; default: return -1; } diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index 275490ff65..79ef26444a 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -128,6 +128,31 @@ static int action_start_video_filter_file_load( return 0; } +static int action_start_audio_dsp_plugin_file_load( + const char *path, const char *label, + unsigned type, size_t idx, size_t entry_idx) +{ + settings_t *settings = config_get_ptr(); + + if (!settings) + return menu_cbs_exit(); + + if (!string_is_empty(settings->paths.path_audio_dsp_plugin)) + { + bool refresh = false; + + /* Unload dsp plugin filter */ + settings->paths.path_audio_dsp_plugin[0] = '\0'; + command_event(CMD_EVENT_DSP_FILTER_INIT, NULL); + + /* Refresh menu */ + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); + menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); + } + + return 0; +} + static int generic_action_start_performance_counters(struct retro_perf_counter **counters, unsigned offset, unsigned type, const char *label) { @@ -615,6 +640,9 @@ static int menu_cbs_init_bind_start_compare_label(menu_file_list_cbs_t *cbs) case MENU_ENUM_LABEL_VIDEO_FILTER: BIND_ACTION_START(cbs, action_start_video_filter_file_load); break; + case MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN: + BIND_ACTION_START(cbs, action_start_audio_dsp_plugin_file_load); + break; case MENU_ENUM_LABEL_VIDEO_SHADER_PASS: #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) BIND_ACTION_START(cbs, action_start_shader_pass); diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index c1f8ed7702..a64e1ef6d7 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -513,6 +513,7 @@ 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_dsp_plugin_remove, MENU_ENUM_SUBLABEL_AUDIO_DSP_PLUGIN_REMOVE) 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) @@ -2773,6 +2774,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_dsp_plugin); break; + case MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN_REMOVE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_dsp_plugin_remove); + break; case MENU_ENUM_LABEL_AUDIO_OUTPUT_RATE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_audio_output_rate); break; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index ae5cecbac6..fd7d51ff17 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -9781,6 +9781,7 @@ static void materialui_list_insert( case MENU_SETTING_ACTION_CORE_DELETE: case MENU_SETTING_ACTION_CORE_DELETE_BACKUP: case MENU_SETTING_ACTION_VIDEO_FILTER_REMOVE: + case MENU_SETTING_ACTION_AUDIO_DSP_PLUGIN_REMOVE: node->icon_texture_index = MUI_TEXTURE_REMOVE; node->icon_type = MUI_ICON_TYPE_INTERNAL; break; diff --git a/menu/drivers/ozone/ozone_texture.c b/menu/drivers/ozone/ozone_texture.c index 1b43d6d1cd..a7d004f082 100644 --- a/menu/drivers/ozone/ozone_texture.c +++ b/menu/drivers/ozone/ozone_texture.c @@ -249,6 +249,7 @@ uintptr_t ozone_entries_icon_get_texture(ozone_handle_t *ozone, case MENU_ENUM_LABEL_DELETE_PLAYLIST: case MENU_ENUM_LABEL_CORE_DELETE_BACKUP_LIST: case MENU_ENUM_LABEL_VIDEO_FILTER_REMOVE: + case MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN_REMOVE: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CLOSE]; case MENU_ENUM_LABEL_CORE_LOCK: return ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CORE]; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 7bb7bafd23..b905ce3891 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2696,6 +2696,7 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, case MENU_ENUM_LABEL_DELETE_PLAYLIST: case MENU_ENUM_LABEL_CORE_DELETE_BACKUP_LIST: case MENU_ENUM_LABEL_VIDEO_FILTER_REMOVE: + case MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN_REMOVE: return xmb->textures.list[XMB_TEXTURE_CLOSE]; case MENU_ENUM_LABEL_CORE_LOCK: return xmb->textures.list[XMB_TEXTURE_CORE]; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 25b523373c..236104a775 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5625,10 +5625,22 @@ unsigned menu_displaylist_build_list( count++; #ifdef HAVE_DSP_FILTER - if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, - MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, - PARSE_ONLY_PATH, false) == 0) - count++; + { + settings_t *settings = config_get_ptr(); + + if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list, + MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN, + PARSE_ONLY_PATH, false) == 0) + count++; + + if (!string_is_empty(settings->paths.path_audio_dsp_plugin)) + if (menu_entries_append_enum(list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_AUDIO_DSP_PLUGIN_REMOVE), + msg_hash_to_str(MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN_REMOVE), + MENU_ENUM_LABEL_AUDIO_DSP_PLUGIN_REMOVE, + MENU_SETTING_ACTION_AUDIO_DSP_PLUGIN_REMOVE, 0, 0)) + count++; + } #endif break; case DISPLAYLIST_VIDEO_SETTINGS_LIST: diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 0a31bce6fd..33565daa05 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -221,6 +221,7 @@ enum menu_settings_type MENU_SETTING_ITEM_CORE_DELETE_BACKUP, MENU_SETTING_ACTION_VIDEO_FILTER_REMOVE, + MENU_SETTING_ACTION_AUDIO_DSP_PLUGIN_REMOVE, MENU_SETTINGS_LAST }; diff --git a/msg_hash.h b/msg_hash.h index 85d3055ee7..30f549554d 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1598,6 +1598,7 @@ enum msg_hash_enums MENU_LABEL(AUDIO_DEVICE), MENU_LABEL(AUDIO_BLOCK_FRAMES), MENU_LABEL(AUDIO_DSP_PLUGIN), + MENU_LABEL(AUDIO_DSP_PLUGIN_REMOVE), MENU_LABEL(AUDIO_MUTE), MENU_LABEL(AUDIO_MIXER_MUTE), MENU_LABEL(AUDIO_FASTFORWARD_MUTE),