mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-17 22:25:37 +00:00
FrontendCommon: Drop SDL2 audio output
This commit is contained in:
parent
679f1a51db
commit
ea65c0970c
|
@ -25,6 +25,7 @@ if(NOT ANDROID)
|
||||||
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" ON)
|
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" ON)
|
||||||
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
|
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
|
||||||
option(BUILD_REGTEST "Build regression test runner" OFF)
|
option(BUILD_REGTEST "Build regression test runner" OFF)
|
||||||
|
option(ENABLE_CUBEB "Build with Cubeb audio output" ON)
|
||||||
option(ENABLE_OPENGL "Build with OpenGL renderer" ON)
|
option(ENABLE_OPENGL "Build with OpenGL renderer" ON)
|
||||||
option(ENABLE_VULKAN "Build with Vulkan renderer" ON)
|
option(ENABLE_VULKAN "Build with Vulkan renderer" ON)
|
||||||
option(ENABLE_DISCORD_PRESENCE "Build with Discord Rich Presence support" ON)
|
option(ENABLE_DISCORD_PRESENCE "Build with Discord Rich Presence support" ON)
|
||||||
|
@ -55,31 +56,17 @@ if(USE_WAYLAND)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
if(BUILD_NOGUI_FRONTEND)
|
set(BUILD_NOGUI_FRONTEND OFF)
|
||||||
message(WARNING "Building for Android, disabling NoGUI frontend")
|
set(BUILD_QT_FRONTEND OFF)
|
||||||
set(BUILD_NOGUI_FRONTEND OFF)
|
set(BUILD_REGTEST OFF)
|
||||||
endif()
|
set(ENABLE_CUBEB OFF)
|
||||||
if(BUILD_QT_FRONTEND)
|
set(ENABLE_OPENGL ON)
|
||||||
message(WARNING "Building for Android, disabling Qt frontend")
|
set(ENABLE_VULKAN ON)
|
||||||
set(BUILD_QT_FRONTEND OFF)
|
set(ENABLE_DISCORD_PRESENCE OFF)
|
||||||
endif()
|
|
||||||
if(ENABLE_DISCORD_PRESENCE)
|
|
||||||
message("Building for Android, disabling Discord Presence support")
|
|
||||||
set(ENABLE_DISCORD_PRESENCE OFF)
|
|
||||||
endif()
|
|
||||||
if(USE_SDL2)
|
|
||||||
message("Building for Android, disabling SDL2 support")
|
|
||||||
set(USE_SDL2 OFF)
|
|
||||||
endif()
|
|
||||||
if(USE_X11)
|
|
||||||
set(USE_X11 OFF)
|
|
||||||
endif()
|
|
||||||
if(USE_WAYLAND)
|
|
||||||
set(USE_WAYLAND OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Cheevos are always on.
|
|
||||||
set(ENABLE_CHEEVOS ON)
|
set(ENABLE_CHEEVOS ON)
|
||||||
|
set(USE_SDL2 OFF)
|
||||||
|
set(USE_X11 OFF)
|
||||||
|
set(USE_WAYLAND OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,13 @@ add_subdirectory(imgui)
|
||||||
add_subdirectory(simpleini)
|
add_subdirectory(simpleini)
|
||||||
add_subdirectory(vulkan)
|
add_subdirectory(vulkan)
|
||||||
add_subdirectory(soundtouch)
|
add_subdirectory(soundtouch)
|
||||||
|
|
||||||
add_subdirectory(tinyxml2)
|
add_subdirectory(tinyxml2)
|
||||||
add_subdirectory(cubeb)
|
|
||||||
add_subdirectory(googletest)
|
add_subdirectory(googletest)
|
||||||
|
|
||||||
|
if(ENABLE_CUBEB)
|
||||||
|
add_subdirectory(cubeb)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_DISCORD_PRESENCE)
|
if(ENABLE_DISCORD_PRESENCE)
|
||||||
add_subdirectory(discord-rpc)
|
add_subdirectory(discord-rpc)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -129,6 +129,10 @@ if(WIN32)
|
||||||
target_link_libraries(core PRIVATE winmm.lib)
|
target_link_libraries(core PRIVATE winmm.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_CUBEB)
|
||||||
|
target_compile_definitions(core PUBLIC "WITH_CUBEB=1")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_OPENGL)
|
if(ENABLE_OPENGL)
|
||||||
target_sources(core PRIVATE
|
target_sources(core PRIVATE
|
||||||
gpu_hw_opengl.cpp
|
gpu_hw_opengl.cpp
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PreprocessorDefinitions>WITH_CHEEVOS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WITH_CHEEVOS=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<PreprocessorDefinitions Condition="'$(BuildingForUWP)'!='true'">WITH_CUBEB=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="('$(BuildingForUWP)'!='true' And '$(Platform)'!='ARM64')">WITH_RAINTEGRATION=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="('$(BuildingForUWP)'!='true' And '$(Platform)'!='ARM64')">WITH_RAINTEGRATION=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="('$(Platform)'=='x64' Or '$(Platform)'=='ARM' Or '$(Platform)'=='ARM64')">WITH_RECOMPILER=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="('$(Platform)'=='x64' Or '$(Platform)'=='ARM' Or '$(Platform)'=='ARM64')">WITH_RECOMPILER=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessorDefinitions Condition="('$(Platform)'=='x64' Or '$(Platform)'=='ARM64') And ('$(BuildingForUWP)'!='true')">WITH_MMAP_FASTMEM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions Condition="('$(Platform)'=='x64' Or '$(Platform)'=='ARM64') And ('$(BuildingForUWP)'!='true')">WITH_MMAP_FASTMEM=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
|
|
@ -990,33 +990,31 @@ float Settings::GetDisplayAspectRatioValue() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const auto s_audio_backend_names = make_array("Null", "Cubeb"
|
static constexpr const char* s_audio_backend_names[] = {
|
||||||
|
"Null",
|
||||||
|
#ifdef WITH_CUBEB
|
||||||
|
"Cubeb",
|
||||||
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
,
|
"XAudio2",
|
||||||
"XAudio2"
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef ANDROID
|
#ifdef __ANDROID__
|
||||||
,
|
"AAudio", "OpenSLES",
|
||||||
"SDL"
|
#endif
|
||||||
#else
|
};
|
||||||
,
|
static constexpr const char* s_audio_backend_display_names[] = {
|
||||||
"OpenSLES"
|
TRANSLATABLE("AudioBackend", "Null (No Output)"),
|
||||||
|
#ifdef WITH_CUBEB
|
||||||
|
TRANSLATABLE("AudioBackend", "Cubeb"),
|
||||||
#endif
|
#endif
|
||||||
);
|
|
||||||
static const auto s_audio_backend_display_names =
|
|
||||||
make_array(TRANSLATABLE("AudioBackend", "Null (No Output)"), TRANSLATABLE("AudioBackend", "Cubeb")
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
,
|
TRANSLATABLE("AudioBackend", "XAudio2"),
|
||||||
TRANSLATABLE("AudioBackend", "XAudio2")
|
|
||||||
#endif
|
#endif
|
||||||
#ifndef ANDROID
|
#ifdef __ANDROID__
|
||||||
,
|
"AAudio",
|
||||||
TRANSLATABLE("AudioBackend", "SDL")
|
"OpenSL ES",
|
||||||
#else
|
|
||||||
,
|
|
||||||
TRANSLATABLE("AudioBackend", "OpenSL ES")
|
|
||||||
#endif
|
#endif
|
||||||
);
|
};
|
||||||
|
|
||||||
std::optional<AudioBackend> Settings::ParseAudioBackend(const char* str)
|
std::optional<AudioBackend> Settings::ParseAudioBackend(const char* str)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,13 +112,14 @@ enum class DisplayAspectRatio : u8
|
||||||
enum class AudioBackend : u8
|
enum class AudioBackend : u8
|
||||||
{
|
{
|
||||||
Null,
|
Null,
|
||||||
|
#ifdef WITH_CUBEB
|
||||||
Cubeb,
|
Cubeb,
|
||||||
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
XAudio2,
|
XAudio2,
|
||||||
#endif
|
#endif
|
||||||
#ifndef ANDROID
|
#ifdef __ANDROID__
|
||||||
SDL,
|
AAudio,
|
||||||
#else
|
|
||||||
OpenSLES,
|
OpenSLES,
|
||||||
#endif
|
#endif
|
||||||
Count
|
Count
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "frontend-common/imgui_manager.h"
|
#include "frontend-common/imgui_manager.h"
|
||||||
#include "frontend-common/imgui_overlays.h"
|
#include "frontend-common/imgui_overlays.h"
|
||||||
#include "frontend-common/input_manager.h"
|
#include "frontend-common/input_manager.h"
|
||||||
#include "frontend-common/sdl_audio_stream.h"
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "qtprogresscallback.h"
|
#include "qtprogresscallback.h"
|
||||||
|
|
|
@ -3,8 +3,6 @@ add_library(frontend-common
|
||||||
achievements.h
|
achievements.h
|
||||||
common_host.cpp
|
common_host.cpp
|
||||||
common_host.h
|
common_host.h
|
||||||
cubeb_audio_stream.cpp
|
|
||||||
cubeb_audio_stream.h
|
|
||||||
fullscreen_ui.cpp
|
fullscreen_ui.cpp
|
||||||
fullscreen_ui.h
|
fullscreen_ui.h
|
||||||
game_list.cpp
|
game_list.cpp
|
||||||
|
@ -32,7 +30,15 @@ add_library(frontend-common
|
||||||
postprocessing_shadergen.h
|
postprocessing_shadergen.h
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(frontend-common PUBLIC core common cubeb imgui tinyxml2 rapidjson scmversion)
|
target_link_libraries(frontend-common PUBLIC core common imgui tinyxml2 rapidjson scmversion)
|
||||||
|
|
||||||
|
if(ENABLE_CUBEB)
|
||||||
|
target_sources(frontend-common PRIVATE
|
||||||
|
cubeb_audio_stream.cpp
|
||||||
|
cubeb_audio_stream.h
|
||||||
|
)
|
||||||
|
target_link_libraries(frontend-common PRIVATE cubeb)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_sources(frontend-common PRIVATE
|
target_sources(frontend-common PRIVATE
|
||||||
|
@ -82,8 +88,6 @@ endif()
|
||||||
|
|
||||||
if(SDL2_FOUND)
|
if(SDL2_FOUND)
|
||||||
target_sources(frontend-common PRIVATE
|
target_sources(frontend-common PRIVATE
|
||||||
sdl_audio_stream.cpp
|
|
||||||
sdl_audio_stream.h
|
|
||||||
sdl_input_source.cpp
|
sdl_input_source.cpp
|
||||||
sdl_input_source.h
|
sdl_input_source.h
|
||||||
sdl_initializer.cpp
|
sdl_initializer.cpp
|
||||||
|
|
|
@ -42,14 +42,6 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#ifndef _UWP
|
|
||||||
#include "cubeb_audio_stream.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_SDL2
|
|
||||||
#include "sdl_audio_stream.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WITH_DISCORD_PRESENCE
|
#ifdef WITH_DISCORD_PRESENCE
|
||||||
#include "discord_rpc.h"
|
#include "discord_rpc.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,7 +52,6 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "common/windows_headers.h"
|
#include "common/windows_headers.h"
|
||||||
#include "xaudio2_audio_stream.h"
|
|
||||||
#include <KnownFolders.h>
|
#include <KnownFolders.h>
|
||||||
#include <ShlObj.h>
|
#include <ShlObj.h>
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
|
@ -158,11 +149,6 @@ std::unique_ptr<AudioStream> Host::CreateAudioStream(AudioBackend backend, u32 s
|
||||||
return CommonHost::CreateXAudio2Stream(sample_rate, channels, buffer_ms, latency_ms, stretch);
|
return CommonHost::CreateXAudio2Stream(sample_rate, channels, buffer_ms, latency_ms, stretch);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_SDL2
|
|
||||||
case AudioBackend::SDL:
|
|
||||||
return CommonHost::CreateSDLAudioStream(sample_rate, channels, buffer_ms, latency_ms, stretch);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,6 @@ void ReleaseHostDisplayResources();
|
||||||
std::unique_ptr<AudioStream> CreateXAudio2Stream(u32 sample_rate, u32 channels, u32 buffer_ms, u32 latency_ms,
|
std::unique_ptr<AudioStream> CreateXAudio2Stream(u32 sample_rate, u32 channels, u32 buffer_ms, u32 latency_ms,
|
||||||
AudioStretchMode stretch);
|
AudioStretchMode stretch);
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_SDL2
|
|
||||||
std::unique_ptr<AudioStream> CreateSDLAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms, u32 latency_ms,
|
|
||||||
AudioStretchMode stretch);
|
|
||||||
#endif
|
|
||||||
#ifndef _UWP
|
#ifndef _UWP
|
||||||
std::unique_ptr<AudioStream> CreateCubebAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms, u32 latency_ms,
|
std::unique_ptr<AudioStream> CreateCubebAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms, u32 latency_ms,
|
||||||
AudioStretchMode stretch);
|
AudioStretchMode stretch);
|
||||||
|
|
|
@ -34,9 +34,6 @@
|
||||||
<ClCompile Include="postprocessing_chain.cpp" />
|
<ClCompile Include="postprocessing_chain.cpp" />
|
||||||
<ClCompile Include="postprocessing_shader.cpp" />
|
<ClCompile Include="postprocessing_shader.cpp" />
|
||||||
<ClCompile Include="postprocessing_shadergen.cpp" />
|
<ClCompile Include="postprocessing_shadergen.cpp" />
|
||||||
<ClCompile Include="sdl_audio_stream.cpp">
|
|
||||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="sdl_initializer.cpp">
|
<ClCompile Include="sdl_initializer.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -80,9 +77,6 @@
|
||||||
<ClInclude Include="postprocessing_chain.h" />
|
<ClInclude Include="postprocessing_chain.h" />
|
||||||
<ClInclude Include="postprocessing_shader.h" />
|
<ClInclude Include="postprocessing_shader.h" />
|
||||||
<ClInclude Include="postprocessing_shadergen.h" />
|
<ClInclude Include="postprocessing_shadergen.h" />
|
||||||
<ClInclude Include="sdl_audio_stream.h">
|
|
||||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="sdl_initializer.h">
|
<ClInclude Include="sdl_initializer.h">
|
||||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="icon.cpp" />
|
<ClCompile Include="icon.cpp" />
|
||||||
<ClCompile Include="sdl_audio_stream.cpp" />
|
|
||||||
<ClCompile Include="sdl_initializer.cpp" />
|
<ClCompile Include="sdl_initializer.cpp" />
|
||||||
<ClCompile Include="common_host.cpp" />
|
<ClCompile Include="common_host.cpp" />
|
||||||
<ClCompile Include="vulkan_host_display.cpp" />
|
<ClCompile Include="vulkan_host_display.cpp" />
|
||||||
|
@ -35,7 +34,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="icon.h" />
|
<ClInclude Include="icon.h" />
|
||||||
<ClInclude Include="sdl_audio_stream.h" />
|
|
||||||
<ClInclude Include="sdl_initializer.h" />
|
<ClInclude Include="sdl_initializer.h" />
|
||||||
<ClInclude Include="common_host.h" />
|
<ClInclude Include="common_host.h" />
|
||||||
<ClInclude Include="vulkan_host_display.h" />
|
<ClInclude Include="vulkan_host_display.h" />
|
||||||
|
|
|
@ -1,98 +0,0 @@
|
||||||
#include "sdl_audio_stream.h"
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "common/log.h"
|
|
||||||
#include "common_host.h"
|
|
||||||
#include "sdl_initializer.h"
|
|
||||||
#include <SDL.h>
|
|
||||||
Log_SetChannel(SDLAudioStream);
|
|
||||||
|
|
||||||
SDLAudioStream::SDLAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms, AudioStretchMode stretch)
|
|
||||||
: AudioStream(sample_rate, channels, buffer_ms, stretch)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SDLAudioStream::~SDLAudioStream()
|
|
||||||
{
|
|
||||||
if (IsOpen())
|
|
||||||
SDLAudioStream::CloseDevice();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<AudioStream> CommonHost::CreateSDLAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms,
|
|
||||||
u32 latency_ms, AudioStretchMode stretch)
|
|
||||||
{
|
|
||||||
std::unique_ptr<SDLAudioStream> stream(std::make_unique<SDLAudioStream>(sample_rate, channels, buffer_ms, stretch));
|
|
||||||
if (!stream->OpenDevice(latency_ms))
|
|
||||||
stream.reset();
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SDLAudioStream::OpenDevice(u32 latency_ms)
|
|
||||||
{
|
|
||||||
DebugAssert(!IsOpen());
|
|
||||||
|
|
||||||
FrontendCommon::EnsureSDLInitialized();
|
|
||||||
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
|
|
||||||
{
|
|
||||||
Log_ErrorPrintf("SDL_InitSubSystem(SDL_INIT_AUDIO) failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_AudioSpec spec = {};
|
|
||||||
spec.freq = m_sample_rate;
|
|
||||||
spec.channels = static_cast<Uint8>(m_channels);
|
|
||||||
spec.format = AUDIO_S16;
|
|
||||||
spec.samples = static_cast<Uint16>(GetBufferSizeForMS(m_sample_rate, (latency_ms == 0) ? m_buffer_ms : latency_ms));
|
|
||||||
spec.callback = AudioCallback;
|
|
||||||
spec.userdata = static_cast<void*>(this);
|
|
||||||
|
|
||||||
SDL_AudioSpec obtained_spec = {};
|
|
||||||
m_device_id = SDL_OpenAudioDevice(nullptr, 0, &spec, &obtained_spec, SDL_AUDIO_ALLOW_SAMPLES_CHANGE);
|
|
||||||
if (m_device_id == 0)
|
|
||||||
{
|
|
||||||
Log_ErrorPrintf("SDL_OpenAudioDevice() failed: %s", SDL_GetError());
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Log_DevPrintf("Requested %u frame buffer, got %u frame buffer", spec.samples, obtained_spec.samples);
|
|
||||||
|
|
||||||
BaseInitialize();
|
|
||||||
m_volume = 100;
|
|
||||||
m_paused = false;
|
|
||||||
SDL_PauseAudioDevice(m_device_id, 0);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLAudioStream::SetPaused(bool paused)
|
|
||||||
{
|
|
||||||
if (m_paused == paused)
|
|
||||||
return;
|
|
||||||
|
|
||||||
SDL_PauseAudioDevice(m_device_id, paused ? 1 : 0);
|
|
||||||
m_paused = paused;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLAudioStream::CloseDevice()
|
|
||||||
{
|
|
||||||
SDL_CloseAudioDevice(m_device_id);
|
|
||||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
|
||||||
m_device_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLAudioStream::AudioCallback(void* userdata, uint8_t* stream, int len)
|
|
||||||
{
|
|
||||||
SDLAudioStream* const this_ptr = static_cast<SDLAudioStream*>(userdata);
|
|
||||||
const u32 num_frames = len / sizeof(SampleType) / this_ptr->m_channels;
|
|
||||||
|
|
||||||
this_ptr->ReadFrames(reinterpret_cast<SampleType*>(stream), num_frames);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLAudioStream::SetOutputVolume(u32 volume)
|
|
||||||
{
|
|
||||||
if (m_volume == volume)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Panic("Fixme");
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include "util/audio_stream.h"
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
class SDLAudioStream final : public AudioStream
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SDLAudioStream(u32 sample_rate, u32 channels, u32 buffer_ms, AudioStretchMode stretch);
|
|
||||||
~SDLAudioStream();
|
|
||||||
|
|
||||||
void SetPaused(bool paused) override;
|
|
||||||
void SetOutputVolume(u32 volume) override;
|
|
||||||
|
|
||||||
bool OpenDevice(u32 latency_ms);
|
|
||||||
void CloseDevice();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ALWAYS_INLINE bool IsOpen() const { return (m_device_id != 0); }
|
|
||||||
|
|
||||||
static void AudioCallback(void* userdata, uint8_t* stream, int len);
|
|
||||||
|
|
||||||
u32 m_device_id = 0;
|
|
||||||
};
|
|
Loading…
Reference in a new issue