summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2012-11-26 17:19:48 +0400
committerAndrey Nazarov <skuller@skuller.net>2012-11-26 17:25:59 +0400
commit305a316e0436dfdafc868a05c4f600044e7401d9 (patch)
treebf7ff7765cf6a31f5c5a2432c9cead0740371857
parent680d854caf8d9f3f62ea0d589a380b76d2c584e8 (diff)
Use larger sample buffer size for SDL audio.
2048 samples was not enough to keep up with 10 Hz updates at 22050. Bump to 32768 samples per channel. Also validate number of channels obtained.
-rw-r--r--src/unix/sdl/sound.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/unix/sdl/sound.c b/src/unix/sdl/sound.c
index af383c2..ad18099 100644
--- a/src/unix/sdl/sound.c
+++ b/src/unix/sdl/sound.c
@@ -103,13 +103,17 @@ static sndinitstat_t Init(void)
if (obtained.format != AUDIO_S16LSB) {
Com_EPrintf("SDL audio format %d unsupported.\n", obtained.format);
- Shutdown();
- return SIS_FAILURE;
+ goto fail;
+ }
+
+ if (obtained.channels != 1 && obtained.channels != 2) {
+ Com_EPrintf("SDL audio channels %d unsupported.\n", obtained.channels);
+ goto fail;
}
dma.speed = obtained.freq;
dma.channels = obtained.channels;
- dma.samples = 2048 * obtained.channels;
+ dma.samples = 0x8000 * obtained.channels;
dma.submission_chunk = 1;
dma.samplebits = 16;
dma.buffer = Z_Mallocz(dma.samples * 2);
@@ -121,6 +125,10 @@ static sndinitstat_t Init(void)
SDL_PauseAudio(0);
return SIS_SUCCESS;
+
+fail:
+ Shutdown();
+ return SIS_FAILURE;
}
static void BeginPainting(void)