From b59b967280d19348154ab52e2bec085d78605f79 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Sep 2022 09:25:00 -0400 Subject: audio_manager: Remove dependence on system state This isn't used by the class, so this can be removed for the time being. --- src/audio_core/audio_core.cpp | 2 +- src/audio_core/audio_manager.cpp | 2 +- src/audio_core/audio_manager.h | 10 ++-------- 3 files changed, 4 insertions(+), 10 deletions(-) (limited to 'src/audio_core') diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index c845330cd..07a679c32 100644 --- a/src/audio_core/audio_core.cpp +++ b/src/audio_core/audio_core.cpp @@ -8,7 +8,7 @@ namespace AudioCore { -AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique(system)} { +AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique()} { CreateSinks(); // Must be created after the sinks adsp = std::make_unique(system, *output_sink); diff --git a/src/audio_core/audio_manager.cpp b/src/audio_core/audio_manager.cpp index 2f1bba9c3..94f2f7e35 100644 --- a/src/audio_core/audio_manager.cpp +++ b/src/audio_core/audio_manager.cpp @@ -8,7 +8,7 @@ namespace AudioCore { -AudioManager::AudioManager(Core::System& system_) : system{system_} { +AudioManager::AudioManager() { thread = std::jthread([this]() { ThreadFunc(); }); } diff --git a/src/audio_core/audio_manager.h b/src/audio_core/audio_manager.h index 8cbd95e22..75604df18 100644 --- a/src/audio_core/audio_manager.h +++ b/src/audio_core/audio_manager.h @@ -12,10 +12,6 @@ #include "audio_core/audio_event.h" #include "core/hle/service/audio/errors.h" -namespace Core { -class System; -} - namespace AudioCore { namespace AudioOut { @@ -43,7 +39,7 @@ class AudioManager { using BufferEventFunc = std::function; public: - explicit AudioManager(Core::System& system); + explicit AudioManager(); /** * Shutdown the audio manager. @@ -80,9 +76,7 @@ private: */ void ThreadFunc(); - /// Core system - Core::System& system; - /// Have sessions started palying? + /// Have sessions started playing? bool sessions_started{}; /// Is the main thread running? std::atomic running{}; -- cgit v1.2.3 From 08d81e0bd8971736547c5fece3a71549df483cc4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Sep 2022 09:28:03 -0400 Subject: audio_manager: Remove unused sessions_started member variable This isn't used, so it can be removed. --- src/audio_core/audio_manager.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/audio_core') diff --git a/src/audio_core/audio_manager.h b/src/audio_core/audio_manager.h index 75604df18..6edf1541d 100644 --- a/src/audio_core/audio_manager.h +++ b/src/audio_core/audio_manager.h @@ -76,8 +76,6 @@ private: */ void ThreadFunc(); - /// Have sessions started playing? - bool sessions_started{}; /// Is the main thread running? std::atomic running{}; /// Unused -- cgit v1.2.3 From da0fd51642d27d6bf9d1af3b3f0acf2888fe724c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Sep 2022 09:29:33 -0400 Subject: audio_manager: Remove unused forward declarations Allows us to get rid of some unnecessary forward declarations and includes. --- src/audio_core/audio_manager.cpp | 2 -- src/audio_core/audio_manager.h | 8 -------- 2 files changed, 10 deletions(-) (limited to 'src/audio_core') diff --git a/src/audio_core/audio_manager.cpp b/src/audio_core/audio_manager.cpp index 94f2f7e35..c46bc3839 100644 --- a/src/audio_core/audio_manager.cpp +++ b/src/audio_core/audio_manager.cpp @@ -1,9 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "audio_core/audio_in_manager.h" #include "audio_core/audio_manager.h" -#include "audio_core/audio_out_manager.h" #include "core/core.h" namespace AudioCore { diff --git a/src/audio_core/audio_manager.h b/src/audio_core/audio_manager.h index 6edf1541d..6c76c36a7 100644 --- a/src/audio_core/audio_manager.h +++ b/src/audio_core/audio_manager.h @@ -14,14 +14,6 @@ namespace AudioCore { -namespace AudioOut { -class Manager; -} - -namespace AudioIn { -class Manager; -} - /** * The AudioManager's main purpose is to wait for buffer events for the audio in and out managers, * and call an associated callback to release buffers. -- cgit v1.2.3 From e48e22eb52ffe08af62772a92c553cd2e3acbfc7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Sep 2022 09:32:12 -0400 Subject: audio_manager: move std::functions in SetOutManager/SetInManager Prevents unnecessary reallocations in the event the captured variables are larger than the internal std::function buffer. --- src/audio_core/audio_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/audio_core') diff --git a/src/audio_core/audio_manager.cpp b/src/audio_core/audio_manager.cpp index c46bc3839..d101e6163 100644 --- a/src/audio_core/audio_manager.cpp +++ b/src/audio_core/audio_manager.cpp @@ -25,7 +25,7 @@ Result AudioManager::SetOutManager(BufferEventFunc buffer_func) { const auto index{events.GetManagerIndex(Event::Type::AudioOutManager)}; if (buffer_events[index] == nullptr) { - buffer_events[index] = buffer_func; + buffer_events[index] = std::move(buffer_func); needs_update = true; events.SetAudioEvent(Event::Type::AudioOutManager, true); } @@ -41,7 +41,7 @@ Result AudioManager::SetInManager(BufferEventFunc buffer_func) { const auto index{events.GetManagerIndex(Event::Type::AudioInManager)}; if (buffer_events[index] == nullptr) { - buffer_events[index] = buffer_func; + buffer_events[index] = std::move(buffer_func); needs_update = true; events.SetAudioEvent(Event::Type::AudioInManager, true); } -- cgit v1.2.3 From 75d6fe3669c5fcbb437247c2c115f401ebb5c30e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Sep 2022 09:35:20 -0400 Subject: audio_manager: Remove redundant cast in ThreadFunc() We can just use a local here to get rid of a second cast. --- src/audio_core/audio_manager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/audio_core') diff --git a/src/audio_core/audio_manager.cpp b/src/audio_core/audio_manager.cpp index d101e6163..e23af0ef5 100644 --- a/src/audio_core/audio_manager.cpp +++ b/src/audio_core/audio_manager.cpp @@ -58,19 +58,21 @@ void AudioManager::ThreadFunc() { running = true; while (running) { - auto timed_out{events.Wait(l, std::chrono::seconds(2))}; + const auto timed_out{events.Wait(l, std::chrono::seconds(2))}; if (events.CheckAudioEventSet(Event::Type::Max)) { break; } for (size_t i = 0; i < buffer_events.size(); i++) { - if (events.CheckAudioEventSet(Event::Type(i)) || timed_out) { + const auto event_type = static_cast(i); + + if (events.CheckAudioEventSet(event_type) || timed_out) { if (buffer_events[i]) { buffer_events[i](); } } - events.SetAudioEvent(Event::Type(i), false); + events.SetAudioEvent(event_type, false); } } } -- cgit v1.2.3 From 00616c7ad856a05189eb1963fef85be361bb9527 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 21 Sep 2022 09:43:53 -0400 Subject: audio_manager: Forward declare result type Moves the include into the cpp file to lessen header dependencies. --- src/audio_core/audio_manager.cpp | 1 + src/audio_core/audio_manager.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/audio_core') diff --git a/src/audio_core/audio_manager.cpp b/src/audio_core/audio_manager.cpp index e23af0ef5..2acde668e 100644 --- a/src/audio_core/audio_manager.cpp +++ b/src/audio_core/audio_manager.cpp @@ -3,6 +3,7 @@ #include "audio_core/audio_manager.h" #include "core/core.h" +#include "core/hle/service/audio/errors.h" namespace AudioCore { diff --git a/src/audio_core/audio_manager.h b/src/audio_core/audio_manager.h index 6c76c36a7..abf077de4 100644 --- a/src/audio_core/audio_manager.h +++ b/src/audio_core/audio_manager.h @@ -10,7 +10,8 @@ #include #include "audio_core/audio_event.h" -#include "core/hle/service/audio/errors.h" + +union Result; namespace AudioCore { -- cgit v1.2.3