mirror of
https://github.com/libretro/RetroArch
synced 2025-04-24 15:02:35 +00:00
Only need to grab settings pointer from within audio_driver_flush
now when setting slowmotion
This commit is contained in:
parent
097515fa63
commit
99e7cb7d75
@ -122,41 +122,43 @@ static size_t audio_driver_chunk_block_size = 0;
|
|||||||
|
|
||||||
static size_t audio_driver_rewind_ptr = 0;
|
static size_t audio_driver_rewind_ptr = 0;
|
||||||
static size_t audio_driver_rewind_size = 0;
|
static size_t audio_driver_rewind_size = 0;
|
||||||
static int16_t *audio_driver_rewind_buf = NULL;
|
|
||||||
|
|
||||||
static float *audio_driver_input_data = NULL;
|
static int16_t *audio_driver_rewind_buf = NULL;
|
||||||
|
static int16_t *audio_driver_output_samples_conv_buf = NULL;
|
||||||
|
|
||||||
static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT];
|
static unsigned audio_driver_free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT];
|
||||||
static uint64_t audio_driver_free_samples_count = 0;
|
static uint64_t audio_driver_free_samples_count = 0;
|
||||||
|
|
||||||
static float *audio_driver_output_samples_buf = NULL;
|
|
||||||
static int16_t *audio_driver_output_samples_conv_buf = NULL;
|
|
||||||
|
|
||||||
static float audio_driver_volume_gain = 0.0f;
|
|
||||||
|
|
||||||
static size_t audio_driver_buffer_size = 0;
|
static size_t audio_driver_buffer_size = 0;
|
||||||
static size_t audio_driver_data_ptr = 0;
|
static size_t audio_driver_data_ptr = 0;
|
||||||
|
|
||||||
static bool audio_driver_control = false;
|
static bool audio_driver_control = false;
|
||||||
|
static bool audio_driver_mute_enable = false;
|
||||||
|
static bool audio_driver_use_float = false;
|
||||||
|
static bool audio_driver_active = false;
|
||||||
|
static bool audio_driver_data_own = false;
|
||||||
|
static bool audio_mixer_active = false;
|
||||||
|
|
||||||
|
static float audio_driver_rate_control_delta = 0.0f;
|
||||||
static float audio_driver_input = 0.0f;
|
static float audio_driver_input = 0.0f;
|
||||||
|
static float audio_driver_volume_gain = 0.0f;
|
||||||
|
|
||||||
|
static float *audio_driver_input_data = NULL;
|
||||||
|
static float *audio_driver_output_samples_buf = NULL;
|
||||||
|
|
||||||
static double audio_source_ratio_original = 0.0f;
|
static double audio_source_ratio_original = 0.0f;
|
||||||
static double audio_source_ratio_current = 0.0f;
|
static double audio_source_ratio_current = 0.0f;
|
||||||
|
|
||||||
static struct retro_audio_callback audio_callback = {0};
|
static struct retro_audio_callback audio_callback = {0};
|
||||||
|
|
||||||
static retro_dsp_filter_t *audio_driver_dsp = NULL;
|
static retro_dsp_filter_t *audio_driver_dsp = NULL;
|
||||||
static struct string_list *audio_driver_devices_list = NULL;
|
static struct string_list *audio_driver_devices_list = NULL;
|
||||||
static const retro_resampler_t *audio_driver_resampler = NULL;
|
static const retro_resampler_t *audio_driver_resampler = NULL;
|
||||||
|
|
||||||
static void *audio_driver_resampler_data = NULL;
|
static void *audio_driver_resampler_data = NULL;
|
||||||
static const audio_driver_t *current_audio = NULL;
|
static const audio_driver_t *current_audio = NULL;
|
||||||
static void *audio_driver_context_audio_data = NULL;
|
static void *audio_driver_context_audio_data = NULL;
|
||||||
|
|
||||||
static bool audio_driver_mute_enable = false;
|
|
||||||
static bool audio_driver_use_float = false;
|
|
||||||
static bool audio_driver_active = false;
|
|
||||||
static bool audio_driver_data_own = false;
|
|
||||||
|
|
||||||
static bool audio_mixer_active = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* compute_audio_buffer_statistics:
|
* compute_audio_buffer_statistics:
|
||||||
*
|
*
|
||||||
@ -518,7 +520,6 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
|
|||||||
bool is_slowmotion = false;
|
bool is_slowmotion = false;
|
||||||
const void *output_data = NULL;
|
const void *output_data = NULL;
|
||||||
unsigned output_frames = 0;
|
unsigned output_frames = 0;
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
|
|
||||||
src_data.data_in = NULL;
|
src_data.data_in = NULL;
|
||||||
src_data.data_out = NULL;
|
src_data.data_out = NULL;
|
||||||
@ -577,7 +578,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
|
|||||||
(int)current_audio->write_avail(audio_driver_context_audio_data);
|
(int)current_audio->write_avail(audio_driver_context_audio_data);
|
||||||
int delta_mid = avail - half_size;
|
int delta_mid = avail - half_size;
|
||||||
double direction = (double)delta_mid / half_size;
|
double direction = (double)delta_mid / half_size;
|
||||||
double adjust = 1.0 + settings->floats.audio_rate_control_delta * direction;
|
double adjust = 1.0 + audio_driver_rate_control_delta * direction;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
RARCH_LOG_OUTPUT("[Audio]: Audio buffer is %u%% full\n",
|
RARCH_LOG_OUTPUT("[Audio]: Audio buffer is %u%% full\n",
|
||||||
@ -599,7 +600,10 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
|
|||||||
src_data.ratio = audio_source_ratio_current;
|
src_data.ratio = audio_source_ratio_current;
|
||||||
|
|
||||||
if (is_slowmotion)
|
if (is_slowmotion)
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
src_data.ratio *= settings->floats.slowmotion_ratio;
|
src_data.ratio *= settings->floats.slowmotion_ratio;
|
||||||
|
}
|
||||||
|
|
||||||
audio_driver_resampler->process(audio_driver_resampler_data, &src_data);
|
audio_driver_resampler->process(audio_driver_resampler_data, &src_data);
|
||||||
|
|
||||||
@ -1049,6 +1053,33 @@ void audio_driver_destroy(void)
|
|||||||
current_audio = NULL;
|
current_audio = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void audio_set_float(enum audio_action action, float val)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case AUDIO_ACTION_RATE_CONTROL_DELTA:
|
||||||
|
audio_driver_rate_control_delta = val;
|
||||||
|
break;
|
||||||
|
case AUDIO_ACTION_NONE:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float *audio_get_float_ptr(enum audio_action action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case AUDIO_ACTION_RATE_CONTROL_DELTA:
|
||||||
|
return &audio_driver_rate_control_delta;
|
||||||
|
case AUDIO_ACTION_NONE:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
bool *audio_get_bool_ptr(enum audio_action action)
|
bool *audio_get_bool_ptr(enum audio_action action)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
@ -1056,6 +1087,7 @@ bool *audio_get_bool_ptr(enum audio_action action)
|
|||||||
case AUDIO_ACTION_MUTE_ENABLE:
|
case AUDIO_ACTION_MUTE_ENABLE:
|
||||||
return &audio_driver_mute_enable;
|
return &audio_driver_mute_enable;
|
||||||
case AUDIO_ACTION_NONE:
|
case AUDIO_ACTION_NONE:
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ RETRO_BEGIN_DECLS
|
|||||||
enum audio_action
|
enum audio_action
|
||||||
{
|
{
|
||||||
AUDIO_ACTION_NONE = 0,
|
AUDIO_ACTION_NONE = 0,
|
||||||
|
AUDIO_ACTION_RATE_CONTROL_DELTA,
|
||||||
AUDIO_ACTION_MUTE_ENABLE
|
AUDIO_ACTION_MUTE_ENABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -215,6 +216,10 @@ void audio_driver_unset_callback(void);
|
|||||||
|
|
||||||
void audio_driver_frame_is_reverse(void);
|
void audio_driver_frame_is_reverse(void);
|
||||||
|
|
||||||
|
void audio_set_float(enum audio_action action, float val);
|
||||||
|
|
||||||
|
float *audio_get_float_ptr(enum audio_action action);
|
||||||
|
|
||||||
bool *audio_get_bool_ptr(enum audio_action action);
|
bool *audio_get_bool_ptr(enum audio_action action);
|
||||||
|
|
||||||
bool audio_driver_deinit(void);
|
bool audio_driver_deinit(void);
|
||||||
|
@ -1266,7 +1266,7 @@ static struct config_float_setting *populate_settings_float(settings_t *settings
|
|||||||
SETTING_FLOAT("video_aspect_ratio", &settings->floats.video_aspect_ratio, true, aspect_ratio, false);
|
SETTING_FLOAT("video_aspect_ratio", &settings->floats.video_aspect_ratio, true, aspect_ratio, false);
|
||||||
SETTING_FLOAT("video_scale", &settings->floats.video_scale, false, 0.0f, false);
|
SETTING_FLOAT("video_scale", &settings->floats.video_scale, false, 0.0f, false);
|
||||||
SETTING_FLOAT("video_refresh_rate", &settings->floats.video_refresh_rate, true, refresh_rate, false);
|
SETTING_FLOAT("video_refresh_rate", &settings->floats.video_refresh_rate, true, refresh_rate, false);
|
||||||
SETTING_FLOAT("audio_rate_control_delta", &settings->floats.audio_rate_control_delta, true, rate_control_delta, false);
|
SETTING_FLOAT("audio_rate_control_delta", audio_get_float_ptr(AUDIO_ACTION_RATE_CONTROL_DELTA), true, rate_control_delta, false);
|
||||||
SETTING_FLOAT("audio_max_timing_skew", &settings->floats.audio_max_timing_skew, true, max_timing_skew, false);
|
SETTING_FLOAT("audio_max_timing_skew", &settings->floats.audio_max_timing_skew, true, max_timing_skew, false);
|
||||||
SETTING_FLOAT("audio_volume", &settings->floats.audio_volume, true, audio_volume, false);
|
SETTING_FLOAT("audio_volume", &settings->floats.audio_volume, true, audio_volume, false);
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
|
@ -228,7 +228,6 @@ typedef struct settings
|
|||||||
float menu_footer_opacity;
|
float menu_footer_opacity;
|
||||||
float menu_header_opacity;
|
float menu_header_opacity;
|
||||||
|
|
||||||
float audio_rate_control_delta;
|
|
||||||
float audio_max_timing_skew;
|
float audio_max_timing_skew;
|
||||||
float audio_volume; /* dB scale. */
|
float audio_volume; /* dB scale. */
|
||||||
|
|
||||||
|
@ -1478,16 +1478,16 @@ void general_read_handler(void *data)
|
|||||||
switch (setting->enum_idx)
|
switch (setting->enum_idx)
|
||||||
{
|
{
|
||||||
case MENU_ENUM_LABEL_AUDIO_RATE_CONTROL_DELTA:
|
case MENU_ENUM_LABEL_AUDIO_RATE_CONTROL_DELTA:
|
||||||
*setting->value.target.fraction = settings->floats.audio_rate_control_delta;
|
*setting->value.target.fraction = *(audio_get_float_ptr(AUDIO_ACTION_RATE_CONTROL_DELTA));
|
||||||
if (*setting->value.target.fraction < 0.0005)
|
if (*setting->value.target.fraction < 0.0005)
|
||||||
{
|
{
|
||||||
configuration_set_bool(settings, settings->bools.audio_rate_control, false);
|
configuration_set_bool(settings, settings->bools.audio_rate_control, false);
|
||||||
settings->floats.audio_rate_control_delta = 0.0;
|
audio_set_float(AUDIO_ACTION_RATE_CONTROL_DELTA, 0.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
configuration_set_bool(settings, settings->bools.audio_rate_control, true);
|
configuration_set_bool(settings, settings->bools.audio_rate_control, true);
|
||||||
settings->floats.audio_rate_control_delta = *setting->value.target.fraction;
|
audio_set_float(AUDIO_ACTION_RATE_CONTROL_DELTA, *setting->value.target.fraction);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_ENUM_LABEL_AUDIO_MAX_TIMING_SKEW:
|
case MENU_ENUM_LABEL_AUDIO_MAX_TIMING_SKEW:
|
||||||
@ -1600,12 +1600,12 @@ void general_write_handler(void *data)
|
|||||||
if (*setting->value.target.fraction < 0.0005)
|
if (*setting->value.target.fraction < 0.0005)
|
||||||
{
|
{
|
||||||
configuration_set_bool(settings, settings->bools.audio_rate_control, false);
|
configuration_set_bool(settings, settings->bools.audio_rate_control, false);
|
||||||
settings->floats.audio_rate_control_delta = 0.0;
|
audio_set_float(AUDIO_ACTION_RATE_CONTROL_DELTA, 0.0f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
configuration_set_bool(settings, settings->bools.audio_rate_control, true);
|
configuration_set_bool(settings, settings->bools.audio_rate_control, true);
|
||||||
settings->floats.audio_rate_control_delta = *setting->value.target.fraction;
|
audio_set_float(AUDIO_ACTION_RATE_CONTROL_DELTA, *setting->value.target.fraction);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_ENUM_LABEL_VIDEO_REFRESH_RATE_AUTO:
|
case MENU_ENUM_LABEL_VIDEO_REFRESH_RATE_AUTO:
|
||||||
@ -3853,7 +3853,7 @@ static bool setting_append_list(
|
|||||||
|
|
||||||
CONFIG_FLOAT(
|
CONFIG_FLOAT(
|
||||||
list, list_info,
|
list, list_info,
|
||||||
&settings->floats.audio_rate_control_delta,
|
audio_get_float_ptr(AUDIO_ACTION_RATE_CONTROL_DELTA),
|
||||||
MENU_ENUM_LABEL_AUDIO_RATE_CONTROL_DELTA,
|
MENU_ENUM_LABEL_AUDIO_RATE_CONTROL_DELTA,
|
||||||
MENU_ENUM_LABEL_VALUE_AUDIO_RATE_CONTROL_DELTA,
|
MENU_ENUM_LABEL_VALUE_AUDIO_RATE_CONTROL_DELTA,
|
||||||
rate_control_delta,
|
rate_control_delta,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user