1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
From 574447e0806322f8def7f82bb9110253f0e9da27 Mon Sep 17 00:00:00 2001
From: Max Waine <bobishmax@hotmail.com>
Date: Mon, 18 Feb 2019 13:58:07 +0000
Subject: [PATCH] Fix crashes under SDL 2.0.9 for Linux
Achieved by changing how mixbuffer_size is calculated.
---
source/sdl/i_sdlsound.cpp | 43 ++++++---------------------------------
1 file changed, 6 insertions(+), 37 deletions(-)
diff --git a/source/sdl/i_sdlsound.cpp b/source/sdl/i_sdlsound.cpp
index 11b2008a..6eec181e 100644
--- a/source/sdl/i_sdlsound.cpp
+++ b/source/sdl/i_sdlsound.cpp
@@ -742,32 +742,6 @@ static void I_SDLCacheSound(sfxinfo_t *sound)
S_CacheDigitalSoundLump(sound);
}
-static void I_SDLDummyCallback(void *, Uint8 *, int) {}
-
-//
-// I_SDLTestSoundBufferSize
-//
-// This shouldn't be necessary except for really bad API design.
-//
-static Uint32 I_SDLTestSoundBufferSize()
-{
- Uint32 ret = 0;
- SDL_AudioSpec want, have;
- want.freq = snd_samplerate;
- want.format = MIX_DEFAULT_FORMAT;
- want.channels = 2;
- want.samples = audio_buffers;
- want.callback = I_SDLDummyCallback;
-
- if(SDL_OpenAudio(&want, &have) >= 0)
- {
- ret = have.size;
- SDL_CloseAudio();
- }
-
- return ret;
-}
-
//
// I_SDLInitSound
//
@@ -787,16 +761,11 @@ static int I_SDLInitSound()
if(!I_IsSoundBufferSizePowerOf2(audio_buffers))
audio_buffers = I_MakeSoundBufferSize(audio_buffers);
- // Figure out mix buffer sizes
- mixbuffer_size = I_SDLTestSoundBufferSize() / SAMPLESIZE;
- if(!mixbuffer_size)
- {
- printf("Couldn't determine sound mixing buffer size.\n");
- nosfxparm = true;
- nomusicparm = true;
- return 0;
- }
-
+ // Figure out mix buffer sizes by dividing the results of SDL_audio.c's
+ // SDL_CalculateAudioSpec size calculation by SAMPLESIZE. The 2 is number of channels.
+ mixbuffer_size = ((SDL_AUDIO_BITSIZE(MIX_DEFAULT_FORMAT) / 8) * 2 * audio_buffers) /
+ SAMPLESIZE;
+
if(Mix_OpenAudio(snd_samplerate, MIX_DEFAULT_FORMAT, 2, audio_buffers) < 0)
{
printf("Couldn't open audio with desired format.\n");
@@ -804,7 +773,7 @@ static int I_SDLInitSound()
nomusicparm = true;
return 0;
}
-
+
// haleyjd 10/02/08: this must be done as early as possible.
I_SetChannels();
--
2.23.0
|