/** ****************************************************************************** * Xenia : Xbox 360 Emulator Research Project * ****************************************************************************** * Copyright 2020 Ben Vanik. All rights reserved. * * Released under the BSD license - see LICENSE in the root for more details. * ****************************************************************************** * * @modified Tom Clay, 2026 - Adapted for ReXGlue runtime */ #pragma once #include #include #include #include #include #include namespace rex::audio::sdl { class SDLAudioDriver : public AudioDriver { public: SDLAudioDriver(memory::Memory* memory, rex::thread::Semaphore* semaphore); ~SDLAudioDriver() override; bool Initialize(); void SubmitFrame(uint32_t frame_ptr) override; void Shutdown(); protected: static void SDLCallback(void* userdata, SDL_AudioStream* stream, int additional_amount, int total_amount); rex::thread::Semaphore* semaphore_ = nullptr; SDL_AudioStream* sdl_stream_ = nullptr; bool sdl_initialized_ = false; uint8_t sdl_device_channels_ = 0; static const uint32_t frame_frequency_ = 48000; static const uint32_t frame_channels_ = 6; static const uint32_t channel_samples_ = 256; static const uint32_t frame_samples_ = frame_channels_ * channel_samples_; static const uint32_t frame_size_ = sizeof(float) * frame_samples_; std::queue frames_queued_ = {}; std::stack frames_unused_ = {}; std::mutex frames_mutex_ = {}; }; } // namespace rex::audio::sdl