diff --git a/retroarch.c b/retroarch.c index d42e7530ce..9aa43cc486 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2238,6 +2238,30 @@ static bool rarch_update_system_info(struct retro_system_info *_info, return true; } +/** + * set_volume: + * @gain : amount of gain to be applied to current volume level. + * + * Adjusts the current audio volume level. + * + **/ +static void set_volume(float gain) +{ + char msg[PATH_MAX_LENGTH]; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + 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", settings->audio.volume); + rarch_main_msg_queue_push(msg, 1, 180, true); + RARCH_LOG("%s\n", msg); + + global->audio_data.volume_gain = db_to_gain(settings->audio.volume); +} + /** * rarch_main_command: * @cmd : Command index. @@ -2928,6 +2952,12 @@ bool rarch_main_command(unsigned cmd) case RARCH_CMD_PERFCNT_REPORT_FRONTEND_LOG: rarch_perf_log(); break; + case RARCH_CMD_VOLUME_UP: + set_volume(0.5f); + break; + case RARCH_CMD_VOLUME_DOWN: + set_volume(-0.5f); + break; } return true; diff --git a/retroarch.h b/retroarch.h index 7a43214c4f..ac7bbf1b80 100644 --- a/retroarch.h +++ b/retroarch.h @@ -191,6 +191,8 @@ enum basic_event RARCH_CMD_PERFCNT_REPORT_FRONTEND_LOG, RARCH_CMD_REMAPPING_INIT, RARCH_CMD_REMAPPING_DEINIT, + RARCH_CMD_VOLUME_UP, + RARCH_CMD_VOLUME_DOWN, }; enum action_state diff --git a/runloop.c b/runloop.c index 6274d4c66c..dd639e7d2d 100644 --- a/runloop.c +++ b/runloop.c @@ -37,30 +37,6 @@ static struct runloop *g_runloop; static struct global *g_extern; -/** - * set_volume: - * @gain : amount of gain to be applied to current volume level. - * - * Adjusts the current audio volume level. - * - **/ -static void set_volume(float gain) -{ - char msg[PATH_MAX_LENGTH]; - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - - 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", settings->audio.volume); - rarch_main_msg_queue_push(msg, 1, 180, true); - RARCH_LOG("%s\n", msg); - - global->audio_data.volume_gain = db_to_gain(settings->audio.volume); -} - /** * check_pause: * @pressed : was libretro pause key pressed? @@ -644,9 +620,9 @@ static int do_state_checks( rarch_main_command(RARCH_CMD_AUDIO_MUTE_TOGGLE); if (volume_up_pressed) - set_volume(0.5f); + rarch_main_command(RARCH_CMD_VOLUME_UP); else if (volume_down_pressed) - set_volume(-0.5f); + rarch_main_command(RARCH_CMD_VOLUME_DOWN); #ifdef HAVE_NETPLAY if (driver->netplay_data)