From 3f3b4bc36393bb632141ff509804b730e9382775 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 2 Dec 2021 00:58:28 +0100 Subject: [PATCH] cellAudio: recover Cubeb on failed initialization --- rpcs3/Emu/Audio/Cubeb/CubebBackend.cpp | 14 ++++++-------- rpcs3/Emu/Audio/Cubeb/CubebBackend.h | 4 ++-- rpcs3/main_application.cpp | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/rpcs3/Emu/Audio/Cubeb/CubebBackend.cpp b/rpcs3/Emu/Audio/Cubeb/CubebBackend.cpp index f9b27e1be9..4faf5dc1b8 100644 --- a/rpcs3/Emu/Audio/Cubeb/CubebBackend.cpp +++ b/rpcs3/Emu/Audio/Cubeb/CubebBackend.cpp @@ -97,6 +97,12 @@ void CubebBackend::Open(AudioFreq freq, AudioSampleSize sample_size, AudioChanne { m_stream = nullptr; Cubeb.error("cubeb_stream_init() failed: 0x%08x", err); + } + + if (m_stream == nullptr) + { + Cubeb.error("Failed to open audio backend. Make sure that no other application is running that might block audio access (e.g. Netflix)."); + CloseUnlocked(); return; } @@ -130,8 +136,6 @@ void CubebBackend::Close() void CubebBackend::Play() { - ensure(m_stream != nullptr); - if (m_playing) return; if (int err = cubeb_stream_start(m_stream)) @@ -145,8 +149,6 @@ void CubebBackend::Play() void CubebBackend::Pause() { - ensure(m_stream != nullptr); - if (int err = cubeb_stream_stop(m_stream)) { Cubeb.error("cubeb_stream_stop() failed: 0x%08x", err); @@ -158,8 +160,6 @@ void CubebBackend::Pause() bool CubebBackend::IsPlaying() { - ensure(m_stream != nullptr); - return m_playing; } @@ -171,8 +171,6 @@ void CubebBackend::SetWriteCallback(std::function cb) f64 CubebBackend::GetCallbackFrameLen() { - ensure(m_stream != nullptr); - cubeb_stream_params stream_param{}; stream_param.format = get_convert_to_s16() ? CUBEB_SAMPLE_S16NE : CUBEB_SAMPLE_FLOAT32NE; stream_param.rate = get_sampling_rate(); diff --git a/rpcs3/Emu/Audio/Cubeb/CubebBackend.h b/rpcs3/Emu/Audio/Cubeb/CubebBackend.h index 794f8d720f..30a25a0492 100644 --- a/rpcs3/Emu/Audio/Cubeb/CubebBackend.h +++ b/rpcs3/Emu/Audio/Cubeb/CubebBackend.h @@ -35,8 +35,8 @@ public: bool IsPlaying() override; private: - cubeb *m_ctx = nullptr; - cubeb_stream *m_stream = nullptr; + cubeb* m_ctx = nullptr; + cubeb_stream* m_stream = nullptr; #ifdef _WIN32 bool m_com_init_success = false; #endif diff --git a/rpcs3/main_application.cpp b/rpcs3/main_application.cpp index 7e02bb1714..ff61055cb2 100644 --- a/rpcs3/main_application.cpp +++ b/rpcs3/main_application.cpp @@ -117,7 +117,7 @@ EmuCallbacks main_application::CreateCallbacks() if (!result->Initialized()) { // Fall back to a null backend if something went wrong - sys_log.error("Audio renderer %s could not be initialized, using a Null renderer instead", result->GetName()); + sys_log.error("Audio renderer %s could not be initialized, using a Null renderer instead. Make sure that no other application is running that might block audio access (e.g. Netflix).", result->GetName()); result = std::make_shared(); } return result;