From 58ec81a463f18de2ca4f49301a0d7dca8f55a19e Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Thu, 7 Apr 2016 21:18:27 +0300 Subject: [PATCH] sdlmixer: added hidden config options to setup sampling rate and buffer size --- src/engine/e_sound_sdl.inc | 3 ++- src/game/g_options.pas | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/engine/e_sound_sdl.inc b/src/engine/e_sound_sdl.inc index ce644a7..541f31a 100644 --- a/src/engine/e_sound_sdl.inc +++ b/src/engine/e_sound_sdl.inc @@ -175,7 +175,8 @@ begin if (res and MIX_INIT_OGG) <> 0 then e_WriteLog('SDL: OGG playback is active', MSG_NOTIFY); if (res and MIX_INIT_FLUIDSYNTH) <> 0 then e_WriteLog('SDL: FLUIDSYNTH playback is active', MSG_NOTIFY); - res := Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048); + e_WriteLog(Format('SDL: initializing mixer at %d with buffer %d', [gsSDLSampleRate, gsSDLBufferSize]), MSG_NOTIFY); + res := Mix_OpenAudio(gsSDLSampleRate, AUDIO_S16LSB, 2, gsSDLBufferSize); if res = -1 then begin e_WriteLog('Error initializing SDL mixer:', MSG_FATALERROR); diff --git a/src/game/g_options.pas b/src/game/g_options.pas index f6ffc77..3f13430 100644 --- a/src/game/g_options.pas +++ b/src/game/g_options.pas @@ -92,6 +92,8 @@ var gnWeaponStay: Boolean = False; gnMonsters: Boolean = False; gnBotsVS: String = 'Everybody'; + gsSDLSampleRate: Integer = 44100; + gsSDLBufferSize: Integer = 2048; implementation @@ -242,6 +244,8 @@ begin gMuteWhenInactive := config.ReadBool('Sound', 'MuteInactive', False); gAnnouncer := Min(Max(config.ReadInt('Sound', 'Announcer', ANNOUNCE_MEPLUS), ANNOUNCE_NONE), ANNOUNCE_ALL); gSoundEffectsDF := config.ReadBool('Sound', 'SoundEffectsDF', True); + gsSDLSampleRate := Min(Max(config.ReadInt('Sound', 'SDLSampleRate', 44100), 11025), 96000); + gsSDLBufferSize := Min(Max(config.ReadInt('Sound', 'SDLBufferSize', 2048), 64), 16384); with gGameControls.GameControls do begin @@ -451,6 +455,8 @@ begin config.WriteBool('Sound', 'MuteInactive', gMuteWhenInactive); config.WriteInt('Sound', 'Announcer', gAnnouncer); config.WriteBool('Sound', 'SoundEffectsDF', gSoundEffectsDF); + config.WriteInt('Sound', 'SDLSampleRate', gsSDLSampleRate); + config.WriteInt('Sound', 'SDLBufferSize', gsSDLBufferSize); with config, gGameControls.GameControls do begin -- 2.29.2