From 17b0955f9a9a044060d9673a5e28ede5e5b245ff Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:50:27 -0400 Subject: [PATCH 1/2] audin_u: stub Start, RegisterBufferEvent, AppendAudioInBufferAuto This also moves IAudioIn's definition to the header. Required for Splatoon 2 LAN play. --- src/core/hle/service/audio/audin_u.cpp | 70 +++++++++++++++++--------- src/core/hle/service/audio/audin_u.h | 11 ++++ 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 3e7fd6024..30fedcc8d 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp @@ -9,32 +9,52 @@ namespace Service::Audio { -class IAudioIn final : public ServiceFramework { -public: - explicit IAudioIn(Core::System& system_) : ServiceFramework{system_, "IAudioIn"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, nullptr, "GetAudioInState"}, - {1, nullptr, "Start"}, - {2, nullptr, "Stop"}, - {3, nullptr, "AppendAudioInBuffer"}, - {4, nullptr, "RegisterBufferEvent"}, - {5, nullptr, "GetReleasedAudioInBuffer"}, - {6, nullptr, "ContainsAudioInBuffer"}, - {7, nullptr, "AppendUacInBuffer"}, - {8, nullptr, "AppendAudioInBufferAuto"}, - {9, nullptr, "GetReleasedAudioInBuffersAuto"}, - {10, nullptr, "AppendUacInBufferAuto"}, - {11, nullptr, "GetAudioInBufferCount"}, - {12, nullptr, "SetDeviceGain"}, - {13, nullptr, "GetDeviceGain"}, - {14, nullptr, "FlushAudioInBuffers"}, - }; - // clang-format on +IAudioIn::IAudioIn(Core::System& system_) : ServiceFramework{system_, "IAudioIn"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetAudioInState"}, + {1, &IAudioIn::Start, "Start"}, + {2, nullptr, "Stop"}, + {3, nullptr, "AppendAudioInBuffer"}, + {4, &IAudioIn::RegisterBufferEvent, "RegisterBufferEvent"}, + {5, nullptr, "GetReleasedAudioInBuffer"}, + {6, nullptr, "ContainsAudioInBuffer"}, + {7, nullptr, "AppendUacInBuffer"}, + {8, &IAudioIn::AppendAudioInBufferAuto, "AppendAudioInBufferAuto"}, + {9, nullptr, "GetReleasedAudioInBuffersAuto"}, + {10, nullptr, "AppendUacInBufferAuto"}, + {11, nullptr, "GetAudioInBufferCount"}, + {12, nullptr, "SetDeviceGain"}, + {13, nullptr, "GetDeviceGain"}, + {14, nullptr, "FlushAudioInBuffers"}, + }; + // clang-format on - RegisterHandlers(functions); - } -}; + RegisterHandlers(functions); +} + +IAudioIn::~IAudioIn() = default; + +void IAudioIn::Start(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_Audio, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void IAudioIn::RegisterBufferEvent(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_Audio, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void IAudioIn::AppendAudioInBufferAuto(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_Audio, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} AudInU::AudInU(Core::System& system_) : ServiceFramework{system_, "audin:u"} { // clang-format off diff --git a/src/core/hle/service/audio/audin_u.h b/src/core/hle/service/audio/audin_u.h index 0d75ae5ac..bde8fe7b7 100644 --- a/src/core/hle/service/audio/audin_u.h +++ b/src/core/hle/service/audio/audin_u.h @@ -16,6 +16,17 @@ class HLERequestContext; namespace Service::Audio { +class IAudioIn final : public ServiceFramework { +public: + explicit IAudioIn(Core::System& system_); + ~IAudioIn() override; + +private: + void Start(Kernel::HLERequestContext& ctx); + void RegisterBufferEvent(Kernel::HLERequestContext& ctx); + void AppendAudioInBufferAuto(Kernel::HLERequestContext& ctx); +}; + class AudInU final : public ServiceFramework { public: explicit AudInU(Core::System& system_); From 7bc07195c567a001ecc54d23ba730aa8f369cac7 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 15 Sep 2021 16:27:05 -0400 Subject: [PATCH 2/2] audin_u: Return a buffer event in RegisterBufferEvent Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com> --- src/core/hle/service/audio/audin_u.cpp | 11 +++++++++-- src/core/hle/service/audio/audin_u.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 30fedcc8d..570525019 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp @@ -3,13 +3,16 @@ // Refer to the license.txt file included. #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/service/audio/audin_u.h" namespace Service::Audio { -IAudioIn::IAudioIn(Core::System& system_) : ServiceFramework{system_, "IAudioIn"} { +IAudioIn::IAudioIn(Core::System& system_) + : ServiceFramework{system_, "IAudioIn"}, buffer_event{system_.Kernel()} { // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "GetAudioInState"}, @@ -31,6 +34,9 @@ IAudioIn::IAudioIn(Core::System& system_) : ServiceFramework{system_, "IAudioIn" // clang-format on RegisterHandlers(functions); + + Kernel::KAutoObject::Create(std::addressof(buffer_event)); + buffer_event.Initialize("IAudioIn:BufferEvent"); } IAudioIn::~IAudioIn() = default; @@ -45,8 +51,9 @@ void IAudioIn::Start(Kernel::HLERequestContext& ctx) { void IAudioIn::RegisterBufferEvent(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_Audio, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; + IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(ResultSuccess); + rb.PushCopyObjects(buffer_event.GetReadableEvent()); } void IAudioIn::AppendAudioInBufferAuto(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/audio/audin_u.h b/src/core/hle/service/audio/audin_u.h index bde8fe7b7..f2f7f9932 100644 --- a/src/core/hle/service/audio/audin_u.h +++ b/src/core/hle/service/audio/audin_u.h @@ -4,6 +4,7 @@ #pragma once +#include "core/hle/kernel/k_event.h" #include "core/hle/service/service.h" namespace Core { @@ -25,6 +26,8 @@ private: void Start(Kernel::HLERequestContext& ctx); void RegisterBufferEvent(Kernel::HLERequestContext& ctx); void AppendAudioInBufferAuto(Kernel::HLERequestContext& ctx); + + Kernel::KEvent buffer_event; }; class AudInU final : public ServiceFramework {