diff options
author | Liam <byteslice@airmail.cc> | 2024-02-21 02:02:36 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-02-21 04:15:37 +0100 |
commit | 6012c9fe3af1c649e5ac6392dc4b74bd3cfd0c4f (patch) | |
tree | 0c4925aa6e1c67ab3f91723c690ebfce90089356 /src/core | |
parent | audio: split IHardwarweOpusDecoder, move IHardwareOpusDecoderManager (diff) | |
download | yuzu-6012c9fe3af1c649e5ac6392dc4b74bd3cfd0c4f.tar yuzu-6012c9fe3af1c649e5ac6392dc4b74bd3cfd0c4f.tar.gz yuzu-6012c9fe3af1c649e5ac6392dc4b74bd3cfd0c4f.tar.bz2 yuzu-6012c9fe3af1c649e5ac6392dc4b74bd3cfd0c4f.tar.lz yuzu-6012c9fe3af1c649e5ac6392dc4b74bd3cfd0c4f.tar.xz yuzu-6012c9fe3af1c649e5ac6392dc4b74bd3cfd0c4f.tar.zst yuzu-6012c9fe3af1c649e5ac6392dc4b74bd3cfd0c4f.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/service/audio/audio_renderer.cpp | 13 | ||||
-rw-r--r-- | src/core/hle/service/audio/audio_renderer.h | 6 | ||||
-rw-r--r-- | src/core/hle/service/audio/audio_renderer_manager.cpp | 115 | ||||
-rw-r--r-- | src/core/hle/service/audio/audio_renderer_manager.h | 25 |
4 files changed, 62 insertions, 97 deletions
diff --git a/src/core/hle/service/audio/audio_renderer.cpp b/src/core/hle/service/audio/audio_renderer.cpp index 68415eb8f..a408fc3cf 100644 --- a/src/core/hle/service/audio/audio_renderer.cpp +++ b/src/core/hle/service/audio/audio_renderer.cpp @@ -10,11 +10,12 @@ using namespace AudioCore::Renderer; IAudioRenderer::IAudioRenderer(Core::System& system_, Manager& manager_, AudioCore::AudioRendererParameterInternal& params, Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size, - u32 process_handle, Kernel::KProcess& process_, - u64 applet_resource_user_id, s32 session_id) + Kernel::KProcess* process_handle_, u64 applet_resource_user_id, + s32 session_id) : ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"}, rendered_event{service_context.CreateEvent("IAudioRendererEvent")}, manager{manager_}, - impl{std::make_unique<Renderer>(system_, manager, rendered_event)}, process{process_} { + impl{std::make_unique<Renderer>(system_, manager, rendered_event)}, + process_handle{process_handle_} { // clang-format off static const FunctionInfo functions[] = { {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, @@ -35,15 +36,15 @@ IAudioRenderer::IAudioRenderer(Core::System& system_, Manager& manager_, // clang-format on RegisterHandlers(functions); - process.Open(); - impl->Initialize(params, transfer_memory, transfer_memory_size, process_handle, process, + process_handle->Open(); + impl->Initialize(params, transfer_memory, transfer_memory_size, process_handle, applet_resource_user_id, session_id); } IAudioRenderer::~IAudioRenderer() { impl->Finalize(); service_context.CloseEvent(rendered_event); - process.Close(); + process_handle->Close(); } void IAudioRenderer::GetSampleRate(HLERequestContext& ctx) { diff --git a/src/core/hle/service/audio/audio_renderer.h b/src/core/hle/service/audio/audio_renderer.h index f8c48154b..d3e7461ef 100644 --- a/src/core/hle/service/audio/audio_renderer.h +++ b/src/core/hle/service/audio/audio_renderer.h @@ -14,8 +14,8 @@ public: explicit IAudioRenderer(Core::System& system_, AudioCore::Renderer::Manager& manager_, AudioCore::AudioRendererParameterInternal& params, Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size, - u32 process_handle, Kernel::KProcess& process_, - u64 applet_resource_user_id, s32 session_id); + Kernel::KProcess* process_handle_, u64 applet_resource_user_id, + s32 session_id); ~IAudioRenderer() override; private: @@ -37,7 +37,7 @@ private: Kernel::KEvent* rendered_event; AudioCore::Renderer::Manager& manager; std::unique_ptr<AudioCore::Renderer::Renderer> impl; - Kernel::KProcess& process; + Kernel::KProcess* process_handle; Common::ScratchBuffer<u8> output_buffer; Common::ScratchBuffer<u8> performance_buffer; }; diff --git a/src/core/hle/service/audio/audio_renderer_manager.cpp b/src/core/hle/service/audio/audio_renderer_manager.cpp index 7baa9d8cf..3129169a4 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.cpp +++ b/src/core/hle/service/audio/audio_renderer_manager.cpp @@ -8,22 +8,21 @@ #include "core/hle/service/audio/audio_device.h" #include "core/hle/service/audio/audio_renderer.h" #include "core/hle/service/audio/audio_renderer_manager.h" -#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/cmif_serialization.h" namespace Service::Audio { using namespace AudioCore::Renderer; IAudioRendererManager::IAudioRendererManager(Core::System& system_) - : ServiceFramework{system_, "audren:u"}, service_context{system_, "audren:u"}, - impl{std::make_unique<Manager>(system_)} { + : ServiceFramework{system_, "audren:u"}, impl{std::make_unique<Manager>(system_)} { // clang-format off static const FunctionInfo functions[] = { - {0, &IAudioRendererManager::OpenAudioRenderer, "OpenAudioRenderer"}, - {1, &IAudioRendererManager::GetWorkBufferSize, "GetWorkBufferSize"}, - {2, &IAudioRendererManager::GetAudioDeviceService, "GetAudioDeviceService"}, + {0, C<&IAudioRendererManager::OpenAudioRenderer>, "OpenAudioRenderer"}, + {1, C<&IAudioRendererManager::GetWorkBufferSize>, "GetWorkBufferSize"}, + {2, C<&IAudioRendererManager::GetAudioDeviceService>, "GetAudioDeviceService"}, {3, nullptr, "OpenAudioRendererForManualExecution"}, - {4, &IAudioRendererManager::GetAudioDeviceServiceWithRevisionInfo, "GetAudioDeviceServiceWithRevisionInfo"}, + {4, C<&IAudioRendererManager::GetAudioDeviceServiceWithRevisionInfo>, "GetAudioDeviceServiceWithRevisionInfo"}, }; // clang-format on @@ -32,53 +31,38 @@ IAudioRendererManager::IAudioRendererManager(Core::System& system_) IAudioRendererManager::~IAudioRendererManager() = default; -void IAudioRendererManager::OpenAudioRenderer(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - - AudioCore::AudioRendererParameterInternal params; - rp.PopRaw<AudioCore::AudioRendererParameterInternal>(params); - rp.Skip(1, false); - auto transfer_memory_size = rp.Pop<u64>(); - auto applet_resource_user_id = rp.Pop<u64>(); - auto transfer_memory_handle = ctx.GetCopyHandle(0); - auto process_handle = ctx.GetCopyHandle(1); +Result IAudioRendererManager::OpenAudioRenderer( + Out<SharedPointer<IAudioRenderer>> out_audio_renderer, + AudioCore::AudioRendererParameterInternal parameter, + InCopyHandle<Kernel::KTransferMemory> tmem_handle, u64 tmem_size, + InCopyHandle<Kernel::KProcess> process_handle, ClientAppletResourceUserId aruid) { + LOG_DEBUG(Service_Audio, "called"); if (impl->GetSessionCount() + 1 > AudioCore::MaxRendererSessions) { LOG_ERROR(Service_Audio, "Too many AudioRenderer sessions open!"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(Audio::ResultOutOfSessions); - return; + R_THROW(Audio::ResultOutOfSessions); } - auto process{ctx.GetObjectFromHandle<Kernel::KProcess>(process_handle).GetPointerUnsafe()}; - auto transfer_memory{ctx.GetObjectFromHandle<Kernel::KTransferMemory>(transfer_memory_handle)}; - const auto session_id{impl->GetSessionId()}; if (session_id == -1) { LOG_ERROR(Service_Audio, "Tried to open a session that's already in use!"); - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(Audio::ResultOutOfSessions); - return; + R_THROW(Audio::ResultOutOfSessions); } LOG_DEBUG(Service_Audio, "Opened new AudioRenderer session {} sessions open {}", session_id, impl->GetSessionCount()); - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface<IAudioRenderer>(system, *impl, params, transfer_memory.GetPointerUnsafe(), - transfer_memory_size, process_handle, *process, - applet_resource_user_id, session_id); + *out_audio_renderer = + std::make_shared<IAudioRenderer>(system, *impl, parameter, tmem_handle.Get(), tmem_size, + process_handle.Get(), aruid.pid, session_id); + R_SUCCEED(); } -void IAudioRendererManager::GetWorkBufferSize(HLERequestContext& ctx) { - AudioCore::AudioRendererParameterInternal params; +Result IAudioRendererManager::GetWorkBufferSize(Out<u64> out_size, + AudioCore::AudioRendererParameterInternal params) { + LOG_DEBUG(Service_Audio, "called"); - IPC::RequestParser rp{ctx}; - rp.PopRaw<AudioCore::AudioRendererParameterInternal>(params); - - u64 size{0}; - auto result = impl->GetWorkBufferSize(params, size); + R_TRY(impl->GetWorkBufferSize(params, *out_size)) std::string output_info{}; output_info += fmt::format("\tRevision {}", AudioCore::GetRevisionNum(params.revision)); @@ -95,49 +79,26 @@ void IAudioRendererManager::GetWorkBufferSize(HLERequestContext& ctx) { params.external_context_size); LOG_DEBUG(Service_Audio, "called.\nInput params:\n{}\nOutput params:\n\tWorkbuffer size {:08X}", - output_info, size); - - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(result); - rb.Push<u64>(size); -} - -void IAudioRendererManager::GetAudioDeviceService(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - - const auto applet_resource_user_id = rp.Pop<u64>(); - - LOG_DEBUG(Service_Audio, "called. Applet resource id {}", applet_resource_user_id); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - - rb.Push(ResultSuccess); - rb.PushIpcInterface<IAudioDevice>(system, applet_resource_user_id, - ::Common::MakeMagic('R', 'E', 'V', '1'), num_audio_devices++); + output_info, *out_size); + R_SUCCEED(); } -void IAudioRendererManager::OpenAudioRendererForManualExecution(HLERequestContext& ctx) { - LOG_ERROR(Service_Audio, "called. Implement me!"); +Result IAudioRendererManager::GetAudioDeviceService( + Out<SharedPointer<IAudioDevice>> out_audio_device, ClientAppletResourceUserId aruid) { + LOG_DEBUG(Service_Audio, "called, aruid={:#x}", aruid.pid); + *out_audio_device = std::make_shared<IAudioDevice>( + system, aruid.pid, Common::MakeMagic('R', 'E', 'V', '1'), num_audio_devices++); + R_SUCCEED(); } -void IAudioRendererManager::GetAudioDeviceServiceWithRevisionInfo(HLERequestContext& ctx) { - struct Parameters { - u32 revision; - u64 applet_resource_user_id; - }; - - IPC::RequestParser rp{ctx}; - - const auto [revision, applet_resource_user_id] = rp.PopRaw<Parameters>(); - - LOG_DEBUG(Service_Audio, "called. Revision {} Applet resource id {}", - AudioCore::GetRevisionNum(revision), applet_resource_user_id); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - - rb.Push(ResultSuccess); - rb.PushIpcInterface<IAudioDevice>(system, applet_resource_user_id, revision, - num_audio_devices++); +Result IAudioRendererManager::GetAudioDeviceServiceWithRevisionInfo( + Out<SharedPointer<IAudioDevice>> out_audio_device, u32 revision, + ClientAppletResourceUserId aruid) { + LOG_DEBUG(Service_Audio, "called, revision={} aruid={:#x}", AudioCore::GetRevisionNum(revision), + aruid.pid); + *out_audio_device = + std::make_shared<IAudioDevice>(system, aruid.pid, revision, num_audio_devices++); + R_SUCCEED(); } } // namespace Service::Audio diff --git a/src/core/hle/service/audio/audio_renderer_manager.h b/src/core/hle/service/audio/audio_renderer_manager.h index 3623f91c6..69eee664c 100644 --- a/src/core/hle/service/audio/audio_renderer_manager.h +++ b/src/core/hle/service/audio/audio_renderer_manager.h @@ -4,14 +4,12 @@ #pragma once #include "audio_core/audio_render_manager.h" -#include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/cmif_types.h" #include "core/hle/service/service.h" -namespace Core { -class System; -} - namespace Service::Audio { + +class IAudioDevice; class IAudioRenderer; class IAudioRendererManager final : public ServiceFramework<IAudioRendererManager> { @@ -20,13 +18,18 @@ public: ~IAudioRendererManager() override; private: - void OpenAudioRenderer(HLERequestContext& ctx); - void GetWorkBufferSize(HLERequestContext& ctx); - void GetAudioDeviceService(HLERequestContext& ctx); - void OpenAudioRendererForManualExecution(HLERequestContext& ctx); - void GetAudioDeviceServiceWithRevisionInfo(HLERequestContext& ctx); + Result OpenAudioRenderer(Out<SharedPointer<IAudioRenderer>> out_audio_renderer, + AudioCore::AudioRendererParameterInternal parameter, + InCopyHandle<Kernel::KTransferMemory> tmem_handle, u64 tmem_size, + InCopyHandle<Kernel::KProcess> process_handle, + ClientAppletResourceUserId aruid); + Result GetWorkBufferSize(Out<u64> out_size, + AudioCore::AudioRendererParameterInternal parameter); + Result GetAudioDeviceService(Out<SharedPointer<IAudioDevice>> out_audio_device, + ClientAppletResourceUserId aruid); + Result GetAudioDeviceServiceWithRevisionInfo(Out<SharedPointer<IAudioDevice>> out_audio_device, + u32 revision, ClientAppletResourceUserId aruid); - KernelHelpers::ServiceContext service_context; std::unique_ptr<AudioCore::Renderer::Manager> impl; u32 num_audio_devices{0}; }; |