mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Refactor DSP filter init/deinit
This commit is contained in:
parent
b80961301a
commit
e110bd90f5
27
driver.c
27
driver.c
@ -27,7 +27,6 @@
|
||||
#include "audio/resampler.h"
|
||||
#include "gfx/thread_wrapper.h"
|
||||
#include "audio/thread_wrapper.h"
|
||||
#include "audio/dsp_filter.h"
|
||||
#include "gfx/gfx_common.h"
|
||||
|
||||
#ifdef HAVE_X11
|
||||
@ -696,24 +695,6 @@ void uninit_drivers(void)
|
||||
driver.audio_data = NULL;
|
||||
}
|
||||
|
||||
void rarch_init_dsp_filter(void)
|
||||
{
|
||||
rarch_deinit_dsp_filter();
|
||||
if (!*g_settings.audio.dsp_plugin)
|
||||
return;
|
||||
|
||||
g_extern.audio_data.dsp = rarch_dsp_filter_new(g_settings.audio.dsp_plugin, g_extern.audio_data.in_rate);
|
||||
if (!g_extern.audio_data.dsp)
|
||||
RARCH_ERR("[DSP]: Failed to initialize DSP filter \"%s\".\n", g_settings.audio.dsp_plugin);
|
||||
}
|
||||
|
||||
void rarch_deinit_dsp_filter(void)
|
||||
{
|
||||
if (g_extern.audio_data.dsp)
|
||||
rarch_dsp_filter_free(g_extern.audio_data.dsp);
|
||||
g_extern.audio_data.dsp = NULL;
|
||||
}
|
||||
|
||||
void init_audio(void)
|
||||
{
|
||||
audio_convert_init_simd();
|
||||
@ -817,7 +798,7 @@ void init_audio(void)
|
||||
RARCH_WARN("Audio rate control was desired, but driver does not support needed features.\n");
|
||||
}
|
||||
|
||||
rarch_init_dsp_filter();
|
||||
rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT);
|
||||
|
||||
g_extern.measure_data.buffer_free_samples_count = 0;
|
||||
|
||||
@ -935,7 +916,7 @@ void uninit_audio(void)
|
||||
free(g_extern.audio_data.outsamples);
|
||||
g_extern.audio_data.outsamples = NULL;
|
||||
|
||||
rarch_deinit_dsp_filter();
|
||||
rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT);
|
||||
|
||||
compute_audio_buffer_statistics();
|
||||
}
|
||||
@ -1197,7 +1178,7 @@ void init_video_input(void)
|
||||
}
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_FREE);
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_DEINIT);
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_INIT);
|
||||
#endif
|
||||
|
||||
@ -1207,7 +1188,7 @@ void init_video_input(void)
|
||||
void uninit_video_input(void)
|
||||
{
|
||||
#ifdef HAVE_OVERLAY
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_FREE);
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_DEINIT);
|
||||
#endif
|
||||
|
||||
if (!driver.input_data_own && driver.input_data != driver.video_data && driver.input && driver.input->free)
|
||||
|
2
driver.h
2
driver.h
@ -562,8 +562,6 @@ void rarch_init_filter(enum retro_pixel_format);
|
||||
unsigned dspfilter_get_last_idx(void);
|
||||
#endif
|
||||
|
||||
void rarch_init_dsp_filter(void);
|
||||
void rarch_deinit_dsp_filter(void);
|
||||
const char *rarch_dspfilter_get_name(void *data);
|
||||
|
||||
// Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE
|
||||
|
@ -3704,7 +3704,7 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
|
||||
menu_common_setting_push_current_menu(driver.menu->menu_stack, g_extern.overlay_dir, setting, driver.menu->selection_ptr, action);
|
||||
break;
|
||||
case MENU_ACTION_START:
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_FREE);
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_DEINIT);
|
||||
*g_settings.input.overlay = '\0';
|
||||
break;
|
||||
default:
|
||||
@ -3766,8 +3766,8 @@ static int menu_common_setting_set(unsigned setting, unsigned action)
|
||||
menu_common_setting_push_current_menu(driver.menu->menu_stack, g_settings.audio.filter_dir, setting, driver.menu->selection_ptr, action);
|
||||
break;
|
||||
case MENU_ACTION_START:
|
||||
rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT);
|
||||
*g_settings.audio.dsp_plugin = '\0';
|
||||
rarch_deinit_dsp_filter();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -105,7 +105,9 @@ enum basic_event
|
||||
RARCH_CMD_AUDIO_STOP,
|
||||
RARCH_CMD_AUDIO_START,
|
||||
RARCH_CMD_OVERLAY_INIT,
|
||||
RARCH_CMD_OVERLAY_FREE,
|
||||
RARCH_CMD_OVERLAY_DEINIT,
|
||||
RARCH_CMD_DSP_FILTER_INIT,
|
||||
RARCH_CMD_DSP_FILTER_DEINIT,
|
||||
};
|
||||
|
||||
enum menu_enums
|
||||
|
16
retroarch.c
16
retroarch.c
@ -3221,7 +3221,7 @@ void rarch_main_command(unsigned action)
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CMD_OVERLAY_FREE:
|
||||
case RARCH_CMD_OVERLAY_DEINIT:
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (driver.overlay)
|
||||
input_overlay_free(driver.overlay);
|
||||
@ -3229,6 +3229,20 @@ void rarch_main_command(unsigned action)
|
||||
memset(&driver.overlay_state, 0, sizeof(driver.overlay_state));
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CMD_DSP_FILTER_INIT:
|
||||
rarch_main_command(RARCH_CMD_DSP_FILTER_DEINIT);
|
||||
if (!*g_settings.audio.dsp_plugin)
|
||||
break;
|
||||
|
||||
g_extern.audio_data.dsp = rarch_dsp_filter_new(g_settings.audio.dsp_plugin, g_extern.audio_data.in_rate);
|
||||
if (!g_extern.audio_data.dsp)
|
||||
RARCH_ERR("[DSP]: Failed to initialize DSP filter \"%s\".\n", g_settings.audio.dsp_plugin);
|
||||
break;
|
||||
case RARCH_CMD_DSP_FILTER_DEINIT:
|
||||
if (g_extern.audio_data.dsp)
|
||||
rarch_dsp_filter_free(g_extern.audio_data.dsp);
|
||||
g_extern.audio_data.dsp = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -982,6 +982,7 @@ static void general_write_handler(const void *data)
|
||||
bool has_set_autosave = false;
|
||||
bool has_set_overlay_init = false;
|
||||
bool has_set_overlay_free = false;
|
||||
bool has_set_dsp_init = false;
|
||||
const rarch_setting_t *setting = (const rarch_setting_t*)data;
|
||||
|
||||
if (!setting)
|
||||
@ -1090,8 +1091,7 @@ static void general_write_handler(const void *data)
|
||||
#ifdef HAVE_DYLIB
|
||||
strlcpy(g_settings.audio.dsp_plugin, setting->value.string, sizeof(g_settings.audio.dsp_plugin));
|
||||
#endif
|
||||
rarch_deinit_dsp_filter();
|
||||
rarch_init_dsp_filter();
|
||||
has_set_dsp_init = true;
|
||||
}
|
||||
else if (!strcmp(setting->name, "state_slot"))
|
||||
g_settings.state_slot = *setting->value.integer;
|
||||
@ -1338,9 +1338,11 @@ static void general_write_handler(const void *data)
|
||||
if (has_set_autosave)
|
||||
rarch_main_command(RARCH_CMD_AUTOSAVE);
|
||||
if (has_set_overlay_free)
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_FREE);
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_DEINIT);
|
||||
if (has_set_overlay_init)
|
||||
rarch_main_command(RARCH_CMD_OVERLAY_INIT);
|
||||
if (has_set_dsp_init)
|
||||
rarch_main_command(RARCH_CMD_DSP_FILTER_INIT);
|
||||
}
|
||||
|
||||
#define NEXT (list[index++])
|
||||
|
Loading…
Reference in New Issue
Block a user