From 6176fc44860721d5fdc2ed42785da4829c09a5fd Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 30 Dec 2019 00:45:50 +1000 Subject: [PATCH] NullAudioStream: Provide factory function --- src/common/null_audio_stream.cpp | 5 +++++ src/common/null_audio_stream.h | 4 +++- src/duckstation/sdl_host_interface.cpp | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/common/null_audio_stream.cpp b/src/common/null_audio_stream.cpp index a9d3ec26d..d6c5794b4 100644 --- a/src/common/null_audio_stream.cpp +++ b/src/common/null_audio_stream.cpp @@ -18,3 +18,8 @@ void NullAudioStream::BufferAvailable() // drop any buffer as soon as they're available DropBuffer(); } + +std::unique_ptr NullAudioStream::Create() +{ + return std::unique_ptr(new NullAudioStream()); +} diff --git a/src/common/null_audio_stream.h b/src/common/null_audio_stream.h index a1e0a6edf..d589ef697 100644 --- a/src/common/null_audio_stream.h +++ b/src/common/null_audio_stream.h @@ -4,7 +4,6 @@ class NullAudioStream final : public AudioStream { public: - NullAudioStream(); ~NullAudioStream(); static std::unique_ptr Create(); @@ -14,4 +13,7 @@ protected: void PauseDevice(bool paused) override; void CloseDevice() override; void BufferAvailable() override; + +private: + NullAudioStream(); }; diff --git a/src/duckstation/sdl_host_interface.cpp b/src/duckstation/sdl_host_interface.cpp index 8561e613e..3f6d3cbc6 100644 --- a/src/duckstation/sdl_host_interface.cpp +++ b/src/duckstation/sdl_host_interface.cpp @@ -130,7 +130,7 @@ void SDLHostInterface::CreateAudioStream() switch (m_settings.audio_backend) { case AudioBackend::Null: - m_audio_stream = std::make_unique(); + m_audio_stream = NullAudioStream::Create(); break; case AudioBackend::Default: @@ -143,7 +143,7 @@ void SDLHostInterface::CreateAudioStream() { ReportError("Failed to recreate audio stream, falling back to null"); m_audio_stream.reset(); - m_audio_stream = std::make_unique(); + m_audio_stream = NullAudioStream::Create(); if (!m_audio_stream->Reconfigure(44100, 2)) Panic("Failed to reconfigure null audio stream"); }