summaryrefslogtreecommitdiffstats
path: root/src/audio_core/renderer
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-02-23 17:34:21 +0100
committerGitHub <noreply@github.com>2024-02-23 17:34:21 +0100
commit215e887be088ed572da999e9ec7fd8559198524b (patch)
tree793415b72d36bb07d0174dfcf731f81235008936 /src/audio_core/renderer
parentMerge pull request #13073 from FearlessTobi/fsp-srv-ipc (diff)
parentoboe_sink: handle temporary stream creation failure (diff)
downloadyuzu-215e887be088ed572da999e9ec7fd8559198524b.tar
yuzu-215e887be088ed572da999e9ec7fd8559198524b.tar.gz
yuzu-215e887be088ed572da999e9ec7fd8559198524b.tar.bz2
yuzu-215e887be088ed572da999e9ec7fd8559198524b.tar.lz
yuzu-215e887be088ed572da999e9ec7fd8559198524b.tar.xz
yuzu-215e887be088ed572da999e9ec7fd8559198524b.tar.zst
yuzu-215e887be088ed572da999e9ec7fd8559198524b.zip
Diffstat (limited to 'src/audio_core/renderer')
-rw-r--r--src/audio_core/renderer/audio_device.cpp14
-rw-r--r--src/audio_core/renderer/audio_device.h6
-rw-r--r--src/audio_core/renderer/audio_renderer.cpp7
-rw-r--r--src/audio_core/renderer/audio_renderer.h4
-rw-r--r--src/audio_core/renderer/behavior/info_updater.cpp2
-rw-r--r--src/audio_core/renderer/behavior/info_updater.h10
-rw-r--r--src/audio_core/renderer/memory/pool_mapper.cpp18
-rw-r--r--src/audio_core/renderer/memory/pool_mapper.h14
-rw-r--r--src/audio_core/renderer/system.cpp10
-rw-r--r--src/audio_core/renderer/system.h8
10 files changed, 48 insertions, 45 deletions
diff --git a/src/audio_core/renderer/audio_device.cpp b/src/audio_core/renderer/audio_device.cpp
index 2d9bf82bb..5be5594f6 100644
--- a/src/audio_core/renderer/audio_device.cpp
+++ b/src/audio_core/renderer/audio_device.cpp
@@ -36,8 +36,7 @@ AudioDevice::AudioDevice(Core::System& system, const u64 applet_resource_user_id
: output_sink{system.AudioCore().GetOutputSink()},
applet_resource_user_id{applet_resource_user_id_}, user_revision{revision} {}
-u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
- const size_t max_count) const {
+u32 AudioDevice::ListAudioDeviceName(std::span<AudioDeviceName> out_buffer) const {
std::span<const AudioDeviceName> names{};
if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) {
@@ -46,19 +45,18 @@ u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
names = device_names;
}
- const u32 out_count{static_cast<u32>(std::min(max_count, names.size()))};
+ const u32 out_count{static_cast<u32>(std::min(out_buffer.size(), names.size()))};
for (u32 i = 0; i < out_count; i++) {
- out_buffer.push_back(names[i]);
+ out_buffer[i] = names[i];
}
return out_count;
}
-u32 AudioDevice::ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer,
- const size_t max_count) const {
- const u32 out_count{static_cast<u32>(std::min(max_count, output_device_names.size()))};
+u32 AudioDevice::ListAudioOutputDeviceName(std::span<AudioDeviceName> out_buffer) const {
+ const u32 out_count{static_cast<u32>(std::min(out_buffer.size(), output_device_names.size()))};
for (u32 i = 0; i < out_count; i++) {
- out_buffer.push_back(output_device_names[i]);
+ out_buffer[i] = output_device_names[i];
}
return out_count;
}
diff --git a/src/audio_core/renderer/audio_device.h b/src/audio_core/renderer/audio_device.h
index ca4040add..4242dad30 100644
--- a/src/audio_core/renderer/audio_device.h
+++ b/src/audio_core/renderer/audio_device.h
@@ -36,20 +36,18 @@ public:
* Get a list of the available output devices.
*
* @param out_buffer - Output buffer to write the available device names.
- * @param max_count - Maximum number of devices to write (count of out_buffer).
* @return Number of device names written.
*/
- u32 ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count) const;
+ u32 ListAudioDeviceName(std::span<AudioDeviceName> out_buffer) const;
/**
* Get a list of the available output devices.
* Different to above somehow...
*
* @param out_buffer - Output buffer to write the available device names.
- * @param max_count - Maximum number of devices to write (count of out_buffer).
* @return Number of device names written.
*/
- u32 ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count) const;
+ u32 ListAudioOutputDeviceName(std::span<AudioDeviceName> out_buffer) const;
/**
* Set the volume of all streams in the backend sink.
diff --git a/src/audio_core/renderer/audio_renderer.cpp b/src/audio_core/renderer/audio_renderer.cpp
index df03d03aa..7c728cb86 100644
--- a/src/audio_core/renderer/audio_renderer.cpp
+++ b/src/audio_core/renderer/audio_renderer.cpp
@@ -17,9 +17,8 @@ Renderer::Renderer(Core::System& system_, Manager& manager_, Kernel::KEvent* ren
Result Renderer::Initialize(const AudioRendererParameterInternal& params,
Kernel::KTransferMemory* transfer_memory,
- const u64 transfer_memory_size, const u32 process_handle,
- Kernel::KProcess& process, const u64 applet_resource_user_id,
- const s32 session_id) {
+ const u64 transfer_memory_size, Kernel::KProcess* process_handle,
+ const u64 applet_resource_user_id, const s32 session_id) {
if (params.execution_mode == ExecutionMode::Auto) {
if (!manager.AddSystem(system)) {
LOG_ERROR(Service_Audio,
@@ -30,7 +29,7 @@ Result Renderer::Initialize(const AudioRendererParameterInternal& params,
}
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);
return ResultSuccess;
diff --git a/src/audio_core/renderer/audio_renderer.h b/src/audio_core/renderer/audio_renderer.h
index 1219f74ca..f16adeda7 100644
--- a/src/audio_core/renderer/audio_renderer.h
+++ b/src/audio_core/renderer/audio_renderer.h
@@ -38,14 +38,14 @@ public:
* @param params - Input parameters to initialize the system with.
* @param transfer_memory - Game-supplied memory for all workbuffers. 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 session_id - Session id of this renderer.
* @return Result code.
*/
Result Initialize(const AudioRendererParameterInternal& params,
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);
/**
diff --git a/src/audio_core/renderer/behavior/info_updater.cpp b/src/audio_core/renderer/behavior/info_updater.cpp
index 667711e17..3dae6069f 100644
--- a/src/audio_core/renderer/behavior/info_updater.cpp
+++ b/src/audio_core/renderer/behavior/info_updater.cpp
@@ -18,7 +18,7 @@
namespace AudioCore::Renderer {
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_origin{input_}, output{output_.data() + sizeof(UpdateDataHeader)},
output_origin{output_}, in_header{reinterpret_cast<const UpdateDataHeader*>(
diff --git a/src/audio_core/renderer/behavior/info_updater.h b/src/audio_core/renderer/behavior/info_updater.h
index fb4b7d25a..4f27a817e 100644
--- a/src/audio_core/renderer/behavior/info_updater.h
+++ b/src/audio_core/renderer/behavior/info_updater.h
@@ -8,6 +8,10 @@
#include "common/common_types.h"
#include "core/hle/service/audio/errors.h"
+namespace Kernel {
+class KProcess;
+}
+
namespace AudioCore::Renderer {
class BehaviorInfo;
class VoiceContext;
@@ -39,8 +43,8 @@ class InfoUpdater {
static_assert(sizeof(UpdateDataHeader) == 0x40, "UpdateDataHeader has the wrong size!");
public:
- explicit InfoUpdater(std::span<const u8> input, std::span<u8> output, u32 process_handle,
- BehaviorInfo& behaviour);
+ explicit InfoUpdater(std::span<const u8> input, std::span<u8> output,
+ Kernel::KProcess* process_handle, BehaviorInfo& behaviour);
/**
* Update the voice channel resources.
@@ -197,7 +201,7 @@ private:
/// Expected output size, see CheckConsumedSize
u64 expected_output_size;
/// Unused
- u32 process_handle;
+ Kernel::KProcess* process_handle;
/// Behaviour
BehaviorInfo& behaviour;
};
diff --git a/src/audio_core/renderer/memory/pool_mapper.cpp b/src/audio_core/renderer/memory/pool_mapper.cpp
index 999bb746b..e47eb66d5 100644
--- a/src/audio_core/renderer/memory/pool_mapper.cpp
+++ b/src/audio_core/renderer/memory/pool_mapper.cpp
@@ -8,11 +8,11 @@
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_} {}
-PoolMapper::PoolMapper(u32 process_handle_, std::span<MemoryPoolInfo> pool_infos_, u32 pool_count_,
- bool force_map_)
+PoolMapper::PoolMapper(Kernel::KProcess* process_handle_, std::span<MemoryPoolInfo> pool_infos_,
+ u32 pool_count_, bool force_map_)
: process_handle{process_handle_}, pool_infos{pool_infos_.data()},
pool_count{pool_count_}, force_map{force_map_} {}
@@ -106,15 +106,17 @@ bool PoolMapper::IsForceMapEnabled() const {
return force_map;
}
-u32 PoolMapper::GetProcessHandle(const MemoryPoolInfo* pool) const {
+Kernel::KProcess* PoolMapper::GetProcessHandle(const MemoryPoolInfo* pool) const {
switch (pool->GetLocation()) {
case MemoryPoolInfo::Location::CPU:
return process_handle;
case MemoryPoolInfo::Location::DSP:
- return Kernel::Svc::CurrentProcess;
+ // return Kernel::Svc::CurrentProcess;
+ return nullptr;
}
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,
@@ -147,14 +149,14 @@ bool PoolMapper::Unmap([[maybe_unused]] const u32 handle, [[maybe_unused]] const
}
bool PoolMapper::Unmap(MemoryPoolInfo& pool) const {
- [[maybe_unused]] u32 handle{0};
+ [[maybe_unused]] Kernel::KProcess* handle{};
switch (pool.GetLocation()) {
case MemoryPoolInfo::Location::CPU:
handle = process_handle;
break;
case MemoryPoolInfo::Location::DSP:
- handle = Kernel::Svc::CurrentProcess;
+ // handle = Kernel::Svc::CurrentProcess;
break;
}
// nn::audio::dsp::UnmapUserPointer(handle, pool->cpu_address, pool->size);
diff --git a/src/audio_core/renderer/memory/pool_mapper.h b/src/audio_core/renderer/memory/pool_mapper.h
index 95ae5d8ea..fb5122b73 100644
--- a/src/audio_core/renderer/memory/pool_mapper.h
+++ b/src/audio_core/renderer/memory/pool_mapper.h
@@ -10,6 +10,10 @@
#include "common/common_types.h"
#include "core/hle/service/audio/errors.h"
+namespace Kernel {
+class KProcess;
+}
+
namespace AudioCore::Renderer {
class AddressInfo;
@@ -18,9 +22,9 @@ class AddressInfo;
*/
class PoolMapper {
public:
- explicit PoolMapper(u32 process_handle, bool force_map);
- explicit PoolMapper(u32 process_handle, std::span<MemoryPoolInfo> pool_infos, u32 pool_count,
- bool force_map);
+ explicit PoolMapper(Kernel::KProcess* process_handle, bool force_map);
+ explicit PoolMapper(Kernel::KProcess* process_handle, std::span<MemoryPoolInfo> pool_infos,
+ u32 pool_count, bool force_map);
/**
* Clear the usage state for all given pools.
@@ -98,7 +102,7 @@ public:
* @return CurrentProcessHandle if location == DSP,
* 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.
@@ -167,7 +171,7 @@ public:
private:
/// Process handle for this mapper, used when location == CPU
- u32 process_handle;
+ Kernel::KProcess* process_handle{};
/// List of memory pools assigned to this mapper
MemoryPoolInfo* pool_infos{};
/// The number of pools
diff --git a/src/audio_core/renderer/system.cpp b/src/audio_core/renderer/system.cpp
index ca656edae..c30d68426 100644
--- a/src/audio_core/renderer/system.cpp
+++ b/src/audio_core/renderer/system.cpp
@@ -102,8 +102,8 @@ System::System(Core::System& core_, Kernel::KEvent* adsp_rendered_event_)
Result System::Initialize(const 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_) {
if (!CheckValidRevision(params.revision)) {
return Service::Audio::ResultInvalidRevision;
}
@@ -119,7 +119,6 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
behavior.SetUserLibRevision(params.revision);
process_handle = process_handle_;
- process = &process_;
applet_resource_user_id = applet_resource_user_id_;
session_id = session_id_;
@@ -132,7 +131,8 @@ Result System::Initialize(const AudioRendererParameterInternal& params,
render_device = params.rendering_device;
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.
// 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<f32>(render_time_limit_percent) / 100.0f))};
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 = false;
command_buffer_size = command_size;
diff --git a/src/audio_core/renderer/system.h b/src/audio_core/renderer/system.h
index 753a0b796..3533a74ef 100644
--- a/src/audio_core/renderer/system.h
+++ b/src/audio_core/renderer/system.h
@@ -74,14 +74,14 @@ public:
* @param params - Input parameters to initialize the system with.
* @param transfer_memory - Game-supplied memory for all workbuffers. 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 session_id - Session id of this renderer.
* @return Result code.
*/
Result Initialize(const AudioRendererParameterInternal& params,
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);
/**
@@ -278,9 +278,7 @@ private:
/// Does what locks do
std::mutex lock{};
/// Process this audio render is operating within, used for memory reads/writes.
- Kernel::KProcess* process{};
- /// Handle for the process for this system, unused
- u32 process_handle{};
+ Kernel::KProcess* process_handle{};
/// Applet resource id for this system, unused
u64 applet_resource_user_id{};
/// Controls performance input and output