diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-09-29 05:42:50 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-10-02 05:38:59 +0200 |
commit | fadcee14f8fca1b76b4ea48b1cfd136ccae8d182 (patch) | |
tree | a5787938bc73ff1b0b539e0945d3544d06a7d6d2 /src/core/hle/service/audio/audout_u.cpp | |
parent | Merge pull request #7102 from Morph1984/remove-boxcat (diff) | |
download | yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.gz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.bz2 yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.lz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.xz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.zst yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.zip |
Diffstat (limited to 'src/core/hle/service/audio/audout_u.cpp')
-rw-r--r-- | src/core/hle/service/audio/audout_u.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 92d4510b1..beb387745 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -15,11 +15,10 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" #include "core/hle/kernel/k_event.h" -#include "core/hle/kernel/k_readable_event.h" -#include "core/hle/kernel/k_writable_event.h" #include "core/hle/kernel/kernel.h" #include "core/hle/service/audio/audout_u.h" #include "core/hle/service/audio/errors.h" +#include "core/hle/service/kernel_helpers.h" #include "core/memory.h" namespace Service::Audio { @@ -41,11 +40,12 @@ enum class AudioState : u32 { class IAudioOut final : public ServiceFramework<IAudioOut> { public: - IAudioOut(Core::System& system_, AudoutParams audio_params_, AudioCore::AudioOut& audio_core_, - std::string&& device_name_, std::string&& unique_name) - : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, device_name{std::move( - device_name_)}, - audio_params{audio_params_}, buffer_event{system.Kernel()}, main_memory{system.Memory()} { + explicit IAudioOut(Core::System& system_, AudoutParams audio_params_, + AudioCore::AudioOut& audio_core_, std::string&& device_name_, + std::string&& unique_name) + : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_}, + device_name{std::move(device_name_)}, audio_params{audio_params_}, + main_memory{system.Memory()}, service_context{system_, "IAudioOut"} { // clang-format off static const FunctionInfo functions[] = { {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"}, @@ -67,16 +67,19 @@ public: RegisterHandlers(functions); // This is the event handle used to check if the audio buffer was released - Kernel::KAutoObject::Create(std::addressof(buffer_event)); - buffer_event.Initialize("IAudioOutBufferReleased"); + buffer_event = service_context.CreateEvent("IAudioOutBufferReleased"); stream = audio_core.OpenStream(system.CoreTiming(), audio_params.sample_rate, audio_params.channel_count, std::move(unique_name), [this] { const auto guard = LockService(); - buffer_event.GetWritableEvent().Signal(); + buffer_event->GetWritableEvent().Signal(); }); } + ~IAudioOut() override { + service_context.CloseEvent(buffer_event); + } + private: struct AudioBuffer { u64_le next; @@ -126,7 +129,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(ResultSuccess); - rb.PushCopyObjects(buffer_event.GetReadableEvent()); + rb.PushCopyObjects(buffer_event->GetReadableEvent()); } void AppendAudioOutBufferImpl(Kernel::HLERequestContext& ctx) { @@ -227,9 +230,12 @@ private: [[maybe_unused]] AudoutParams audio_params{}; - /// This is the event handle used to check if the audio buffer was released - Kernel::KEvent buffer_event; Core::Memory::Memory& main_memory; + + KernelHelpers::ServiceContext service_context; + + /// This is the event handle used to check if the audio buffer was released + Kernel::KEvent* buffer_event; }; AudOutU::AudOutU(Core::System& system_) : ServiceFramework{system_, "audout:u"} { |