From 06c22497b7fff9ecd22f1833332543e2ee3f79f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 16 May 2020 21:15:51 +0200 Subject: [PATCH] SDL: If we get an audio device with a different freq than 44100, that's actually OK. --- SDL/SDLMain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 087478a081..382b770115 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -84,8 +84,8 @@ int getDisplayNumber(void) { return displayNumber; } -extern void mixaudio(void *userdata, Uint8 *stream, int len) { - NativeMix((short *)stream, len / 4); +void sdl_mixaudio_callback(void *userdata, Uint8 *stream, int len) { + NativeMix((short *)stream, len / (2 * 2)); } static SDL_AudioDeviceID audioDev = 0; @@ -98,7 +98,7 @@ static void InitSDLAudioDevice(const std::string &name = "") { fmt.format = AUDIO_S16; fmt.channels = 2; fmt.samples = 2048; - fmt.callback = &mixaudio; + fmt.callback = &sdl_mixaudio_callback; fmt.userdata = nullptr; std::string startDevice = name; @@ -122,7 +122,7 @@ static void InitSDLAudioDevice(const std::string &name = "") { } else { if (g_retFmt.samples != fmt.samples) // Notify, but still use it ELOG("Output audio samples: %d (requested: %d)", g_retFmt.samples, fmt.samples); - if (g_retFmt.freq != fmt.freq || g_retFmt.format != fmt.format || g_retFmt.channels != fmt.channels) { + if (g_retFmt.format != fmt.format || g_retFmt.channels != fmt.channels) { ELOG("Sound buffer format does not match requested format."); ELOG("Output audio freq: %d (requested: %d)", g_retFmt.freq, fmt.freq); ELOG("Output audio format: %d (requested: %d)", g_retFmt.format, fmt.format);