diff --git a/config.def.h b/config.def.h index aae6d51880..5e9a4bb87f 100644 --- a/config.def.h +++ b/config.def.h @@ -343,7 +343,8 @@ static const char *default_shader_dir = ":/shaders_glsl/"; static const char *default_shader_dir = NULL; #endif -static const char *default_filter_dir = NULL; +static const char *default_filter_dir = NULL; +static const char *default_dsp_filter_dir = NULL; #if defined(__QNX__) static const char *default_config_path = "app/native/retroarch.cfg"; diff --git a/driver.c b/driver.c index edbd18fd2d..7f01640470 100644 --- a/driver.c +++ b/driver.c @@ -967,7 +967,7 @@ void uninit_drivers(void) } #ifdef HAVE_DYLIB -static void init_dsp_plugin(void) +void rarch_init_dsp_filter(void) { if (!(*g_settings.audio.dsp_plugin)) return; @@ -1023,13 +1023,15 @@ error: g_extern.audio_data.dsp_lib = NULL; } -static void deinit_dsp_plugin(void) +void rarch_deinit_dsp_filter(void) { if (g_extern.audio_data.dsp_lib && g_extern.audio_data.dsp_plugin) { g_extern.audio_data.dsp_plugin->free(g_extern.audio_data.dsp_handle); dylib_close(g_extern.audio_data.dsp_lib); } + g_extern.audio_data.dsp_handle = NULL; + g_extern.audio_data.dsp_plugin = NULL; } #endif @@ -1130,7 +1132,7 @@ void init_audio(void) } #ifdef HAVE_DYLIB - init_dsp_plugin(); + rarch_init_dsp_filter(); #endif g_extern.measure_data.buffer_free_samples_count = 0; @@ -1275,7 +1277,7 @@ void uninit_audio(void) g_extern.audio_data.outsamples = NULL; #ifdef HAVE_DYLIB - deinit_dsp_plugin(); + rarch_deinit_dsp_filter(); #endif compute_audio_buffer_statistics(); diff --git a/driver.h b/driver.h index 1cfbddf6cd..a670a36560 100644 --- a/driver.h +++ b/driver.h @@ -584,6 +584,8 @@ float driver_sensor_get_input(unsigned port, unsigned action); #ifdef HAVE_DYLIB void rarch_deinit_filter(void); void rarch_init_filter(enum retro_pixel_format); +void rarch_init_dsp_filter(void); +void rarch_deinit_dsp_filter(void); #endif // Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE diff --git a/frontend/menu/backend/menu_common_backend.c b/frontend/menu/backend/menu_common_backend.c index 35b27d67b4..6017368da4 100644 --- a/frontend/menu/backend/menu_common_backend.c +++ b/frontend/menu/backend/menu_common_backend.c @@ -300,7 +300,8 @@ static void menu_common_entries_init(void *data, unsigned menu_type) file_list_push(rgui->selection_buf, "Core Directory", RGUI_LIBRETRO_DIR_PATH, 0); file_list_push(rgui->selection_buf, "Core Info Directory", RGUI_LIBRETRO_INFO_DIR_PATH, 0); #ifdef HAVE_DYLIB - file_list_push(rgui->selection_buf, "Filter Directory", RGUI_FILTER_DIR_PATH, 0); + file_list_push(rgui->selection_buf, "Video Filter Directory", RGUI_FILTER_DIR_PATH, 0); + file_list_push(rgui->selection_buf, "DSP Filter Directory", RGUI_DSP_FILTER_DIR_PATH, 0); #endif #ifdef HAVE_SHADER_MANAGER file_list_push(rgui->selection_buf, "Shader Directory", RGUI_SHADER_DIR_PATH, 0); @@ -336,6 +337,9 @@ static void menu_common_entries_init(void *data, unsigned menu_type) break; case RGUI_SETTINGS_AUDIO_OPTIONS: file_list_clear(rgui->selection_buf); +#ifdef HAVE_DYLIB + file_list_push(rgui->selection_buf, "DSP Filter", RGUI_SETTINGS_AUDIO_DSP_FILTER, 0); +#endif file_list_push(rgui->selection_buf, "Mute Audio", RGUI_SETTINGS_AUDIO_MUTE, 0); file_list_push(rgui->selection_buf, "Rate Control Delta", RGUI_SETTINGS_AUDIO_CONTROL_RATE_DELTA, 0); #ifdef __CELLOS_LV2__ @@ -526,6 +530,7 @@ static unsigned menu_common_type_is(unsigned type) type_found = type == RGUI_BROWSER_DIR_PATH || type == RGUI_SHADER_DIR_PATH || type == RGUI_FILTER_DIR_PATH || + type == RGUI_DSP_FILTER_DIR_PATH || type == RGUI_SAVESTATE_DIR_PATH || type == RGUI_LIBRETRO_DIR_PATH || type == RGUI_LIBRETRO_INFO_DIR_PATH || @@ -661,6 +666,7 @@ static int menu_settings_iterate(void *data, unsigned action) menu_common_type_is(menu_type) == RGUI_SETTINGS_SHADER_OPTIONS|| menu_common_type_is(menu_type) == RGUI_FILE_DIRECTORY || menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER || + menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER || menu_type == RGUI_SETTINGS_OVERLAY_PRESET || menu_type == RGUI_SETTINGS_CORE || menu_type == RGUI_SETTINGS_CONFIG || @@ -1000,6 +1006,8 @@ static void menu_parse_and_resolve(void *data, unsigned menu_type) exts = "cg|glsl"; else if (menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER) exts = EXT_EXECUTABLES; + else if (menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER) + exts = EXT_EXECUTABLES; else if (menu_type == RGUI_SETTINGS_OVERLAY_PRESET) exts = "cfg"; else if (menu_common_type_is(menu_type) == RGUI_FILE_DIRECTORY) @@ -1291,6 +1299,7 @@ static int menu_common_iterate(void *data, unsigned action) menu_common_type_is(type) == RGUI_FILE_DIRECTORY || type == RGUI_SETTINGS_OVERLAY_PRESET || type == RGUI_SETTINGS_VIDEO_SOFTFILTER || + type == RGUI_SETTINGS_AUDIO_DSP_FILTER || type == RGUI_SETTINGS_CORE || type == RGUI_SETTINGS_CONFIG || type == RGUI_SETTINGS_DISK_APPEND || @@ -1446,6 +1455,15 @@ static int menu_common_iterate(void *data, unsigned action) #endif menu_flush_stack_type(rgui, RGUI_SETTINGS_VIDEO_OPTIONS); } + else if (menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER) + { + fill_pathname_join(g_settings.audio.dsp_plugin, dir, path, sizeof(g_settings.audio.dsp_plugin)); +#ifdef HAVE_DYLIB + rarch_deinit_dsp_filter(); + rarch_init_dsp_filter(); +#endif + menu_flush_stack_type(rgui, RGUI_SETTINGS_AUDIO_OPTIONS); + } else if (menu_type == RGUI_SAVESTATE_DIR_PATH) { strlcpy(g_extern.savestate_dir, dir, sizeof(g_extern.savestate_dir)); @@ -1480,6 +1498,11 @@ static int menu_common_iterate(void *data, unsigned action) strlcpy(g_settings.video.filter_dir, dir, sizeof(g_settings.video.filter_dir)); menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); } + else if (menu_type == RGUI_DSP_FILTER_DIR_PATH) + { + strlcpy(g_settings.audio.filter_dir, dir, sizeof(g_settings.audio.filter_dir)); + menu_flush_stack_type(rgui, RGUI_SETTINGS_PATH_OPTIONS); + } else if (menu_type == RGUI_SYSTEM_DIR_PATH) { strlcpy(g_settings.system_directory, dir, sizeof(g_settings.system_directory)); @@ -1556,6 +1579,7 @@ static int menu_common_iterate(void *data, unsigned action) menu_common_type_is(menu_type) == RGUI_FILE_DIRECTORY || menu_type == RGUI_SETTINGS_OVERLAY_PRESET || menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER || + menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER || menu_type == RGUI_SETTINGS_DEFERRED_CORE || menu_type == RGUI_SETTINGS_CORE || menu_type == RGUI_SETTINGS_CONFIG || @@ -1831,10 +1855,12 @@ static unsigned menu_common_shader_manager_get_type(void *data) { unsigned i, type; (void)data; - (void)i; + i = 0; type = 0; + (void)i; + #ifdef HAVE_SHADER_MANAGER const struct gfx_shader *shader = (const struct gfx_shader*)data; @@ -2496,6 +2522,23 @@ static int menu_common_setting_set(void *data, unsigned setting, unsigned action break; } break; + case RGUI_SETTINGS_AUDIO_DSP_FILTER: + switch (action) + { + case RGUI_ACTION_OK: + file_list_push(rgui->menu_stack, g_settings.audio.filter_dir, setting, rgui->selection_ptr); + menu_clear_navigation(rgui); + rgui->need_refresh = true; + break; + case RGUI_ACTION_START: + strlcpy(g_settings.audio.dsp_plugin, "", sizeof(g_settings.audio.dsp_plugin)); +#ifdef HAVE_DYLIB + rarch_deinit_dsp_filter(); + rarch_init_dsp_filter(); +#endif + break; + } + break; #ifdef HAVE_OVERLAY case RGUI_SETTINGS_OVERLAY_OPACITY: { @@ -2934,6 +2977,10 @@ static int menu_common_setting_set(void *data, unsigned setting, unsigned action if (action == RGUI_ACTION_START) *g_settings.video.filter_dir = '\0'; break; + case RGUI_DSP_FILTER_DIR_PATH: + if (action == RGUI_ACTION_START) + *g_settings.audio.filter_dir = '\0'; + break; case RGUI_SHADER_DIR_PATH: if (action == RGUI_ACTION_START) *g_settings.video.shader_dir = '\0'; @@ -3919,6 +3966,9 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size, case RGUI_FILTER_DIR_PATH: strlcpy(type_str, *g_settings.video.filter_dir ? g_settings.video.filter_dir : "", type_str_size); break; + case RGUI_DSP_FILTER_DIR_PATH: + strlcpy(type_str, *g_settings.audio.filter_dir ? g_settings.audio.filter_dir : "", type_str_size); + break; case RGUI_SHADER_DIR_PATH: strlcpy(type_str, *g_settings.video.shader_dir ? g_settings.video.shader_dir : "", type_str_size); break; @@ -3973,11 +4023,14 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size, strlcpy(type_str, "...", type_str_size); break; case RGUI_SETTINGS_VIDEO_SOFTFILTER: - { - const char *filter_name = rarch_softfilter_get_name(g_extern.filter.filter); - strlcpy(type_str, filter_name ? filter_name : "N/A", type_str_size); + { + const char *filter_name = rarch_softfilter_get_name(g_extern.filter.filter); + strlcpy(type_str, filter_name ? filter_name : "N/A", type_str_size); + } + break; + case RGUI_SETTINGS_AUDIO_DSP_FILTER: + strlcpy(type_str, *g_settings.audio.dsp_plugin ? g_settings.audio.dsp_plugin : "N/A", type_str_size); break; - } #ifdef HAVE_OVERLAY case RGUI_SETTINGS_OVERLAY_PRESET: strlcpy(type_str, path_basename(g_settings.input.overlay), type_str_size); diff --git a/frontend/menu/backend/menu_common_backend.h b/frontend/menu/backend/menu_common_backend.h index 92d5ad5292..fb055a86f6 100644 --- a/frontend/menu/backend/menu_common_backend.h +++ b/frontend/menu/backend/menu_common_backend.h @@ -113,6 +113,7 @@ typedef enum RGUI_SCREENSHOT_DIR_PATH, RGUI_BROWSER_DIR_PATH, RGUI_FILTER_DIR_PATH, + RGUI_DSP_FILTER_DIR_PATH, RGUI_SHADER_DIR_PATH, RGUI_SAVESTATE_DIR_PATH, RGUI_SAVEFILE_DIR_PATH, @@ -122,6 +123,7 @@ typedef enum RGUI_OVERLAY_DIR_PATH, RGUI_SYSTEM_DIR_PATH, RGUI_SETTINGS_RESTART_GAME, + RGUI_SETTINGS_AUDIO_DSP_FILTER, RGUI_SETTINGS_AUDIO_MUTE, RGUI_SETTINGS_AUDIO_CONTROL_RATE_DELTA, RGUI_SETTINGS_AUDIO_DSP_EFFECT, diff --git a/frontend/menu/disp/rgui.c b/frontend/menu/disp/rgui.c index 2726a3c86d..f496b7ed75 100644 --- a/frontend/menu/disp/rgui.c +++ b/frontend/menu/disp/rgui.c @@ -350,6 +350,8 @@ static void rgui_render(void *data) #endif else if (menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER) snprintf(title, sizeof(title), "FILTER %s", dir); + else if (menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER) + snprintf(title, sizeof(title), "DSP FILTER %s", dir); else if (menu_type == RGUI_BROWSER_DIR_PATH) snprintf(title, sizeof(title), "BROWSER DIR %s", dir); #ifdef HAVE_SCREENSHOTS @@ -360,6 +362,8 @@ static void rgui_render(void *data) snprintf(title, sizeof(title), "SHADER DIR %s", dir); else if (menu_type == RGUI_FILTER_DIR_PATH) snprintf(title, sizeof(title), "FILTER DIR %s", dir); + else if (menu_type == RGUI_DSP_FILTER_DIR_PATH) + snprintf(title, sizeof(title), "DSP FILTER DIR %s", dir); else if (menu_type == RGUI_SAVESTATE_DIR_PATH) snprintf(title, sizeof(title), "SAVESTATE DIR %s", dir); #ifdef HAVE_DYNAMIC @@ -474,6 +478,7 @@ static void rgui_render(void *data) menu_type == RGUI_SETTINGS_OVERLAY_PRESET || #endif menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER || + menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER || menu_type == RGUI_SETTINGS_DISK_APPEND || menu_type_is == RGUI_FILE_DIRECTORY) { diff --git a/frontend/menu/disp/rmenu.c b/frontend/menu/disp/rmenu.c index 40ac9bd6d7..d30b10d7c6 100644 --- a/frontend/menu/disp/rmenu.c +++ b/frontend/menu/disp/rmenu.c @@ -207,6 +207,10 @@ static void rmenu_render(void *data) else if (menu_type == RGUI_SETTINGS_OVERLAY_PRESET) snprintf(title, sizeof(title), "OVERLAY %s", dir); #endif + else if (menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER) + snprintf(title, sizeof(title), "FILTER %s", dir); + else if (menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER) + snprintf(title, sizeof(title), "DSP FILTER %s", dir); else if (menu_type == RGUI_BROWSER_DIR_PATH) snprintf(title, sizeof(title), "BROWSER DIR %s", dir); #ifdef HAVE_SCREENSHOTS @@ -217,6 +221,8 @@ static void rmenu_render(void *data) snprintf(title, sizeof(title), "SHADER DIR %s", dir); else if (menu_type == RGUI_FILTER_DIR_PATH) snprintf(title, sizeof(title), "FILTER DIR %s", dir); + else if (menu_type == RGUI_DSP_FILTER_DIR_PATH) + snprintf(title, sizeof(title), "DSP FILTER DIR %s", dir); else if (menu_type == RGUI_SAVESTATE_DIR_PATH) snprintf(title, sizeof(title), "SAVESTATE DIR %s", dir); #ifdef HAVE_DYNAMIC @@ -342,6 +348,8 @@ static void rmenu_render(void *data) #ifdef HAVE_OVERLAY menu_type == RGUI_SETTINGS_OVERLAY_PRESET || #endif + menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER || + menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER || menu_type == RGUI_SETTINGS_DISK_APPEND || menu_type_is == RGUI_FILE_DIRECTORY) { diff --git a/frontend/menu/disp/rmenu_xui.cpp b/frontend/menu/disp/rmenu_xui.cpp index 01b3bc8a35..3c95cdf508 100644 --- a/frontend/menu/disp/rmenu_xui.cpp +++ b/frontend/menu/disp/rmenu_xui.cpp @@ -459,6 +459,10 @@ static void rmenu_xui_render(void *data) else if (menu_type == RGUI_SETTINGS_OVERLAY_PRESET) snprintf(title, sizeof(title), "OVERLAY %s", dir); #endif + else if (menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER) + snprintf(title, sizeof(title), "FILTER %s", dir); + else if (menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER) + snprintf(title, sizeof(title), "DSP FILTER %s", dir); else if (menu_type == RGUI_BROWSER_DIR_PATH) snprintf(title, sizeof(title), "BROWSER DIR %s", dir); #ifdef HAVE_SCREENSHOTS @@ -469,6 +473,8 @@ static void rmenu_xui_render(void *data) snprintf(title, sizeof(title), "SHADER DIR %s", dir); else if (menu_type == RGUI_FILTER_DIR_PATH) snprintf(title, sizeof(title), "FILTER DIR %s", dir); + else if (menu_type == RGUI_DSP_FILTER_DIR_PATH) + snprintf(title, sizeof(title), "DSP_FILTER DIR %s", dir); else if (menu_type == RGUI_SAVESTATE_DIR_PATH) snprintf(title, sizeof(title), "SAVESTATE DIR %s", dir); #ifdef HAVE_DYNAMIC @@ -583,6 +589,8 @@ static void rmenu_xui_render(void *data) #ifdef HAVE_OVERLAY menu_type == RGUI_SETTINGS_OVERLAY_PRESET || #endif + menu_type == RGUI_SETTINGS_VIDEO_SOFTFILTER || + menu_type == RGUI_SETTINGS_AUDIO_DSP_FILTER || menu_type == RGUI_SETTINGS_DISK_APPEND || menu_type_is == RGUI_FILE_DIRECTORY) { diff --git a/general.h b/general.h index ea28fa0f10..ce04b92850 100644 --- a/general.h +++ b/general.h @@ -234,6 +234,7 @@ struct settings bool sync; char dsp_plugin[PATH_MAX]; + char filter_dir[PATH_MAX]; bool rate_control; float rate_control_delta; diff --git a/retroarch.c b/retroarch.c index f7cb695bfb..806155c501 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3060,7 +3060,7 @@ bool rarch_main_iterate(void) #ifdef HAVE_DYLIB // DSP plugin GUI events. - if (g_extern.audio_data.dsp_handle && g_extern.audio_data.dsp_plugin->events) + if (g_extern.audio_data.dsp_handle && g_extern.audio_data.dsp_plugin && g_extern.audio_data.dsp_plugin->events) g_extern.audio_data.dsp_plugin->events(g_extern.audio_data.dsp_handle); #endif diff --git a/settings.c b/settings.c index 1a07a8bac7..e604250044 100644 --- a/settings.c +++ b/settings.c @@ -395,6 +395,8 @@ void config_set_defaults(void) *g_settings.video.shader_dir = '\0'; *g_settings.video.filter_dir = '\0'; *g_settings.video.filter_path = '\0'; + *g_settings.audio.filter_dir = '\0'; + *g_settings.audio.dsp_plugin = '\0'; #ifdef HAVE_MENU *g_settings.rgui_content_directory = '\0'; *g_settings.rgui_config_directory = '\0'; @@ -448,6 +450,9 @@ void config_set_defaults(void) if (default_filter_dir) fill_pathname_expand_special(g_settings.video.filter_dir, default_filter_dir, sizeof(g_settings.video.filter_dir)); + if (default_dsp_filter_dir) + fill_pathname_expand_special(g_settings.audio.filter_dir, default_dsp_filter_dir, sizeof(g_settings.audio.filter_dir)); + if (default_libretro_path && !g_extern.has_set_libretro) fill_pathname_expand_special(g_settings.libretro, default_libretro_path, sizeof(g_settings.libretro)); @@ -889,6 +894,10 @@ bool config_load_file(const char *path, bool set_defaults) if (!strcmp(g_settings.video.filter_dir, "default")) *g_settings.video.filter_dir = '\0'; + CONFIG_GET_PATH(audio.filter_dir, "audio_filter_dir"); + if (!strcmp(g_settings.audio.filter_dir, "default")) + *g_settings.audio.filter_dir = '\0'; + CONFIG_GET_FLOAT(input.axis_threshold, "input_axis_threshold"); CONFIG_GET_BOOL(input.netplay_client_swap_input, "netplay_client_swap_input"); @@ -1309,6 +1318,7 @@ bool config_save_file(const char *path) config_set_path(conf, "screenshot_directory", *g_settings.screenshot_directory ? g_settings.screenshot_directory : "default"); config_set_int(conf, "aspect_ratio_index", g_settings.video.aspect_ratio_idx); config_set_string(conf, "audio_device", g_settings.audio.device); + config_set_string(conf, "audio_dsp_plugin", g_settings.audio.dsp_plugin); #ifdef HAVE_CAMERA config_set_string(conf, "camera_device", g_settings.camera.device); config_set_bool(conf, "camera_allow", g_settings.camera.allow); @@ -1334,6 +1344,7 @@ bool config_save_file(const char *path) config_set_path(conf, "video_shader_dir", *g_settings.video.shader_dir ? g_settings.video.shader_dir : "default"); config_set_path(conf, "video_filter", g_settings.video.filter_path); config_set_path(conf, "video_filter_dir", *g_settings.video.filter_dir ? g_settings.video.filter_dir : "default"); + config_set_path(conf, "audio_filter_dir", *g_settings.audio.filter_dir ? g_settings.audio.filter_dir : "default"); config_set_path(conf, "content_directory", *g_settings.content_directory ? g_settings.content_directory : "default"); #ifdef HAVE_MENU