diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 2bef556ce9..ce6e5f7fb9 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -797,10 +797,8 @@ bool audio_driver_init_internal( #endif /* Threaded driver is initially stopped. */ - if ( - (audio_driver_st.flags & AUDIO_FLAG_ACTIVE) - && audio_cb_inited - ) + if ( (audio_driver_st.flags & AUDIO_FLAG_ACTIVE) + && audio_cb_inited) audio_driver_start(false); return true; @@ -1444,7 +1442,8 @@ void audio_driver_load_system_sounds(void) task_push_audio_mixer_load(path_ok, NULL, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_OK); if (path_cancel && audio_enable_menu_cancel) task_push_audio_mixer_load(path_cancel, NULL, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_CANCEL); - if (audio_enable_menu_notice) { + if (audio_enable_menu_notice) + { if (path_notice) task_push_audio_mixer_load(path_notice, NULL, NULL, true, AUDIO_MIXER_SLOT_SELECTION_MANUAL, AUDIO_MIXER_SYSTEM_SLOT_NOTICE); if (path_notice_back) @@ -1882,11 +1881,10 @@ void audio_driver_menu_sample(void) struct retro_system_av_info *av_info = &video_st->av_info; const struct retro_system_timing *info = (const struct retro_system_timing*)&av_info->timing; - unsigned sample_count = (info->sample_rate / info->fps) * 2; + unsigned sample_count = floor(info->sample_rate / info->fps) * 2; audio_driver_state_t *audio_st = &audio_driver_st; bool check_flush = !( - (runloop_flags & RUNLOOP_FLAG_PAUSED) - || !(audio_st->flags & AUDIO_FLAG_ACTIVE) + !(audio_st->flags & AUDIO_FLAG_ACTIVE) || !audio_st->output_samples_buf); if ((audio_st->flags & AUDIO_FLAG_SUSPENDED)) check_flush = false; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index f23e9a30bf..d26b005562 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -56,7 +56,7 @@ typedef struct audio_mixer_stream char *name; size_t bufsize; float volume; - enum audio_mixer_stream_type stream_type; + enum audio_mixer_stream_type stream_type; enum audio_mixer_type type; enum audio_mixer_state state; } audio_mixer_stream_t; @@ -70,8 +70,8 @@ typedef struct audio_mixer_stream_params unsigned slot_selection_idx; float volume; enum audio_mixer_slot_selection_type slot_selection_type; - enum audio_mixer_stream_type stream_type; - enum audio_mixer_type type; + enum audio_mixer_stream_type stream_type; + enum audio_mixer_type type; enum audio_mixer_state state; } audio_mixer_stream_params_t; #endif @@ -181,7 +181,7 @@ typedef struct * up to (but excluding) the point where it's converted to 16-bit audio * to give to the driver. */ - float *output_samples_buf; + float *output_samples_buf; size_t output_samples_buf_length; #ifdef HAVE_REWIND int16_t *rewind_buf; @@ -213,8 +213,7 @@ typedef struct float *input_data; size_t input_data_length; #ifdef HAVE_AUDIOMIXER - struct audio_mixer_stream - mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS]; + struct audio_mixer_stream mixer_streams[AUDIO_MIXER_MAX_SYSTEM_STREAMS]; #endif struct retro_audio_callback callback; /* ptr alignment */ /* ptr alignment */ @@ -229,8 +228,7 @@ typedef struct size_t buffer_size; size_t data_ptr; - unsigned free_samples_buf[ - AUDIO_BUFFER_FREE_SAMPLES_COUNT]; + unsigned free_samples_buf[AUDIO_BUFFER_FREE_SAMPLES_COUNT]; #ifdef HAVE_AUDIOMIXER float mixer_volume_gain; @@ -251,8 +249,7 @@ typedef struct bool mixer_mute_enable; #endif - /* Sample the flush delta-time when fast forwarding to find the correct - ressample ratio. */ + /* Sample the flush delta-time when fast forwarding to find the correct ratio. */ retro_time_t last_flush_time; /* Exponential moving average */ retro_time_t avg_flush_delta; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 6062922b0b..90293c1379 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -8294,6 +8294,7 @@ static void general_write_handler(rarch_setting_t *setting) #ifdef HAVE_AUDIOMIXER if (settings->bools.audio_enable_menu) { + audio_driver_load_system_sounds(); if (settings->bools.audio_enable_menu_bgm) audio_driver_mixer_play_menu_sound_looped(AUDIO_MIXER_SYSTEM_SLOT_BGM); else @@ -16629,7 +16630,6 @@ static bool setting_append_list( SD_FLAG_CMD_APPLY_AUTO ); MENU_SETTINGS_LIST_CURRENT_ADD_CMD(list, list_info, CMD_EVENT_MENU_PAUSE_LIBRETRO); - SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_LAKKA_ADVANCED); CONFIG_BOOL( list, list_info, diff --git a/retroarch.c b/retroarch.c index 7f17806407..988c0246b6 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2870,6 +2870,12 @@ bool command_event(enum event_command cmd, void *data) command_event_reinit( data ? *(const int*)data : DRIVERS_CMD_ALL); +#if defined(HAVE_AUDIOMIXER) && defined(HAVE_MENU) + /* Menu sounds require audio reinit. */ + if (settings->bools.audio_enable_menu) + command_event(CMD_EVENT_AUDIO_REINIT, NULL); +#endif + /* Recalibrate frame delay target */ if (settings->bools.video_frame_delay_auto) video_st->frame_delay_target = 0; @@ -3941,13 +3947,6 @@ bool command_event(enum event_command cmd, void *data) video_st->flags &= ~VIDEO_FLAG_IS_SWITCHING_DISPLAY_MODE; audio_st->flags &= ~AUDIO_FLAG_SUSPENDED; -#if defined(HAVE_AUDIOMIXER) && defined(HAVE_MENU) - /* Menu sounds require audio reinit. */ - if ( settings->bools.audio_enable_menu - && menu_st->flags & MENU_ST_FLAG_ALIVE) - command_event(CMD_EVENT_AUDIO_REINIT, NULL); -#endif - if (userdata && *userdata == true) video_driver_cached_frame(); }