summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/i_sdlsound.c5
-rw-r--r--src/i_sound.c6
-rw-r--r--src/i_sound.h1
-rw-r--r--src/m_config.c9
4 files changed, 18 insertions, 3 deletions
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index c8ec6853..e60e18e3 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -50,7 +50,6 @@
#define LOW_PASS_FILTER
//#define DEBUG_DUMP_WAVS
-#define MAX_SOUND_SLICE_TIME 70 /* ms */
#define NUM_CHANNELS 16
typedef struct allocated_sound_s allocated_sound_t;
@@ -961,7 +960,7 @@ static void I_SDL_ShutdownSound(void)
sound_initialized = false;
}
-// Calculate slice size, based on MAX_SOUND_SLICE_TIME.
+// Calculate slice size, based on snd_maxslicetime_ms.
// The result must be a power of two.
static int GetSliceSize(void)
@@ -969,7 +968,7 @@ static int GetSliceSize(void)
int limit;
int n;
- limit = (snd_samplerate * MAX_SOUND_SLICE_TIME) / 1000;
+ limit = (snd_samplerate * snd_maxslicetime_ms) / 1000;
// Try all powers of two, not exceeding the limit.
diff --git a/src/i_sound.c b/src/i_sound.c
index f12c8204..7aa3a31b 100644
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -47,6 +47,11 @@ int snd_samplerate = 44100;
int snd_cachesize = 64 * 1024 * 1024;
+// Config variable that controls the sound buffer size.
+// We default to 28ms (1000 / 35fps = 1 buffer per tic).
+
+int snd_maxslicetime_ms = 28;
+
// Low-level sound and music modules we are using
static sound_module_t *sound_module;
@@ -434,6 +439,7 @@ void I_BindSoundVariables(void)
M_BindVariable("snd_sbirq", &snd_sbirq);
M_BindVariable("snd_sbdma", &snd_sbdma);
M_BindVariable("snd_mport", &snd_mport);
+ M_BindVariable("snd_maxslicetime_ms", &snd_maxslicetime_ms);
M_BindVariable("snd_samplerate", &snd_samplerate);
M_BindVariable("snd_cachesize", &snd_cachesize);
M_BindVariable("opl_io_port", &opl_io_port);
diff --git a/src/i_sound.h b/src/i_sound.h
index e4062959..db00ab5c 100644
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -233,6 +233,7 @@ extern int snd_sfxdevice;
extern int snd_musicdevice;
extern int snd_samplerate;
extern int snd_cachesize;
+extern int snd_maxslicetime_ms;
void I_BindSoundVariables(void);
diff --git a/src/m_config.c b/src/m_config.c
index 3f0c24cf..edc0a174 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -798,6 +798,15 @@ static default_t extra_defaults_list[] =
CONFIG_VARIABLE_INT(snd_cachesize),
//!
+ // Maximum size of the output sound buffer size in milliseconds.
+ // Sound output is generated periodically in slices. Higher values
+ // might be more efficient but will introduce latency to the
+ // sound output. The default is 28ms (one slice per tic with the
+ // 35fps timer).
+
+ CONFIG_VARIABLE_INT(snd_maxslicetime_ms),
+
+ //!
// The I/O port to use to access the OPL chip. Only relevant when
// using native OPL music playback.
//