| 228 | } |
| 229 | |
| 230 | void AbyssEngine::initializeAudio() { |
| 231 | Common::Log::info("Initializing audio..."); |
| 232 | |
| 233 | SDL_AudioSpec want{.freq = 44100, |
| 234 | .format = AUDIO_S16LSB, |
| 235 | .channels = 2, |
| 236 | .samples = 512, |
| 237 | .callback = [](void *userdata, Uint8 *stream, const int len) { static_cast<AbyssEngine *>(userdata)->fillAudioBuffer(stream, len); }, |
| 238 | .userdata = this}; |
| 239 | SDL_AudioSpec have{}; |
| 240 | |
| 241 | if (SDL_OpenAudio(&want, &have) != 0) |
| 242 | throw std::runtime_error(absl::StrCat("Failed to open audio: ", SDL_GetError())); |
| 243 | |
| 244 | Common::Log::info("Using audio device: {}", SDL_GetAudioDeviceName(0, 0)); |
| 245 | |
| 246 | SDL_PauseAudio(0); |
| 247 | } |
| 248 | |
| 249 | // ReSharper disable once CppDFAUnreachableFunctionCall - fillAudioBuffer is called via SDL2 audio callback |
| 250 | void AbyssEngine::fillAudioBuffer(Uint8 *stream, const int len) const { |
nothing calls this directly
no test coverage detected