[audio_core, hle/services, video_core/compute] Inline std::unique_ptr<> allocs into std::optional<>

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2026-03-04 20:31:09 +00:00 committed by crueter
parent 5322bce4b8
commit 5e10da3cac
18 changed files with 92 additions and 166 deletions

View file

@ -8,10 +8,11 @@
namespace AudioCore {
AudioCore::AudioCore(Core::System& system) : audio_manager{std::make_unique<AudioManager>()} {
AudioCore::AudioCore(Core::System& system) {
audio_manager.emplace();
CreateSinks();
// Must be created after the sinks
adsp = std::make_unique<ADSP::ADSP>(system, *output_sink);
adsp.emplace(system, *output_sink);
}
AudioCore ::~AudioCore() {

View file

@ -15,10 +15,7 @@ class System;
namespace AudioCore {
class AudioManager;
/**
* Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP.
*/
/// @brief Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP.
class AudioCore {
public:
explicit AudioCore(Core::System& system);
@ -50,27 +47,22 @@ public:
*/
Sink::Sink& GetInputSink();
/**
* Get the ADSP.
*
* @return Ref to the ADSP.
*/
/// @brief Get the ADSP.
/// @return Ref to the ADSP.
ADSP::ADSP& ADSP();
private:
/**
* Create the sinks on startup.
*/
/// @brief Create the sinks on startup.
void CreateSinks();
/// Main audio manager for audio in/out
std::unique_ptr<AudioManager> audio_manager;
std::optional<AudioManager> audio_manager;
/// Sink used for audio renderer and audio out
std::unique_ptr<Sink::Sink> output_sink;
/// Sink used for audio input
std::unique_ptr<Sink::Sink> input_sink;
/// The ADSP in the sysmodule
std::unique_ptr<ADSP::ADSP> adsp;
std::optional<ADSP::ADSP> adsp;
};
} // namespace AudioCore

View file

@ -41,8 +41,7 @@ void Manager::ReleaseSessionId(const size_t session_id) {
Result Manager::LinkToManager() {
std::scoped_lock l{mutex};
if (!linked_to_manager) {
AudioManager& manager{system.AudioCore().GetAudioManager()};
manager.SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this));
system.AudioCore().GetAudioManager().SetInManager(std::bind(&Manager::BufferReleaseAndRegister, this));
linked_to_manager = true;
}

View file

@ -40,8 +40,7 @@ void Manager::ReleaseSessionId(const size_t session_id) {
Result Manager::LinkToManager() {
std::scoped_lock l{mutex};
if (!linked_to_manager) {
AudioManager& manager{system.AudioCore().GetAudioManager()};
manager.SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this));
system.AudioCore().GetAudioManager().SetOutManager(std::bind(&Manager::BufferReleaseAndRegister, this));
linked_to_manager = true;
}