mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-18 19:41:01 +01:00
audio: rewrite IAudioRendererManager
This commit is contained in:
parent
f65539504f
commit
6012c9fe3a
12 changed files with 107 additions and 136 deletions
|
@ -17,9 +17,8 @@ Renderer::Renderer(Core::System& system_, Manager& manager_, Kernel::KEvent* ren
|
||||||
|
|
||||||
Result Renderer::Initialize(const AudioRendererParameterInternal& params,
|
Result Renderer::Initialize(const AudioRendererParameterInternal& params,
|
||||||
Kernel::KTransferMemory* transfer_memory,
|
Kernel::KTransferMemory* transfer_memory,
|
||||||
const u64 transfer_memory_size, const u32 process_handle,
|
const u64 transfer_memory_size, Kernel::KProcess* process_handle,
|
||||||
Kernel::KProcess& process, const u64 applet_resource_user_id,
|
const u64 applet_resource_user_id, const s32 session_id) {
|
||||||
const s32 session_id) {
|
|
||||||
if (params.execution_mode == ExecutionMode::Auto) {
|
if (params.execution_mode == ExecutionMode::Auto) {
|
||||||
if (!manager.AddSystem(system)) {
|
if (!manager.AddSystem(system)) {
|
||||||
LOG_ERROR(Service_Audio,
|
LOG_ERROR(Service_Audio,
|
||||||
|
@ -30,7 +29,7 @@ Result Renderer::Initialize(const AudioRendererParameterInternal& params,
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
system.Initialize(params, transfer_memory, transfer_memory_size, process_handle, process,
|
system.Initialize(params, transfer_memory, transfer_memory_size, process_handle,
|
||||||
applet_resource_user_id, session_id);
|
applet_resource_user_id, session_id);
|
||||||
|
|
||||||
return ResultSuccess;
|
return ResultSuccess;
|
||||||
|
|
|
@ -38,14 +38,14 @@ public:
|
||||||
* @param params - Input parameters to initialize the system with.
|
* @param params - Input parameters to initialize the system with.
|
||||||
* @param transfer_memory - Game-supplied memory for all workbuffers. Unused.
|
* @param transfer_memory - Game-supplied memory for all workbuffers. Unused.
|
||||||
* @param transfer_memory_size - Size of the transfer memory. Unused.
|
* @param transfer_memory_size - Size of the transfer memory. Unused.
|
||||||
* @param process_handle - Process handle, also used for memory. Unused.
|
* @param process_handle - Process handle, also used for memory.
|
||||||
* @param applet_resource_user_id - Applet id for this renderer. Unused.
|
* @param applet_resource_user_id - Applet id for this renderer. Unused.
|
||||||
* @param session_id - Session id of this renderer.
|
* @param session_id - Session id of this renderer.
|
||||||
* @return Result code.
|
* @return Result code.
|
||||||
*/
|
*/
|
||||||
Result Initialize(const AudioRendererParameterInternal& params,
|
Result Initialize(const AudioRendererParameterInternal& params,
|
||||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||||
u32 process_handle, Kernel::KProcess& process, u64 applet_resource_user_id,
|
Kernel::KProcess* process_handle, u64 applet_resource_user_id,
|
||||||
s32 session_id);
|
s32 session_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,11 +18,10 @@
|
||||||
namespace AudioCore::Renderer {
|
namespace AudioCore::Renderer {
|
||||||
|
|
||||||
InfoUpdater::InfoUpdater(std::span<const u8> input_, std::span<u8> output_,
|
InfoUpdater::InfoUpdater(std::span<const u8> input_, std::span<u8> output_,
|
||||||
const u32 process_handle_, BehaviorInfo& behaviour_)
|
Kernel::KProcess* process_handle_, BehaviorInfo& behaviour_)
|
||||||
: input{input_.data() + sizeof(UpdateDataHeader)},
|
: input{input_.data() + sizeof(UpdateDataHeader)}, input_origin{input_},
|
||||||
input_origin{input_}, output{output_.data() + sizeof(UpdateDataHeader)},
|
output{output_.data() + sizeof(UpdateDataHeader)}, output_origin{output_},
|
||||||
output_origin{output_}, in_header{reinterpret_cast<const UpdateDataHeader*>(
|
in_header{reinterpret_cast<const UpdateDataHeader*>(input_origin.data())},
|
||||||
input_origin.data())},
|
|
||||||
out_header{reinterpret_cast<UpdateDataHeader*>(output_origin.data())},
|
out_header{reinterpret_cast<UpdateDataHeader*>(output_origin.data())},
|
||||||
expected_input_size{input_.size()}, expected_output_size{output_.size()},
|
expected_input_size{input_.size()}, expected_output_size{output_.size()},
|
||||||
process_handle{process_handle_}, behaviour{behaviour_} {
|
process_handle{process_handle_}, behaviour{behaviour_} {
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/service/audio/errors.h"
|
#include "core/hle/service/audio/errors.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
class KProcess;
|
||||||
|
}
|
||||||
|
|
||||||
namespace AudioCore::Renderer {
|
namespace AudioCore::Renderer {
|
||||||
class BehaviorInfo;
|
class BehaviorInfo;
|
||||||
class VoiceContext;
|
class VoiceContext;
|
||||||
|
@ -39,8 +43,8 @@ class InfoUpdater {
|
||||||
static_assert(sizeof(UpdateDataHeader) == 0x40, "UpdateDataHeader has the wrong size!");
|
static_assert(sizeof(UpdateDataHeader) == 0x40, "UpdateDataHeader has the wrong size!");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InfoUpdater(std::span<const u8> input, std::span<u8> output, u32 process_handle,
|
explicit InfoUpdater(std::span<const u8> input, std::span<u8> output,
|
||||||
BehaviorInfo& behaviour);
|
Kernel::KProcess* process_handle, BehaviorInfo& behaviour);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the voice channel resources.
|
* Update the voice channel resources.
|
||||||
|
@ -197,7 +201,7 @@ private:
|
||||||
/// Expected output size, see CheckConsumedSize
|
/// Expected output size, see CheckConsumedSize
|
||||||
u64 expected_output_size;
|
u64 expected_output_size;
|
||||||
/// Unused
|
/// Unused
|
||||||
u32 process_handle;
|
Kernel::KProcess* process_handle;
|
||||||
/// Behaviour
|
/// Behaviour
|
||||||
BehaviorInfo& behaviour;
|
BehaviorInfo& behaviour;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
|
|
||||||
namespace AudioCore::Renderer {
|
namespace AudioCore::Renderer {
|
||||||
|
|
||||||
PoolMapper::PoolMapper(u32 process_handle_, bool force_map_)
|
PoolMapper::PoolMapper(Kernel::KProcess* process_handle_, bool force_map_)
|
||||||
: process_handle{process_handle_}, force_map{force_map_} {}
|
: process_handle{process_handle_}, force_map{force_map_} {}
|
||||||
|
|
||||||
PoolMapper::PoolMapper(u32 process_handle_, std::span<MemoryPoolInfo> pool_infos_, u32 pool_count_,
|
PoolMapper::PoolMapper(Kernel::KProcess* process_handle_, std::span<MemoryPoolInfo> pool_infos_,
|
||||||
bool force_map_)
|
u32 pool_count_, bool force_map_)
|
||||||
: process_handle{process_handle_}, pool_infos{pool_infos_.data()},
|
: process_handle{process_handle_}, pool_infos{pool_infos_.data()}, pool_count{pool_count_},
|
||||||
pool_count{pool_count_}, force_map{force_map_} {}
|
force_map{force_map_} {}
|
||||||
|
|
||||||
void PoolMapper::ClearUseState(std::span<MemoryPoolInfo> pools, const u32 count) {
|
void PoolMapper::ClearUseState(std::span<MemoryPoolInfo> pools, const u32 count) {
|
||||||
for (u32 i = 0; i < count; i++) {
|
for (u32 i = 0; i < count; i++) {
|
||||||
|
@ -106,15 +106,17 @@ bool PoolMapper::IsForceMapEnabled() const {
|
||||||
return force_map;
|
return force_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 PoolMapper::GetProcessHandle(const MemoryPoolInfo* pool) const {
|
Kernel::KProcess* PoolMapper::GetProcessHandle(const MemoryPoolInfo* pool) const {
|
||||||
switch (pool->GetLocation()) {
|
switch (pool->GetLocation()) {
|
||||||
case MemoryPoolInfo::Location::CPU:
|
case MemoryPoolInfo::Location::CPU:
|
||||||
return process_handle;
|
return process_handle;
|
||||||
case MemoryPoolInfo::Location::DSP:
|
case MemoryPoolInfo::Location::DSP:
|
||||||
return Kernel::Svc::CurrentProcess;
|
// return Kernel::Svc::CurrentProcess;
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
LOG_WARNING(Service_Audio, "Invalid MemoryPoolInfo location!");
|
LOG_WARNING(Service_Audio, "Invalid MemoryPoolInfo location!");
|
||||||
return Kernel::Svc::CurrentProcess;
|
// return Kernel::Svc::CurrentProcess;
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PoolMapper::Map([[maybe_unused]] const u32 handle, [[maybe_unused]] const CpuAddr cpu_addr,
|
bool PoolMapper::Map([[maybe_unused]] const u32 handle, [[maybe_unused]] const CpuAddr cpu_addr,
|
||||||
|
@ -147,14 +149,14 @@ bool PoolMapper::Unmap([[maybe_unused]] const u32 handle, [[maybe_unused]] const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PoolMapper::Unmap(MemoryPoolInfo& pool) const {
|
bool PoolMapper::Unmap(MemoryPoolInfo& pool) const {
|
||||||
[[maybe_unused]] u32 handle{0};
|
[[maybe_unused]] Kernel::KProcess* handle{};
|
||||||
|
|
||||||
switch (pool.GetLocation()) {
|
switch (pool.GetLocation()) {
|
||||||
case MemoryPoolInfo::Location::CPU:
|
case MemoryPoolInfo::Location::CPU:
|
||||||
handle = process_handle;
|
handle = process_handle;
|
||||||
break;
|
break;
|
||||||
case MemoryPoolInfo::Location::DSP:
|
case MemoryPoolInfo::Location::DSP:
|
||||||
handle = Kernel::Svc::CurrentProcess;
|
// handle = Kernel::Svc::CurrentProcess;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// nn::audio::dsp::UnmapUserPointer(handle, pool->cpu_address, pool->size);
|
// nn::audio::dsp::UnmapUserPointer(handle, pool->cpu_address, pool->size);
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/hle/service/audio/errors.h"
|
#include "core/hle/service/audio/errors.h"
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
class KProcess;
|
||||||
|
}
|
||||||
|
|
||||||
namespace AudioCore::Renderer {
|
namespace AudioCore::Renderer {
|
||||||
class AddressInfo;
|
class AddressInfo;
|
||||||
|
|
||||||
|
@ -18,9 +22,9 @@ class AddressInfo;
|
||||||
*/
|
*/
|
||||||
class PoolMapper {
|
class PoolMapper {
|
||||||
public:
|
public:
|
||||||
explicit PoolMapper(u32 process_handle, bool force_map);
|
explicit PoolMapper(Kernel::KProcess* process_handle, bool force_map);
|
||||||
explicit PoolMapper(u32 process_handle, std::span<MemoryPoolInfo> pool_infos, u32 pool_count,
|
explicit PoolMapper(Kernel::KProcess* process_handle, std::span<MemoryPoolInfo> pool_infos,
|
||||||
bool force_map);
|
u32 pool_count, bool force_map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the usage state for all given pools.
|
* Clear the usage state for all given pools.
|
||||||
|
@ -98,7 +102,7 @@ public:
|
||||||
* @return CurrentProcessHandle if location == DSP,
|
* @return CurrentProcessHandle if location == DSP,
|
||||||
* the PoolMapper's process_handle if location == CPU
|
* the PoolMapper's process_handle if location == CPU
|
||||||
*/
|
*/
|
||||||
u32 GetProcessHandle(const MemoryPoolInfo* pool) const;
|
Kernel::KProcess* GetProcessHandle(const MemoryPoolInfo* pool) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map the given region with the given handle. This is a no-op.
|
* Map the given region with the given handle. This is a no-op.
|
||||||
|
@ -167,7 +171,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Process handle for this mapper, used when location == CPU
|
/// Process handle for this mapper, used when location == CPU
|
||||||
u32 process_handle;
|
Kernel::KProcess* process_handle{};
|
||||||
/// List of memory pools assigned to this mapper
|
/// List of memory pools assigned to this mapper
|
||||||
MemoryPoolInfo* pool_infos{};
|
MemoryPoolInfo* pool_infos{};
|
||||||
/// The number of pools
|
/// The number of pools
|
||||||
|
|
|
@ -102,8 +102,8 @@ System::System(Core::System& core_, Kernel::KEvent* adsp_rendered_event_)
|
||||||
|
|
||||||
Result System::Initialize(const AudioRendererParameterInternal& params,
|
Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||||
u32 process_handle_, Kernel::KProcess& process_,
|
Kernel::KProcess* process_handle_, u64 applet_resource_user_id_,
|
||||||
u64 applet_resource_user_id_, s32 session_id_) {
|
s32 session_id_) {
|
||||||
if (!CheckValidRevision(params.revision)) {
|
if (!CheckValidRevision(params.revision)) {
|
||||||
return Service::Audio::ResultInvalidRevision;
|
return Service::Audio::ResultInvalidRevision;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,6 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||||
behavior.SetUserLibRevision(params.revision);
|
behavior.SetUserLibRevision(params.revision);
|
||||||
|
|
||||||
process_handle = process_handle_;
|
process_handle = process_handle_;
|
||||||
process = &process_;
|
|
||||||
applet_resource_user_id = applet_resource_user_id_;
|
applet_resource_user_id = applet_resource_user_id_;
|
||||||
session_id = session_id_;
|
session_id = session_id_;
|
||||||
|
|
||||||
|
@ -132,7 +131,8 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
|
||||||
render_device = params.rendering_device;
|
render_device = params.rendering_device;
|
||||||
execution_mode = params.execution_mode;
|
execution_mode = params.execution_mode;
|
||||||
|
|
||||||
process->GetMemory().ZeroBlock(transfer_memory->GetSourceAddress(), transfer_memory_size);
|
process_handle->GetMemory().ZeroBlock(transfer_memory->GetSourceAddress(),
|
||||||
|
transfer_memory_size);
|
||||||
|
|
||||||
// Note: We're not actually using the transfer memory because it's a pain to code for.
|
// Note: We're not actually using the transfer memory because it's a pain to code for.
|
||||||
// Allocate the memory normally instead and hope the game doesn't try to read anything back
|
// Allocate the memory normally instead and hope the game doesn't try to read anything back
|
||||||
|
@ -616,7 +616,7 @@ void System::SendCommandToDsp() {
|
||||||
static_cast<u64>((time_limit_percent / 100) * 2'880'000.0 *
|
static_cast<u64>((time_limit_percent / 100) * 2'880'000.0 *
|
||||||
(static_cast<f32>(render_time_limit_percent) / 100.0f))};
|
(static_cast<f32>(render_time_limit_percent) / 100.0f))};
|
||||||
audio_renderer.SetCommandBuffer(session_id, translated_addr, command_size, time_limit,
|
audio_renderer.SetCommandBuffer(session_id, translated_addr, command_size, time_limit,
|
||||||
applet_resource_user_id, process,
|
applet_resource_user_id, process_handle,
|
||||||
reset_command_buffers);
|
reset_command_buffers);
|
||||||
reset_command_buffers = false;
|
reset_command_buffers = false;
|
||||||
command_buffer_size = command_size;
|
command_buffer_size = command_size;
|
||||||
|
|
|
@ -74,14 +74,14 @@ public:
|
||||||
* @param params - Input parameters to initialize the system with.
|
* @param params - Input parameters to initialize the system with.
|
||||||
* @param transfer_memory - Game-supplied memory for all workbuffers. Unused.
|
* @param transfer_memory - Game-supplied memory for all workbuffers. Unused.
|
||||||
* @param transfer_memory_size - Size of the transfer memory. Unused.
|
* @param transfer_memory_size - Size of the transfer memory. Unused.
|
||||||
* @param process_handle - Process handle, also used for memory. Unused.
|
* @param process_handle - Process handle, also used for memory.
|
||||||
* @param applet_resource_user_id - Applet id for this renderer. Unused.
|
* @param applet_resource_user_id - Applet id for this renderer. Unused.
|
||||||
* @param session_id - Session id of this renderer.
|
* @param session_id - Session id of this renderer.
|
||||||
* @return Result code.
|
* @return Result code.
|
||||||
*/
|
*/
|
||||||
Result Initialize(const AudioRendererParameterInternal& params,
|
Result Initialize(const AudioRendererParameterInternal& params,
|
||||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||||
u32 process_handle, Kernel::KProcess& process, u64 applet_resource_user_id,
|
Kernel::KProcess* process_handle, u64 applet_resource_user_id,
|
||||||
s32 session_id);
|
s32 session_id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,9 +278,7 @@ private:
|
||||||
/// Does what locks do
|
/// Does what locks do
|
||||||
std::mutex lock{};
|
std::mutex lock{};
|
||||||
/// Process this audio render is operating within, used for memory reads/writes.
|
/// Process this audio render is operating within, used for memory reads/writes.
|
||||||
Kernel::KProcess* process{};
|
Kernel::KProcess* process_handle{};
|
||||||
/// Handle for the process for this system, unused
|
|
||||||
u32 process_handle{};
|
|
||||||
/// Applet resource id for this system, unused
|
/// Applet resource id for this system, unused
|
||||||
u64 applet_resource_user_id{};
|
u64 applet_resource_user_id{};
|
||||||
/// Controls performance input and output
|
/// Controls performance input and output
|
||||||
|
|
|
@ -10,11 +10,12 @@ using namespace AudioCore::Renderer;
|
||||||
IAudioRenderer::IAudioRenderer(Core::System& system_, Manager& manager_,
|
IAudioRenderer::IAudioRenderer(Core::System& system_, Manager& manager_,
|
||||||
AudioCore::AudioRendererParameterInternal& params,
|
AudioCore::AudioRendererParameterInternal& params,
|
||||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||||
u32 process_handle, Kernel::KProcess& process_,
|
Kernel::KProcess* process_handle_, u64 applet_resource_user_id,
|
||||||
u64 applet_resource_user_id, s32 session_id)
|
s32 session_id)
|
||||||
: ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"},
|
: ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"},
|
||||||
rendered_event{service_context.CreateEvent("IAudioRendererEvent")}, manager{manager_},
|
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
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IAudioRenderer::GetSampleRate, "GetSampleRate"},
|
{0, &IAudioRenderer::GetSampleRate, "GetSampleRate"},
|
||||||
|
@ -35,15 +36,15 @@ IAudioRenderer::IAudioRenderer(Core::System& system_, Manager& manager_,
|
||||||
// clang-format on
|
// clang-format on
|
||||||
RegisterHandlers(functions);
|
RegisterHandlers(functions);
|
||||||
|
|
||||||
process.Open();
|
process_handle->Open();
|
||||||
impl->Initialize(params, transfer_memory, transfer_memory_size, process_handle, process,
|
impl->Initialize(params, transfer_memory, transfer_memory_size, process_handle,
|
||||||
applet_resource_user_id, session_id);
|
applet_resource_user_id, session_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
IAudioRenderer::~IAudioRenderer() {
|
IAudioRenderer::~IAudioRenderer() {
|
||||||
impl->Finalize();
|
impl->Finalize();
|
||||||
service_context.CloseEvent(rendered_event);
|
service_context.CloseEvent(rendered_event);
|
||||||
process.Close();
|
process_handle->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IAudioRenderer::GetSampleRate(HLERequestContext& ctx) {
|
void IAudioRenderer::GetSampleRate(HLERequestContext& ctx) {
|
||||||
|
|
|
@ -14,8 +14,8 @@ public:
|
||||||
explicit IAudioRenderer(Core::System& system_, AudioCore::Renderer::Manager& manager_,
|
explicit IAudioRenderer(Core::System& system_, AudioCore::Renderer::Manager& manager_,
|
||||||
AudioCore::AudioRendererParameterInternal& params,
|
AudioCore::AudioRendererParameterInternal& params,
|
||||||
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
|
||||||
u32 process_handle, Kernel::KProcess& process_,
|
Kernel::KProcess* process_handle_, u64 applet_resource_user_id,
|
||||||
u64 applet_resource_user_id, s32 session_id);
|
s32 session_id);
|
||||||
~IAudioRenderer() override;
|
~IAudioRenderer() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -37,7 +37,7 @@ private:
|
||||||
Kernel::KEvent* rendered_event;
|
Kernel::KEvent* rendered_event;
|
||||||
AudioCore::Renderer::Manager& manager;
|
AudioCore::Renderer::Manager& manager;
|
||||||
std::unique_ptr<AudioCore::Renderer::Renderer> impl;
|
std::unique_ptr<AudioCore::Renderer::Renderer> impl;
|
||||||
Kernel::KProcess& process;
|
Kernel::KProcess* process_handle;
|
||||||
Common::ScratchBuffer<u8> output_buffer;
|
Common::ScratchBuffer<u8> output_buffer;
|
||||||
Common::ScratchBuffer<u8> performance_buffer;
|
Common::ScratchBuffer<u8> performance_buffer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,22 +8,21 @@
|
||||||
#include "core/hle/service/audio/audio_device.h"
|
#include "core/hle/service/audio/audio_device.h"
|
||||||
#include "core/hle/service/audio/audio_renderer.h"
|
#include "core/hle/service/audio/audio_renderer.h"
|
||||||
#include "core/hle/service/audio/audio_renderer_manager.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 {
|
namespace Service::Audio {
|
||||||
|
|
||||||
using namespace AudioCore::Renderer;
|
using namespace AudioCore::Renderer;
|
||||||
|
|
||||||
IAudioRendererManager::IAudioRendererManager(Core::System& system_)
|
IAudioRendererManager::IAudioRendererManager(Core::System& system_)
|
||||||
: ServiceFramework{system_, "audren:u"}, service_context{system_, "audren:u"},
|
: ServiceFramework{system_, "audren:u"}, impl{std::make_unique<Manager>(system_)} {
|
||||||
impl{std::make_unique<Manager>(system_)} {
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const FunctionInfo functions[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0, &IAudioRendererManager::OpenAudioRenderer, "OpenAudioRenderer"},
|
{0, C<&IAudioRendererManager::OpenAudioRenderer>, "OpenAudioRenderer"},
|
||||||
{1, &IAudioRendererManager::GetWorkBufferSize, "GetWorkBufferSize"},
|
{1, C<&IAudioRendererManager::GetWorkBufferSize>, "GetWorkBufferSize"},
|
||||||
{2, &IAudioRendererManager::GetAudioDeviceService, "GetAudioDeviceService"},
|
{2, C<&IAudioRendererManager::GetAudioDeviceService>, "GetAudioDeviceService"},
|
||||||
{3, nullptr, "OpenAudioRendererForManualExecution"},
|
{3, nullptr, "OpenAudioRendererForManualExecution"},
|
||||||
{4, &IAudioRendererManager::GetAudioDeviceServiceWithRevisionInfo, "GetAudioDeviceServiceWithRevisionInfo"},
|
{4, C<&IAudioRendererManager::GetAudioDeviceServiceWithRevisionInfo>, "GetAudioDeviceServiceWithRevisionInfo"},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
@ -32,53 +31,38 @@ IAudioRendererManager::IAudioRendererManager(Core::System& system_)
|
||||||
|
|
||||||
IAudioRendererManager::~IAudioRendererManager() = default;
|
IAudioRendererManager::~IAudioRendererManager() = default;
|
||||||
|
|
||||||
void IAudioRendererManager::OpenAudioRenderer(HLERequestContext& ctx) {
|
Result IAudioRendererManager::OpenAudioRenderer(
|
||||||
IPC::RequestParser rp{ctx};
|
Out<SharedPointer<IAudioRenderer>> out_audio_renderer,
|
||||||
|
AudioCore::AudioRendererParameterInternal parameter,
|
||||||
AudioCore::AudioRendererParameterInternal params;
|
InCopyHandle<Kernel::KTransferMemory> tmem_handle, u64 tmem_size,
|
||||||
rp.PopRaw<AudioCore::AudioRendererParameterInternal>(params);
|
InCopyHandle<Kernel::KProcess> process_handle, ClientAppletResourceUserId aruid) {
|
||||||
rp.Skip(1, false);
|
LOG_DEBUG(Service_Audio, "called");
|
||||||
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);
|
|
||||||
|
|
||||||
if (impl->GetSessionCount() + 1 > AudioCore::MaxRendererSessions) {
|
if (impl->GetSessionCount() + 1 > AudioCore::MaxRendererSessions) {
|
||||||
LOG_ERROR(Service_Audio, "Too many AudioRenderer sessions open!");
|
LOG_ERROR(Service_Audio, "Too many AudioRenderer sessions open!");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_THROW(Audio::ResultOutOfSessions);
|
||||||
rb.Push(Audio::ResultOutOfSessions);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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()};
|
const auto session_id{impl->GetSessionId()};
|
||||||
if (session_id == -1) {
|
if (session_id == -1) {
|
||||||
LOG_ERROR(Service_Audio, "Tried to open a session that's already in use!");
|
LOG_ERROR(Service_Audio, "Tried to open a session that's already in use!");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
R_THROW(Audio::ResultOutOfSessions);
|
||||||
rb.Push(Audio::ResultOutOfSessions);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG(Service_Audio, "Opened new AudioRenderer session {} sessions open {}", session_id,
|
LOG_DEBUG(Service_Audio, "Opened new AudioRenderer session {} sessions open {}", session_id,
|
||||||
impl->GetSessionCount());
|
impl->GetSessionCount());
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
*out_audio_renderer =
|
||||||
rb.Push(ResultSuccess);
|
std::make_shared<IAudioRenderer>(system, *impl, parameter, tmem_handle.Get(), tmem_size,
|
||||||
rb.PushIpcInterface<IAudioRenderer>(system, *impl, params, transfer_memory.GetPointerUnsafe(),
|
process_handle.Get(), aruid.pid, session_id);
|
||||||
transfer_memory_size, process_handle, *process,
|
R_SUCCEED();
|
||||||
applet_resource_user_id, session_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IAudioRendererManager::GetWorkBufferSize(HLERequestContext& ctx) {
|
Result IAudioRendererManager::GetWorkBufferSize(Out<u64> out_size,
|
||||||
AudioCore::AudioRendererParameterInternal params;
|
AudioCore::AudioRendererParameterInternal params) {
|
||||||
|
LOG_DEBUG(Service_Audio, "called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
R_TRY(impl->GetWorkBufferSize(params, *out_size))
|
||||||
rp.PopRaw<AudioCore::AudioRendererParameterInternal>(params);
|
|
||||||
|
|
||||||
u64 size{0};
|
|
||||||
auto result = impl->GetWorkBufferSize(params, size);
|
|
||||||
|
|
||||||
std::string output_info{};
|
std::string output_info{};
|
||||||
output_info += fmt::format("\tRevision {}", AudioCore::GetRevisionNum(params.revision));
|
output_info += fmt::format("\tRevision {}", AudioCore::GetRevisionNum(params.revision));
|
||||||
|
@ -95,49 +79,26 @@ void IAudioRendererManager::GetWorkBufferSize(HLERequestContext& ctx) {
|
||||||
params.external_context_size);
|
params.external_context_size);
|
||||||
|
|
||||||
LOG_DEBUG(Service_Audio, "called.\nInput params:\n{}\nOutput params:\n\tWorkbuffer size {:08X}",
|
LOG_DEBUG(Service_Audio, "called.\nInput params:\n{}\nOutput params:\n\tWorkbuffer size {:08X}",
|
||||||
output_info, size);
|
output_info, *out_size);
|
||||||
|
R_SUCCEED();
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
|
||||||
rb.Push(result);
|
|
||||||
rb.Push<u64>(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IAudioRendererManager::GetAudioDeviceService(HLERequestContext& ctx) {
|
Result IAudioRendererManager::GetAudioDeviceService(
|
||||||
IPC::RequestParser rp{ctx};
|
Out<SharedPointer<IAudioDevice>> out_audio_device, ClientAppletResourceUserId aruid) {
|
||||||
|
LOG_DEBUG(Service_Audio, "called, aruid={:#x}", aruid.pid);
|
||||||
const auto applet_resource_user_id = rp.Pop<u64>();
|
*out_audio_device = std::make_shared<IAudioDevice>(
|
||||||
|
system, aruid.pid, Common::MakeMagic('R', 'E', 'V', '1'), num_audio_devices++);
|
||||||
LOG_DEBUG(Service_Audio, "called. Applet resource id {}", applet_resource_user_id);
|
R_SUCCEED();
|
||||||
|
|
||||||
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++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IAudioRendererManager::OpenAudioRendererForManualExecution(HLERequestContext& ctx) {
|
Result IAudioRendererManager::GetAudioDeviceServiceWithRevisionInfo(
|
||||||
LOG_ERROR(Service_Audio, "called. Implement me!");
|
Out<SharedPointer<IAudioDevice>> out_audio_device, u32 revision,
|
||||||
}
|
ClientAppletResourceUserId aruid) {
|
||||||
|
LOG_DEBUG(Service_Audio, "called, revision={} aruid={:#x}", AudioCore::GetRevisionNum(revision),
|
||||||
void IAudioRendererManager::GetAudioDeviceServiceWithRevisionInfo(HLERequestContext& ctx) {
|
aruid.pid);
|
||||||
struct Parameters {
|
*out_audio_device =
|
||||||
u32 revision;
|
std::make_shared<IAudioDevice>(system, aruid.pid, revision, num_audio_devices++);
|
||||||
u64 applet_resource_user_id;
|
R_SUCCEED();
|
||||||
};
|
|
||||||
|
|
||||||
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++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Service::Audio
|
} // namespace Service::Audio
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "audio_core/audio_render_manager.h"
|
#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"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class System;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Service::Audio {
|
namespace Service::Audio {
|
||||||
|
|
||||||
|
class IAudioDevice;
|
||||||
class IAudioRenderer;
|
class IAudioRenderer;
|
||||||
|
|
||||||
class IAudioRendererManager final : public ServiceFramework<IAudioRendererManager> {
|
class IAudioRendererManager final : public ServiceFramework<IAudioRendererManager> {
|
||||||
|
@ -20,13 +18,18 @@ public:
|
||||||
~IAudioRendererManager() override;
|
~IAudioRendererManager() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OpenAudioRenderer(HLERequestContext& ctx);
|
Result OpenAudioRenderer(Out<SharedPointer<IAudioRenderer>> out_audio_renderer,
|
||||||
void GetWorkBufferSize(HLERequestContext& ctx);
|
AudioCore::AudioRendererParameterInternal parameter,
|
||||||
void GetAudioDeviceService(HLERequestContext& ctx);
|
InCopyHandle<Kernel::KTransferMemory> tmem_handle, u64 tmem_size,
|
||||||
void OpenAudioRendererForManualExecution(HLERequestContext& ctx);
|
InCopyHandle<Kernel::KProcess> process_handle,
|
||||||
void GetAudioDeviceServiceWithRevisionInfo(HLERequestContext& ctx);
|
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;
|
std::unique_ptr<AudioCore::Renderer::Manager> impl;
|
||||||
u32 num_audio_devices{0};
|
u32 num_audio_devices{0};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue