Skip to content

Commit

Permalink
Move bool settings
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Apr 28, 2017
1 parent 9e7ac43 commit 3e24672
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 33 deletions.
22 changes: 12 additions & 10 deletions audio/audio_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static bool audio_driver_deinit_internal(void)

audio_driver_rewind_size = 0;

if (settings && !settings->audio.enable)
if (settings && !settings->bools.audio_enable)
{
audio_driver_active = false;
return false;
Expand Down Expand Up @@ -338,7 +338,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
audio_driver_rewind_buf = rewind_buf;
audio_driver_rewind_size = max_bufsamples;

if (!settings->audio.enable)
if (!settings->bools.audio_enable)
{
audio_driver_active = false;
return false;
Expand Down Expand Up @@ -368,7 +368,8 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
audio_driver_context_audio_data =
current_audio->init(*settings->audio.device ?
settings->audio.device : NULL,
settings->audio.out_rate, settings->audio.latency,
settings->audio.out_rate,
settings->audio.latency,
settings->audio.block_frames,
&new_rate);
}
Expand All @@ -389,7 +390,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
&& current_audio->use_float(audio_driver_context_audio_data))
audio_driver_use_float = true;

if (!settings->audio.sync && audio_driver_active)
if (!settings->bools.audio_sync && audio_driver_active)
{
command_event(CMD_EVENT_AUDIO_SET_NONBLOCKING_STATE, NULL);
audio_driver_chunk_size = audio_driver_chunk_nonblock_size;
Expand Down Expand Up @@ -442,7 +443,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited)
if (
!audio_cb_inited
&& audio_driver_active
&& settings->audio.rate_control
&& settings->bools.audio_rate_control
)
{
/* Audio rate control requires write_avail
Expand Down Expand Up @@ -481,8 +482,9 @@ void audio_driver_set_nonblocking_state(bool enable)
audio_driver_active
&& audio_driver_context_audio_data
)
current_audio->set_nonblock_state(audio_driver_context_audio_data,
settings->audio.sync ? enable : true);
current_audio->set_nonblock_state(
audio_driver_context_audio_data,
settings->bools.audio_sync ? enable : true);

audio_driver_chunk_size = enable ?
audio_driver_chunk_nonblock_size :
Expand Down Expand Up @@ -523,7 +525,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples)
runloop_get_status(&is_paused, &is_idle, &is_slowmotion,
&is_perfcnt_enable);

if (is_paused || settings->audio.mute_enable)
if (is_paused || settings->bools.audio_mute_enable)
return true;
if (!audio_driver_active || !audio_driver_input_data)
return false;
Expand Down Expand Up @@ -932,14 +934,14 @@ bool audio_driver_has_callback(void)
bool audio_driver_toggle_mute(void)
{
settings_t *settings = config_get_ptr();
bool new_mute_state = !settings->audio.mute_enable;
bool new_mute_state = !settings->bools.audio_mute_enable;
if (!audio_driver_context_audio_data)
return false;
if (!audio_driver_active)
return false;

configuration_set_bool(settings,
settings->audio.mute_enable, new_mute_state);
settings->bools.audio_mute_enable, new_mute_state);

if (new_mute_state)
command_event(CMD_EVENT_AUDIO_STOP, NULL);
Expand Down
4 changes: 2 additions & 2 deletions audio/drivers/wasapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,10 @@ static void *wasapi_init(const char *dev_id, unsigned rate, unsigned latency,
UINT32 frame_count = 0;
BYTE *dest = NULL;
settings_t *settings = config_get_ptr();
bool float_format = settings->audio.wasapi.float_format;
bool float_format = settings->bools.audio_wasapi_float_format;
unsigned sh_buffer_length = settings->audio.wasapi.sh_buffer_length;
wasapi_t *w = (wasapi_t*)calloc(1, sizeof(wasapi_t));
w->exclusive = settings->audio.wasapi.exclusive_mode;
w->exclusive = settings->bools.audio_wasapi_exclusive_mode;

WASAPI_CHECK(w, "Out of memory", return NULL);

Expand Down
2 changes: 1 addition & 1 deletion command.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_AUDIO_MUTE_TOGGLE:
{
settings_t *settings = config_get_ptr();
const char *msg = !settings->audio.mute_enable ?
const char *msg = !settings->bools.audio_mute_enable ?
msg_hash_to_str(MSG_AUDIO_MUTED):
msg_hash_to_str(MSG_AUDIO_UNMUTED);

Expand Down
12 changes: 6 additions & 6 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("ui_menubar_enable", &settings->bools.ui_menubar_enable, true, true, false);
SETTING_BOOL("suspend_screensaver_enable", &settings->bools.ui_suspend_screensaver_enable, true, true, false);
SETTING_BOOL("rewind_enable", &settings->rewind_enable, true, rewind_enable, false);
SETTING_BOOL("audio_sync", &settings->audio.sync, true, audio_sync, false);
SETTING_BOOL("audio_sync", &settings->bools.audio_sync, true, audio_sync, false);
SETTING_BOOL("video_shader_enable", &settings->bools.video_shader_enable, true, shader_enable, false);

/* Let implementation decide if automatic, or 1:1 PAR. */
Expand All @@ -775,8 +775,8 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("video_post_filter_record", &settings->bools.video_post_filter_record, true, post_filter_record, false);
SETTING_BOOL("keyboard_gamepad_enable", &settings->input.keyboard_gamepad_enable, true, true, false);
SETTING_BOOL("core_set_supports_no_game_enable", &settings->set_supports_no_game_enable, true, true, false);
SETTING_BOOL("audio_enable", &settings->audio.enable, true, audio_enable, false);
SETTING_BOOL("audio_mute_enable", &settings->audio.mute_enable, true, false, false);
SETTING_BOOL("audio_enable", &settings->bools.audio_enable, true, audio_enable, false);
SETTING_BOOL("audio_mute_enable", &settings->bools.audio_mute_enable, true, false, false);
SETTING_BOOL("location_allow", &settings->location.allow, true, false, false);
SETTING_BOOL("video_font_enable", &settings->bools.video_font_enable, true, font_enable, false);
SETTING_BOOL("core_updater_auto_extract_archive", &settings->network.buildbot_auto_extract_archive, true, true, false);
Expand Down Expand Up @@ -866,10 +866,10 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("config_save_on_exit", &settings->config_save_on_exit, true, config_save_on_exit, false);
SETTING_BOOL("show_hidden_files", &settings->show_hidden_files, true, show_hidden_files, false);
SETTING_BOOL("input_autodetect_enable", &settings->input.autodetect_enable, true, input_autodetect_enable, false);
SETTING_BOOL("audio_rate_control", &settings->audio.rate_control, true, rate_control, false);
SETTING_BOOL("audio_rate_control", &settings->bools.audio_rate_control, true, rate_control, false);
#ifdef HAVE_WASAPI
SETTING_BOOL("audio_wasapi_exclusive_mode", &settings->audio.wasapi.exclusive_mode, true, true, false);
SETTING_BOOL("audio_wasapi_float_format", &settings->audio.wasapi.float_format, true, false, false);
SETTING_BOOL("audio_wasapi_exclusive_mode", &settings->bools.audio_wasapi_exclusive_mode, true, true, false);
SETTING_BOOL("audio_wasapi_float_format", &settings->bools.audio_wasapi_float_format, true, false, false);
#endif

if (global)
Expand Down
16 changes: 9 additions & 7 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ typedef struct settings
bool video_shared_context;
bool video_force_srgb_disable;

bool audio_enable;
bool audio_mute_enable;
bool audio_sync;
bool audio_rate_control;
#ifdef HAVE_WASAPI
bool audio_wasapi_exclusive_mode;
bool audio_wasapi_float_format;
#endif

bool ui_menubar_enable;
bool ui_suspend_screensaver_enable;
bool ui_companion_start_on_boot;
Expand Down Expand Up @@ -245,15 +254,10 @@ typedef struct settings
char driver[32];
char resampler[32];
char device[255];
bool enable;
bool mute_enable;
unsigned out_rate;
unsigned block_frames;
unsigned latency;
bool sync;


bool rate_control;
float rate_control_delta;
float max_timing_skew;
float volume; /* dB scale. */
Expand All @@ -262,8 +266,6 @@ typedef struct settings
struct
{
unsigned sh_buffer_length; /* in frames (0 disables buffering) */
bool exclusive_mode;
bool float_format;
} wasapi;
#endif

Expand Down
14 changes: 7 additions & 7 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -1484,12 +1484,12 @@ void general_read_handler(void *data)
*setting->value.target.fraction = settings->audio.rate_control_delta;
if (*setting->value.target.fraction < 0.0005)
{
configuration_set_bool(settings, settings->audio.rate_control, false);
configuration_set_bool(settings, settings->bools.audio_rate_control, false);
settings->audio.rate_control_delta = 0.0;
}
else
{
configuration_set_bool(settings, settings->audio.rate_control, true);
configuration_set_bool(settings, settings->bools.audio_rate_control, true);
settings->audio.rate_control_delta = *setting->value.target.fraction;
}
break;
Expand Down Expand Up @@ -1602,12 +1602,12 @@ void general_write_handler(void *data)
case MENU_ENUM_LABEL_AUDIO_RATE_CONTROL_DELTA:
if (*setting->value.target.fraction < 0.0005)
{
configuration_set_bool(settings, settings->audio.rate_control, false);
configuration_set_bool(settings, settings->bools.audio_rate_control, false);
settings->audio.rate_control_delta = 0.0;
}
else
{
configuration_set_bool(settings, settings->audio.rate_control, true);
configuration_set_bool(settings, settings->bools.audio_rate_control, true);
settings->audio.rate_control_delta = *setting->value.target.fraction;
}
break;
Expand Down Expand Up @@ -3695,7 +3695,7 @@ static bool setting_append_list(

CONFIG_BOOL(
list, list_info,
&settings->audio.enable,
&settings->bools.audio_enable,
MENU_ENUM_LABEL_AUDIO_ENABLE,
MENU_ENUM_LABEL_VALUE_AUDIO_ENABLE,
audio_enable,
Expand All @@ -3711,7 +3711,7 @@ static bool setting_append_list(

CONFIG_BOOL(
list, list_info,
&settings->audio.mute_enable,
&settings->bools.audio_mute_enable,
MENU_ENUM_LABEL_AUDIO_MUTE,
MENU_ENUM_LABEL_VALUE_AUDIO_MUTE,
false,
Expand Down Expand Up @@ -3771,7 +3771,7 @@ static bool setting_append_list(

CONFIG_BOOL(
list, list_info,
&settings->audio.sync,
&settings->bools.audio_sync,
MENU_ENUM_LABEL_AUDIO_SYNC,
MENU_ENUM_LABEL_VALUE_AUDIO_SYNC,
audio_sync,
Expand Down

0 comments on commit 3e24672

Please sign in to comment.