(audio driver) Refactor

This commit is contained in:
twinaphex 2016-05-08 16:54:15 +02:00
parent 13998f583a
commit 8b714d2932
3 changed files with 15 additions and 12 deletions

View File

@ -891,6 +891,17 @@ bool audio_driver_disable_callback(void)
return true;
}
/* Sets audio monitor rate to new value. */
void audio_driver_monitor_set_rate(void)
{
settings_t *settings = config_get_ptr();
double new_src_ratio = (double)settings->audio.out_rate /
audio_driver_data.audio_rate.input;
audio_driver_data.audio_rate.source_ratio.original = new_src_ratio;
audio_driver_data.audio_rate.source_ratio.current = new_src_ratio;
}
bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
{
settings_t *settings = config_get_ptr();
@ -921,15 +932,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data)
case RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES:
audio_monitor_adjust_system_rates();
break;
case RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE:
{
double new_src_ratio = (double)settings->audio.out_rate /
audio_driver_data.audio_rate.input;
audio_driver_data.audio_rate.source_ratio.original = new_src_ratio;
audio_driver_data.audio_rate.source_ratio.current = new_src_ratio;
}
break;
case RARCH_AUDIO_CTL_MUTE_TOGGLE:
if (!audio_driver_context_audio_data)
return false;

View File

@ -45,8 +45,6 @@ enum rarch_audio_ctl_state
RARCH_AUDIO_CTL_DESTROY_DATA,
RARCH_AUDIO_CTL_START,
RARCH_AUDIO_CTL_STOP,
/* Sets audio monitor refresh rate to new value. */
RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE,
RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES,
RARCH_AUDIO_CTL_MUTE_TOGGLE,
RARCH_AUDIO_CTL_UNSET_CALLBACK,
@ -181,6 +179,9 @@ void audio_driver_setup_rewind(void);
bool audio_driver_set_callback(const void *data);
/* Sets audio monitor rate to new value. */
void audio_driver_monitor_set_rate(void);
bool audio_driver_find_driver(void);
bool audio_driver_deinit(void);

View File

@ -477,7 +477,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data)
{
float *hz = (float*)data;
video_monitor_set_refresh_rate(*hz);
audio_driver_ctl(RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE, NULL);
audio_driver_monitor_set_rate();
driver_adjust_system_rates();
}
break;