LIBRETRO: use same libretro buffer size for mixer

This commit is contained in:
Giovanni Cascione 2024-03-12 03:10:49 +01:00
parent 2b1ad93f0e
commit 0554419be2
3 changed files with 7 additions and 2 deletions

View File

@ -35,6 +35,7 @@ const char * retro_get_playlist_dir(void);
bool retro_setting_get_timing_inaccuracies_enabled(void);
float retro_setting_get_frame_rate(void);
uint16 retro_setting_get_sample_rate(void);
uint16 retro_setting_get_audio_samples_buffer_size(void);
int retro_setting_get_analog_deadzone(void);
bool retro_setting_get_analog_response_is_quadratic(void);
float retro_setting_get_mouse_speed(void);

View File

@ -127,7 +127,7 @@ static void log_scummvm_exit_code(void) {
static void audio_buffer_init(uint16 sample_rate, uint16 frame_rate) {
audio_samples_accumulator = 0.0f;
audio_samples_per_frame = (float)sample_rate / (float)frame_rate;
uint32 audio_sample_buffer_size = ((uint32)audio_samples_per_frame + 1) * 2 * sizeof(int16);
uint32 audio_sample_buffer_size = ((uint32)retro_setting_get_audio_samples_buffer_size()) * 2 * sizeof(int16);
audio_sample_buffer = audio_sample_buffer ? (int16 *)realloc(audio_sample_buffer, audio_sample_buffer_size) : (int16 *)malloc(audio_sample_buffer_size);
if (audio_sample_buffer)
@ -609,6 +609,10 @@ uint16 retro_setting_get_sample_rate(void) {
return sample_rate;
}
uint16 retro_setting_get_audio_samples_buffer_size(void) {
return audio_samples_per_frame + 1;
}
void init_command_params(void) {
memset(cmd_params, 0, sizeof(cmd_params));
cmd_params_num = 1;

View File

@ -112,7 +112,7 @@ void OSystem_libretro::initBackend() {
#else
_overlay.create(RES_W_OVERLAY, RES_H_OVERLAY, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
#endif
_mixer = new Audio::MixerImpl(retro_setting_get_sample_rate());
_mixer = new Audio::MixerImpl(retro_setting_get_sample_rate(), true, retro_setting_get_audio_samples_buffer_size());
retro_log_cb(RETRO_LOG_DEBUG, "Mixer set up at %dHz\n", retro_setting_get_sample_rate());
_timerManager = new LibretroTimerManager(retro_setting_get_frame_rate());