Go through settings pointer

This commit is contained in:
twinaphex 2015-03-20 19:48:23 +01:00
parent 0f98407674
commit 6cefa69aa4
6 changed files with 184 additions and 141 deletions

View File

@ -213,8 +213,10 @@ const char* config_get_audio_driver_options(void)
void find_audio_driver(void)
{
driver_t *driver = driver_get_ptr();
int i = find_driver_index("audio_driver", g_settings.audio.driver);
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
int i = find_driver_index("audio_driver", settings->audio.driver);
if (i >= 0)
driver->audio = (const audio_driver_t*)audio_driver_find_handle(i);
@ -222,7 +224,7 @@ void find_audio_driver(void)
{
unsigned d;
RARCH_ERR("Couldn't find any audio driver named \"%s\"\n",
g_settings.audio.driver);
settings->audio.driver);
RARCH_LOG_OUTPUT("Available audio drivers are:\n");
for (d = 0; audio_driver_find_handle(d); d++)
RARCH_LOG_OUTPUT("\t%s\n", audio_driver_find_ident(d));
@ -237,7 +239,8 @@ void find_audio_driver(void)
void uninit_audio(void)
{
driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (driver->audio_data && driver->audio)
driver->audio->free(driver->audio_data);
@ -249,7 +252,7 @@ void uninit_audio(void)
free(g_extern.audio_data.rewind_buf);
g_extern.audio_data.rewind_buf = NULL;
if (!g_settings.audio.enable)
if (!settings->audio.enable)
{
driver->audio_active = false;
return;
@ -272,8 +275,9 @@ void uninit_audio(void)
void init_audio(void)
{
size_t outsamples_max, max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2;
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
audio_convert_init_simd();
@ -283,7 +287,7 @@ void init_audio(void)
/* Accomodate rewind since at some point we might have two full buffers. */
outsamples_max = max_bufsamples * AUDIO_MAX_RATIO *
g_settings.slowmotion_ratio;
settings->slowmotion_ratio;
/* Used for recording even if audio isn't enabled. */
rarch_assert(g_extern.audio_data.conv_outsamples =
@ -300,7 +304,7 @@ void init_audio(void)
malloc(max_bufsamples * sizeof(int16_t)));
g_extern.audio_data.rewind_size = max_bufsamples;
if (!g_settings.audio.enable)
if (!settings->audio.enable)
{
driver->audio_active = false;
return;
@ -312,8 +316,8 @@ void init_audio(void)
{
RARCH_LOG("Starting threaded audio driver ...\n");
if (!rarch_threaded_audio_init(&driver->audio, &driver->audio_data,
*g_settings.audio.device ? g_settings.audio.device : NULL,
g_settings.audio.out_rate, g_settings.audio.latency,
*settings->audio.device ? settings->audio.device : NULL,
settings->audio.out_rate, settings->audio.latency,
driver->audio))
{
RARCH_ERR("Cannot open threaded audio driver ... Exiting ...\n");
@ -323,9 +327,9 @@ void init_audio(void)
else
#endif
{
driver->audio_data = driver->audio->init(*g_settings.audio.device ?
g_settings.audio.device : NULL,
g_settings.audio.out_rate, g_settings.audio.latency);
driver->audio_data = driver->audio->init(*settings->audio.device ?
settings->audio.device : NULL,
settings->audio.out_rate, settings->audio.latency);
}
if (!driver->audio_data)
@ -338,7 +342,7 @@ void init_audio(void)
if (driver->audio_active && driver->audio->use_float(driver->audio_data))
g_extern.audio_data.use_float = true;
if (!g_settings.audio.sync && driver->audio_active)
if (!settings->audio.sync && driver->audio_active)
{
rarch_main_command(RARCH_CMD_AUDIO_SET_NONBLOCKING_STATE);
g_extern.audio_data.chunk_size =
@ -349,20 +353,20 @@ void init_audio(void)
{
/* Should never happen. */
RARCH_WARN("Input rate is invalid (%.3f Hz). Using output rate (%u Hz).\n",
g_extern.audio_data.in_rate, g_settings.audio.out_rate);
g_extern.audio_data.in_rate = g_settings.audio.out_rate;
g_extern.audio_data.in_rate, settings->audio.out_rate);
g_extern.audio_data.in_rate = settings->audio.out_rate;
}
g_extern.audio_data.orig_src_ratio =
g_extern.audio_data.src_ratio =
(double)g_settings.audio.out_rate / g_extern.audio_data.in_rate;
(double)settings->audio.out_rate / g_extern.audio_data.in_rate;
if (!rarch_resampler_realloc(&driver->resampler_data,
&driver->resampler,
g_settings.audio.resampler, g_extern.audio_data.orig_src_ratio))
settings->audio.resampler, g_extern.audio_data.orig_src_ratio))
{
RARCH_ERR("Failed to initialize resampler \"%s\".\n",
g_settings.audio.resampler);
settings->audio.resampler);
driver->audio_active = false;
}
@ -371,14 +375,14 @@ void init_audio(void)
g_extern.audio_data.data_ptr = 0;
rarch_assert(g_settings.audio.out_rate <
rarch_assert(settings->audio.out_rate <
g_extern.audio_data.in_rate * AUDIO_MAX_RATIO);
rarch_assert(g_extern.audio_data.outsamples = (float*)
malloc(outsamples_max * sizeof(float)));
g_extern.audio_data.rate_control = false;
if (!g_extern.system.audio_callback.callback && driver->audio_active &&
g_settings.audio.rate_control)
settings->audio.rate_control)
{
if (driver->audio->buffer_size && driver->audio->write_avail)
{
@ -394,7 +398,7 @@ void init_audio(void)
runloop->measure_data.buffer_free_samples_count = 0;
if (driver->audio_active && !g_settings.audio.mute_enable &&
if (driver->audio_active && !settings->audio.mute_enable &&
g_extern.system.audio_callback.callback)
{
/* Threaded driver is initially stopped. */
@ -404,13 +408,15 @@ void init_audio(void)
bool audio_driver_mute_toggle(void)
{
driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!driver->audio_data || !driver->audio_active)
return false;
g_settings.audio.mute_enable = !g_settings.audio.mute_enable;
settings->audio.mute_enable = !settings->audio.mute_enable;
if (g_settings.audio.mute_enable)
if (settings->audio.mute_enable)
rarch_main_command(RARCH_CMD_AUDIO_STOP);
else if (!rarch_main_command(RARCH_CMD_AUDIO_START))
{
@ -431,9 +437,10 @@ void audio_driver_readjust_input_rate(void)
double direction, adjust;
int half_size, delta_mid;
unsigned write_idx;
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
int avail = 0;
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
avail = driver->audio->write_avail(driver->audio_data);
@ -447,7 +454,7 @@ void audio_driver_readjust_input_rate(void)
half_size = g_extern.audio_data.driver_buffer_size / 2;
delta_mid = avail - half_size;
direction = (double)delta_mid / half_size;
adjust = 1.0 + g_settings.audio.rate_control_delta * direction;
adjust = 1.0 + settings->audio.rate_control_delta * direction;
runloop->measure_data.buffer_free_samples[write_idx] = avail;
g_extern.audio_data.src_ratio = g_extern.audio_data.orig_src_ratio * adjust;

View File

@ -116,8 +116,9 @@ const char* config_get_camera_driver_options(void)
void find_camera_driver(void)
{
driver_t *driver = driver_get_ptr();
int i = find_driver_index("camera_driver", g_settings.camera.driver);
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
int i = find_driver_index("camera_driver", settings->camera.driver);
if (i >= 0)
driver->camera = (const camera_driver_t*)camera_driver_find_handle(i);
@ -125,7 +126,7 @@ void find_camera_driver(void)
{
unsigned d;
RARCH_ERR("Couldn't find any camera driver named \"%s\"\n",
g_settings.camera.driver);
settings->camera.driver);
RARCH_LOG_OUTPUT("Available camera drivers are:\n");
for (d = 0; camera_driver_find_handle(d); d++)
RARCH_LOG_OUTPUT("\t%s\n", camera_driver_find_ident(d));
@ -149,10 +150,12 @@ void find_camera_driver(void)
**/
bool driver_camera_start(void)
{
driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (driver->camera && driver->camera_data && driver->camera->start)
{
if (g_settings.camera.allow)
if (settings->camera.allow)
return driver->camera->start(driver->camera_data);
rarch_main_msg_queue_push(
@ -195,7 +198,8 @@ void driver_camera_poll(void)
void init_camera(void)
{
driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (driver->camera_data)
{
@ -206,12 +210,12 @@ void init_camera(void)
find_camera_driver();
driver->camera_data = driver->camera->init(
*g_settings.camera.device ? g_settings.camera.device : NULL,
*settings->camera.device ? settings->camera.device : NULL,
g_extern.system.camera_callback.caps,
g_settings.camera.width ?
g_settings.camera.width : g_extern.system.camera_callback.width,
g_settings.camera.height ?
g_settings.camera.height : g_extern.system.camera_callback.height);
settings->camera.width ?
settings->camera.width : g_extern.system.camera_callback.width,
settings->camera.height ?
settings->camera.height : g_extern.system.camera_callback.height);
if (!driver->camera_data)
{

View File

@ -323,19 +323,21 @@ static void load_symbols(bool is_dummy)
else
{
#ifdef HAVE_DYNAMIC
settings_t *settings = config_get_ptr();
/* Need to use absolute path for this setting. It can be
* saved to content history, and a relative path would
* break in that scenario. */
path_resolve_realpath(g_settings.libretro,
sizeof(g_settings.libretro));
path_resolve_realpath(settings->libretro,
sizeof(settings->libretro));
RARCH_LOG("Loading dynamic libretro from: \"%s\"\n",
g_settings.libretro);
lib_handle = dylib_load(g_settings.libretro);
settings->libretro);
lib_handle = dylib_load(settings->libretro);
if (!lib_handle)
{
RARCH_ERR("Failed to open dynamic library: \"%s\"\n",
g_settings.libretro);
settings->libretro);
rarch_fail(1, "load_dynamic()");
}
#endif
@ -430,18 +432,20 @@ void init_libretro_sym(bool dummy)
if (!dummy)
{
#ifdef HAVE_DYNAMIC
/* Try to verify that -lretro was not linked in from other modules
* since loading it dynamically and with -l will fail hard. */
function_t sym = dylib_proc(NULL, "retro_init");
settings_t *settings = config_get_ptr();
function_t sym = dylib_proc(NULL, "retro_init");
if (sym)
{
/* Try to verify that -lretro was not linked in from other modules
* since loading it dynamically and with -l will fail hard. */
RARCH_ERR("Serious problem. RetroArch wants to load libretro dyamically, but it is already linked.\n");
RARCH_ERR("This could happen if other modules RetroArch depends on link against libretro directly.\n");
RARCH_ERR("Proceeding could cause a crash. Aborting ...\n");
rarch_fail(1, "init_libretro_sym()");
}
if (!*g_settings.libretro)
if (!*settings->libretro)
{
RARCH_ERR("RetroArch is built for dynamic libretro, but libretro_path is not set. Cannot continue.\n");
rarch_fail(1, "init_libretro_sym()");
@ -568,7 +572,9 @@ static void rarch_log_libretro(enum retro_log_level level,
const char *fmt, ...)
{
va_list vp;
if ((unsigned)level < g_settings.libretro_log_level)
settings_t *settings = config_get_ptr();
if ((unsigned)level < settings->libretro_log_level)
return;
va_start(vp, fmt);
@ -611,7 +617,8 @@ static void rarch_log_libretro(enum retro_log_level level,
bool rarch_environment_cb(unsigned cmd, void *data)
{
unsigned p;
driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (ignore_environment_cb)
return false;
@ -619,9 +626,9 @@ bool rarch_environment_cb(unsigned cmd, void *data)
switch (cmd)
{
case RETRO_ENVIRONMENT_GET_OVERSCAN:
*(bool*)data = !g_settings.video.crop_overscan;
*(bool*)data = !settings->video.crop_overscan;
RARCH_LOG("Environ GET_OVERSCAN: %u\n",
(unsigned)!g_settings.video.crop_overscan);
(unsigned)!settings->video.crop_overscan);
break;
case RETRO_ENVIRONMENT_GET_CAN_DUPE:
@ -661,7 +668,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
const struct retro_variable *vars =
(const struct retro_variable*)data;
const char *options_path = g_settings.core_options_path;
const char *options_path = settings->core_options_path;
char buf[PATH_MAX_LENGTH];
if (!*options_path && *g_extern.config_path)
{
@ -686,7 +693,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{
unsigned rotation = *(const unsigned*)data;
RARCH_LOG("Environ SET_ROTATION: %u\n", rotation);
if (!g_settings.video.allow_rotate)
if (!settings->video.allow_rotate)
break;
g_extern.system.rotation = rotation;
@ -714,10 +721,10 @@ bool rarch_environment_cb(unsigned cmd, void *data)
break;
case RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY:
*(const char**)data = *g_settings.system_directory ?
g_settings.system_directory : NULL;
*(const char**)data = *settings->system_directory ?
settings->system_directory : NULL;
RARCH_LOG("Environ SYSTEM_DIRECTORY: \"%s\".\n",
g_settings.system_directory);
settings->system_directory);
break;
case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY:
@ -728,16 +735,16 @@ bool rarch_environment_cb(unsigned cmd, void *data)
break;
case RETRO_ENVIRONMENT_GET_USERNAME:
*(const char**)data = *g_settings.username ?
g_settings.username : NULL;
*(const char**)data = *settings->username ?
settings->username : NULL;
RARCH_LOG("Environ GET_USERNAME: \"%s\".\n",
g_settings.username);
settings->username);
break;
case RETRO_ENVIRONMENT_GET_LANGUAGE:
*(unsigned *)data = g_settings.user_language;
*(unsigned *)data = settings->user_language;
RARCH_LOG("Environ GET_LANGUAGE: \"%u\".\n",
g_settings.user_language);
settings->user_language);
break;
case RETRO_ENVIRONMENT_SET_PIXEL_FORMAT:
@ -837,7 +844,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
};
RARCH_LOG("Environ SET_INPUT_DESCRIPTORS:\n");
for (p = 0; p < g_settings.input.max_users; p++)
for (p = 0; p < settings->input.max_users; p++)
{
for (retro_id = 0; retro_id < RARCH_FIRST_CUSTOM_BIND; retro_id++)
{
@ -956,7 +963,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{
const char **path = (const char**)data;
#ifdef HAVE_DYNAMIC
*path = g_settings.libretro;
*path = settings->libretro;
#else
*path = NULL;
#endif
@ -1094,10 +1101,10 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{
const char **dir = (const char**)data;
*dir = *g_settings.core_assets_directory ?
g_settings.core_assets_directory : NULL;
*dir = *settings->core_assets_directory ?
settings->core_assets_directory : NULL;
RARCH_LOG("Environ CORE_ASSETS_DIRECTORY: \"%s\".\n",
g_settings.core_assets_directory);
settings->core_assets_directory);
break;
}
@ -1205,8 +1212,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
RARCH_LOG("Environ (Private) SET_LIBRETRO_PATH.\n");
if (path_file_exists((const char*)data))
strlcpy(g_settings.libretro, (const char*)data,
sizeof(g_settings.libretro));
strlcpy(settings->libretro, (const char*)data,
sizeof(settings->libretro));
else
return false;
break;

View File

@ -76,6 +76,7 @@ static bool video_frame_filter(const void *data,
unsigned *output_width, unsigned *output_height,
unsigned *output_pitch)
{
settings_t *settings = config_get_ptr();
RARCH_PERFORMANCE_INIT(softfilter_process);
if (!g_extern.filter.filter)
@ -94,7 +95,7 @@ static bool video_frame_filter(const void *data,
data, width, height, pitch);
RARCH_PERFORMANCE_STOP(softfilter_process);
if (g_settings.video.post_filter_record)
if (settings->video.post_filter_record)
recording_dump_frame(g_extern.filter.buffer,
*output_width, *output_height, *output_pitch);
@ -115,8 +116,9 @@ static void video_frame(const void *data, unsigned width,
{
unsigned output_width = 0, output_height = 0, output_pitch = 0;
const char *msg = NULL;
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!driver->video_active)
return;
@ -137,7 +139,7 @@ static void video_frame(const void *data, unsigned width,
* for best possible scheduling.
*/
if ((!g_extern.filter.filter
|| !g_settings.video.post_filter_record || !data
|| !settings->video.post_filter_record || !data
|| g_extern.record.gpu_buffer)
)
recording_dump_frame(data, width, height, pitch);
@ -183,6 +185,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples)
struct rarch_dsp_data dsp_data = {0};
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (driver->recording_data)
{
@ -194,7 +197,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples)
driver->recording->push_audio(driver->recording_data, &ffemu_data);
}
if (runloop->is_paused || g_settings.audio.mute_enable)
if (runloop->is_paused || settings->audio.mute_enable)
return true;
if (!driver->audio_active || !g_extern.audio_data.data)
return false;
@ -232,7 +235,7 @@ bool retro_flush_audio(const int16_t *data, size_t samples)
src_data.ratio = g_extern.audio_data.src_ratio;
if (runloop->is_slowmotion)
src_data.ratio *= g_settings.slowmotion_ratio;
src_data.ratio *= settings->slowmotion_ratio;
RARCH_PERFORMANCE_INIT(resampler_proc);
RARCH_PERFORMANCE_START(resampler_proc);
@ -362,14 +365,16 @@ static size_t audio_sample_batch_rewind(const int16_t *data, size_t frames)
**/
static bool input_apply_turbo(unsigned port, unsigned id, bool res)
{
settings_t *settings = config_get_ptr();
if (res && g_extern.turbo_frame_enable[port])
g_extern.turbo_enable[port] |= (1 << id);
else if (!res)
g_extern.turbo_enable[port] &= ~(1 << id);
if (g_extern.turbo_enable[port] & (1 << id))
return res && ((g_extern.turbo_count % g_settings.input.turbo_period)
< g_settings.input.turbo_duty_cycle);
return res && ((g_extern.turbo_count % settings->input.turbo_period)
< settings->input.turbo_duty_cycle);
return res;
}
@ -389,6 +394,7 @@ static int16_t input_state(unsigned port, unsigned device,
unsigned idx, unsigned id)
{
int16_t res = 0;
settings_t *settings = config_get_ptr();
static const struct retro_keybind *libretro_input_binds[MAX_USERS] = {
g_settings.input.binds[0],
@ -421,10 +427,10 @@ static int16_t input_state(unsigned port, unsigned device,
g_extern.bsv.movie_end = true;
}
if (g_settings.input.remap_binds_enable)
if (settings->input.remap_binds_enable)
{
if (id < RARCH_FIRST_CUSTOM_BIND)
id = g_settings.input.remap_ids[port][id];
id = settings->input.remap_ids[port][id];
}
if (!driver->block_libretro_input)
@ -495,7 +501,8 @@ static INLINE void input_poll_overlay(input_overlay_t *overlay_device, float opa
unsigned i, j, device;
uint16_t key_mod = 0;
bool polled = false;
driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (overlay_device->state != OVERLAY_STATUS_ALIVE)
return;
@ -582,7 +589,7 @@ static INLINE void input_poll_overlay(input_overlay_t *overlay_device, float opa
/* Check for analog_dpad_mode.
* Map analogs to d-pad buttons when configured. */
switch (g_settings.input.analog_dpad_mode[0])
switch (settings->input.analog_dpad_mode[0])
{
case ANALOG_DPAD_LSTICK:
case ANALOG_DPAD_RSTICK:
@ -590,19 +597,19 @@ static INLINE void input_poll_overlay(input_overlay_t *overlay_device, float opa
float analog_x, analog_y;
unsigned analog_base = 2;
if (g_settings.input.analog_dpad_mode[0] == ANALOG_DPAD_LSTICK)
if (settings->input.analog_dpad_mode[0] == ANALOG_DPAD_LSTICK)
analog_base = 0;
analog_x = (float)driver->overlay_state.analog[analog_base + 0] / 0x7fff;
analog_y = (float)driver->overlay_state.analog[analog_base + 1] / 0x7fff;
if (analog_x <= -g_settings.input.axis_threshold)
if (analog_x <= -settings->input.axis_threshold)
driver->overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT);
if (analog_x >= g_settings.input.axis_threshold)
if (analog_x >= settings->input.axis_threshold)
driver->overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT);
if (analog_y <= -g_settings.input.axis_threshold)
if (analog_y <= -settings->input.axis_threshold)
driver->overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_UP);
if (analog_y >= g_settings.input.axis_threshold)
if (analog_y >= settings->input.axis_threshold)
driver->overlay_state.buttons |= (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN);
break;
}
@ -625,13 +632,15 @@ static INLINE void input_poll_overlay(input_overlay_t *overlay_device, float opa
**/
static void input_poll(void)
{
driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
driver->input->poll(driver->input_data);
#ifdef HAVE_OVERLAY
if (driver->overlay)
input_poll_overlay(driver->overlay, g_settings.input.overlay_opacity);
input_poll_overlay(driver->overlay,
settings->input.overlay_opacity);
#endif
#ifdef HAVE_COMMAND

115
runloop.c
View File

@ -56,16 +56,17 @@ static struct runloop *g_runloop;
static void set_volume(float gain)
{
char msg[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
g_settings.audio.volume += gain;
g_settings.audio.volume = max(g_settings.audio.volume, -80.0f);
g_settings.audio.volume = min(g_settings.audio.volume, 12.0f);
settings->audio.volume += gain;
settings->audio.volume = max(settings->audio.volume, -80.0f);
settings->audio.volume = min(settings->audio.volume, 12.0f);
snprintf(msg, sizeof(msg), "Volume: %.1f dB", g_settings.audio.volume);
snprintf(msg, sizeof(msg), "Volume: %.1f dB", settings->audio.volume);
rarch_main_msg_queue_push(msg, 1, 180, true);
RARCH_LOG("%s\n", msg);
g_extern.audio_data.volume_gain = db_to_gain(g_settings.audio.volume);
g_extern.audio_data.volume_gain = db_to_gain(settings->audio.volume);
}
/**
@ -85,11 +86,12 @@ static bool check_pause(bool pressed, bool frameadvance_pressed)
bool focus = true;
unsigned cmd = RARCH_CMD_NONE;
bool old_is_paused = runloop->is_paused;
settings_t *settings = config_get_ptr();
/* FRAMEADVANCE will set us into pause mode. */
pressed |= !runloop->is_paused && frameadvance_pressed;
if (g_settings.pause_nonactive)
if (settings->pause_nonactive)
focus = video_driver_has_focus();
if (focus && pressed)
@ -167,20 +169,21 @@ static void check_fast_forward_button(bool fastforward_pressed,
static void check_stateslots(bool pressed_increase, bool pressed_decrease)
{
char msg[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
/* Save state slots */
if (pressed_increase)
g_settings.state_slot++;
settings->state_slot++;
else if (pressed_decrease)
{
if (g_settings.state_slot > 0)
g_settings.state_slot--;
if (settings->state_slot > 0)
settings->state_slot--;
}
else
return;
snprintf(msg, sizeof(msg), "State slot: %d",
g_settings.state_slot);
settings->state_slot);
rarch_main_msg_queue_push(msg, 1, 180, true);
@ -259,9 +262,10 @@ static void check_rewind(bool pressed)
else
{
static unsigned cnt = 0;
settings_t *settings = config_get_ptr();
cnt = (cnt + 1) % (g_settings.rewind_granularity ?
g_settings.rewind_granularity : 1); /* Avoid possible SIGFPE. */
cnt = (cnt + 1) % (settings->rewind_granularity ?
settings->rewind_granularity : 1); /* Avoid possible SIGFPE. */
if ((cnt == 0) || g_extern.bsv.movie)
{
@ -288,14 +292,15 @@ static void check_rewind(bool pressed)
**/
static void check_slowmotion(bool pressed)
{
runloop_t *runloop = rarch_main_get_ptr();
runloop_t *runloop = rarch_main_get_ptr();
settings_t *settings = config_get_ptr();
runloop->is_slowmotion = pressed;
if (!runloop->is_slowmotion)
return;
if (g_settings.video.black_frame_insertion)
if (settings->video.black_frame_insertion)
rarch_render_cached_frame();
rarch_main_msg_queue_push(g_extern.rewind.frame_is_reverse ?
@ -306,16 +311,17 @@ static bool check_movie_init(void)
{
char path[PATH_MAX_LENGTH], msg[PATH_MAX_LENGTH];
bool ret = true;
settings_t *settings = config_get_ptr();
if (g_extern.bsv.movie)
return false;
g_settings.rewind_granularity = 1;
settings->rewind_granularity = 1;
if (g_settings.state_slot > 0)
if (settings->state_slot > 0)
{
snprintf(path, sizeof(path), "%s%d.bsv",
g_extern.bsv.movie_path, g_settings.state_slot);
g_extern.bsv.movie_path, settings->state_slot);
}
else
{
@ -676,18 +682,20 @@ static INLINE int time_to_exit(retro_input_t input)
**/
static void rarch_update_frame_time(void)
{
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
retro_time_t curr_time = rarch_get_time_usec();
retro_time_t delta = curr_time - g_extern.system.frame_time_last;
bool is_locked_fps = runloop->is_paused || driver->nonblock_state;
runloop_t *runloop = rarch_main_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
retro_time_t curr_time = rarch_get_time_usec();
retro_time_t delta = curr_time - g_extern.system.frame_time_last;
bool is_locked_fps = runloop->is_paused || driver->nonblock_state;
is_locked_fps |= !!driver->recording_data;
if (!g_extern.system.frame_time_last || is_locked_fps)
delta = g_extern.system.frame_time.reference;
if (!is_locked_fps && runloop->is_slowmotion)
delta /= g_settings.slowmotion_ratio;
delta /= settings->slowmotion_ratio;
g_extern.system.frame_time_last = curr_time;
@ -707,11 +715,12 @@ static void rarch_limit_frame_time(void)
{
double effective_fps, mft_f;
retro_time_t current, target = 0, to_sleep_ms = 0;
runloop_t *runloop = rarch_main_get_ptr();
runloop_t *runloop = rarch_main_get_ptr();
settings_t *settings = config_get_ptr();
current = rarch_get_time_usec();
effective_fps = g_extern.system.av_info.timing.fps
* g_settings.fastforward_ratio;
* settings->fastforward_ratio;
mft_f = 1000000.0f / effective_fps;
runloop->frames.limit.minimum_time = (retro_time_t) roundf(mft_f);
@ -800,8 +809,9 @@ static INLINE retro_input_t input_keys_pressed(void)
g_settings.input.binds[14],
g_settings.input.binds[15],
};
retro_input_t ret = 0;
driver_t *driver = driver_get_ptr();
retro_input_t ret = 0;
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!driver->input || !driver->input_data)
return 0;
@ -812,19 +822,19 @@ static INLINE retro_input_t input_keys_pressed(void)
driver->input->key_pressed(driver->input_data,
RARCH_ENABLE_HOTKEY));
for (i = 0; i < g_settings.input.max_users; i++)
for (i = 0; i < settings->input.max_users; i++)
{
input_push_analog_dpad(g_settings.input.binds[i],
g_settings.input.analog_dpad_mode[i]);
input_push_analog_dpad(g_settings.input.autoconf_binds[i],
g_settings.input.analog_dpad_mode[i]);
input_push_analog_dpad(settings->input.binds[i],
settings->input.analog_dpad_mode[i]);
input_push_analog_dpad(settings->input.autoconf_binds[i],
settings->input.analog_dpad_mode[i]);
g_extern.turbo_frame_enable[i] = 0;
}
if (!driver->block_libretro_input)
{
for (i = 0; i < g_settings.input.max_users; i++)
for (i = 0; i < settings->input.max_users; i++)
{
g_extern.turbo_frame_enable[i] =
driver->input->input_state(driver->input_data, binds, i,
@ -834,10 +844,10 @@ static INLINE retro_input_t input_keys_pressed(void)
ret = input_driver_keys_pressed();
for (i = 0; i < g_settings.input.max_users; i++)
for (i = 0; i < settings->input.max_users; i++)
{
input_pop_analog_dpad(g_settings.input.binds[i]);
input_pop_analog_dpad(g_settings.input.autoconf_binds[i]);
input_pop_analog_dpad(settings->input.binds[i]);
input_pop_analog_dpad(settings->input.autoconf_binds[i]);
}
return ret;
@ -878,8 +888,10 @@ static bool input_flush(retro_input_t *input)
**/
static int rarch_main_iterate_quit(void)
{
settings_t *settings = config_get_ptr();
if (g_extern.core_shutdown_initiated
&& g_settings.load_dummy_on_core_shutdown)
&& settings->load_dummy_on_core_shutdown)
{
rarch_main_data_deinit();
if (!rarch_main_command(RARCH_CMD_PREPARE_DUMMY))
@ -1010,6 +1022,7 @@ int rarch_main_iterate(void)
retro_input_t input = input_keys_pressed();
last_input = input;
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (driver->flushing_input)
driver->flushing_input = (input) ? input_flush(&input) : false;
@ -1038,7 +1051,7 @@ int rarch_main_iterate(void)
if (menu_iterate(input, old_input, trigger_input) == -1)
rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING_FINISHED);
if (!input && g_settings.menu.pause_libretro)
if (!input && settings->menu.pause_libretro)
ret = 1;
goto success;
}
@ -1075,31 +1088,31 @@ int rarch_main_iterate(void)
driver_camera_poll();
/* Update binds for analog dpad modes. */
for (i = 0; i < g_settings.input.max_users; i++)
for (i = 0; i < settings->input.max_users; i++)
{
if (!g_settings.input.analog_dpad_mode[i])
if (!settings->input.analog_dpad_mode[i])
continue;
input_push_analog_dpad(g_settings.input.binds[i],
g_settings.input.analog_dpad_mode[i]);
input_push_analog_dpad(g_settings.input.autoconf_binds[i],
g_settings.input.analog_dpad_mode[i]);
input_push_analog_dpad(settings->input.binds[i],
settings->input.analog_dpad_mode[i]);
input_push_analog_dpad(settings->input.autoconf_binds[i],
settings->input.analog_dpad_mode[i]);
}
if ((g_settings.video.frame_delay > 0) && !driver->nonblock_state)
rarch_sleep(g_settings.video.frame_delay);
if ((settings->video.frame_delay > 0) && !driver->nonblock_state)
rarch_sleep(settings->video.frame_delay);
/* Run libretro for one frame. */
pretro_run();
for (i = 0; i < g_settings.input.max_users; i++)
for (i = 0; i < settings->input.max_users; i++)
{
if (!g_settings.input.analog_dpad_mode[i])
if (!settings->input.analog_dpad_mode[i])
continue;
input_pop_analog_dpad(g_settings.input.binds[i]);
input_pop_analog_dpad(g_settings.input.autoconf_binds[i]);
input_pop_analog_dpad(settings->input.binds[i]);
input_pop_analog_dpad(settings->input.autoconf_binds[i]);
}
if (g_extern.bsv.movie)
@ -1115,7 +1128,7 @@ int rarch_main_iterate(void)
#endif
success:
if (g_settings.fastforward_ratio_throttle_enable)
if (settings->fastforward_ratio_throttle_enable)
rarch_limit_frame_time();
return ret;

View File

@ -871,9 +871,12 @@ static void rarch_main_data_thread_init(void)
void rarch_main_data_iterate(void)
{
data_runloop_t *data_runloop = rarch_main_data_get_ptr();
settings_t *settings = config_get_ptr();
(void)settings;
#ifdef HAVE_THREADS
#if 0
if (g_settings.menu.threaded_data_runloop_enable)
if (settings->menu.threaded_data_runloop_enable)
{
switch (data_runloop->thread_code)
{