Skip to content

Commit 30aceda

Browse files
authored
Merge pull request ddnet#8820 from TsFreddie/resample
Resample to the device playback rate
2 parents bb3c76a + ecec1ff commit 30aceda

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/engine/client/sound.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,16 @@ int CSound::Init()
228228
return -1;
229229
}
230230

231-
m_MixingRate = g_Config.m_SndRate;
232-
233231
SDL_AudioSpec Format, FormatOut;
234-
Format.freq = m_MixingRate;
232+
Format.freq = g_Config.m_SndRate;
235233
Format.format = AUDIO_S16;
236234
Format.channels = 2;
237235
Format.samples = g_Config.m_SndBufferSize;
238236
Format.callback = SdlCallback;
239237
Format.userdata = this;
240238

241239
// Open the audio device and start playing sound!
242-
m_Device = SDL_OpenAudioDevice(nullptr, 0, &Format, &FormatOut, 0);
240+
m_Device = SDL_OpenAudioDevice(nullptr, 0, &Format, &FormatOut, SDL_AUDIO_ALLOW_FREQUENCY_CHANGE);
243241
if(m_Device == 0)
244242
{
245243
dbg_msg("sound", "unable to open audio: %s", SDL_GetError());
@@ -248,6 +246,7 @@ int CSound::Init()
248246
else
249247
dbg_msg("sound", "sound init successful using audio driver '%s'", SDL_GetCurrentAudioDriver());
250248

249+
m_MixingRate = FormatOut.freq;
251250
m_MaxFrames = FormatOut.samples * 2;
252251
#if defined(CONF_VIDEORECORDER)
253252
m_MaxFrames = maximum<uint32_t>(m_MaxFrames, 1024 * 2); // make the buffer bigger just in case

0 commit comments

Comments
 (0)