summaryrefslogtreecommitdiffstats
path: root/src/audio_core/renderer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audio_core/renderer/adsp/adsp.cpp2
-rw-r--r--src/audio_core/renderer/adsp/adsp.h4
-rw-r--r--src/audio_core/renderer/adsp/audio_renderer.cpp11
-rw-r--r--src/audio_core/renderer/adsp/audio_renderer.h8
-rw-r--r--src/audio_core/renderer/adsp/command_list_processor.h13
-rw-r--r--src/audio_core/renderer/audio_device.cpp34
-rw-r--r--src/audio_core/renderer/audio_device.h22
-rw-r--r--src/audio_core/renderer/behavior/behavior_info.cpp16
-rw-r--r--src/audio_core/renderer/behavior/behavior_info.h4
-rw-r--r--src/audio_core/renderer/behavior/info_updater.cpp2
-rw-r--r--src/audio_core/renderer/behavior/info_updater.h2
-rw-r--r--src/audio_core/renderer/command/command_buffer.h12
-rw-r--r--src/audio_core/renderer/command/command_generator.h46
-rw-r--r--src/audio_core/renderer/command/effect/compressor.cpp11
-rw-r--r--src/audio_core/renderer/command/mix/mix_ramp.cpp18
-rw-r--r--src/audio_core/renderer/command/mix/mix_ramp.h8
-rw-r--r--src/audio_core/renderer/command/mix/mix_ramp_grouped.h4
-rw-r--r--src/audio_core/renderer/command/sink/device.cpp4
-rw-r--r--src/audio_core/renderer/effect/effect_context.h14
-rw-r--r--src/audio_core/renderer/effect/effect_info_base.h4
-rw-r--r--src/audio_core/renderer/effect/i3dl2.h4
-rw-r--r--src/audio_core/renderer/effect/reverb.h4
-rw-r--r--src/audio_core/renderer/memory/address_info.h5
-rw-r--r--src/audio_core/renderer/nodes/node_states.h8
-rw-r--r--src/audio_core/renderer/performance/performance_manager.h8
-rw-r--r--src/audio_core/renderer/system_manager.cpp46
-rw-r--r--src/audio_core/renderer/system_manager.h9
-rw-r--r--src/audio_core/renderer/upsampler/upsampler_manager.h2
-rw-r--r--src/audio_core/renderer/voice/voice_info.h26
29 files changed, 155 insertions, 196 deletions
diff --git a/src/audio_core/renderer/adsp/adsp.cpp b/src/audio_core/renderer/adsp/adsp.cpp
index e05a22d86..a28395663 100644
--- a/src/audio_core/renderer/adsp/adsp.cpp
+++ b/src/audio_core/renderer/adsp/adsp.cpp
@@ -50,7 +50,7 @@ u32 ADSP::GetRemainCommandCount(const u32 session_id) const {
return render_mailbox.GetRemainCommandCount(session_id);
}
-void ADSP::SendCommandBuffer(const u32 session_id, CommandBuffer& command_buffer) {
+void ADSP::SendCommandBuffer(const u32 session_id, const CommandBuffer& command_buffer) {
render_mailbox.SetCommandBuffer(session_id, command_buffer);
}
diff --git a/src/audio_core/renderer/adsp/adsp.h b/src/audio_core/renderer/adsp/adsp.h
index 4dfcef4a5..f7a2f25e4 100644
--- a/src/audio_core/renderer/adsp/adsp.h
+++ b/src/audio_core/renderer/adsp/adsp.h
@@ -63,8 +63,6 @@ public:
/**
* Stop the ADSP.
- *
- * @return True if started or already running, otherwise false.
*/
void Stop();
@@ -133,7 +131,7 @@ public:
* @param session_id - The session id to check (0 or 1).
* @param command_buffer - The command buffer to process.
*/
- void SendCommandBuffer(u32 session_id, CommandBuffer& command_buffer);
+ void SendCommandBuffer(u32 session_id, const CommandBuffer& command_buffer);
/**
* Clear the command buffers (does not clear the time taken or the remaining command count)
diff --git a/src/audio_core/renderer/adsp/audio_renderer.cpp b/src/audio_core/renderer/adsp/audio_renderer.cpp
index 3967ccfe6..bafe4822a 100644
--- a/src/audio_core/renderer/adsp/audio_renderer.cpp
+++ b/src/audio_core/renderer/adsp/audio_renderer.cpp
@@ -51,7 +51,7 @@ CommandBuffer& AudioRenderer_Mailbox::GetCommandBuffer(const s32 session_id) {
return command_buffers[session_id];
}
-void AudioRenderer_Mailbox::SetCommandBuffer(const u32 session_id, CommandBuffer& buffer) {
+void AudioRenderer_Mailbox::SetCommandBuffer(const u32 session_id, const CommandBuffer& buffer) {
command_buffers[session_id] = buffer;
}
@@ -106,9 +106,6 @@ void AudioRenderer::Start(AudioRenderer_Mailbox* mailbox_) {
mailbox = mailbox_;
thread = std::thread(&AudioRenderer::ThreadFunc, this);
- for (auto& stream : streams) {
- stream->Start();
- }
running = true;
}
@@ -130,6 +127,7 @@ void AudioRenderer::CreateSinkStreams() {
std::string name{fmt::format("ADSP_RenderStream-{}", i)};
streams[i] =
sink.AcquireSinkStream(system, channels, name, ::AudioCore::Sink::StreamType::Render);
+ streams[i]->SetRingSize(4);
}
}
@@ -198,11 +196,6 @@ void AudioRenderer::ThreadFunc() {
command_list_processor.Process(index) - start_time;
}
- if (index == 0) {
- auto stream{command_list_processor.GetOutputSinkStream()};
- system.AudioCore().SetStreamQueue(stream->GetQueueSize());
- }
-
const auto end_time{system.CoreTiming().GetClockTicks()};
command_buffer.remaining_command_count =
diff --git a/src/audio_core/renderer/adsp/audio_renderer.h b/src/audio_core/renderer/adsp/audio_renderer.h
index b6ced9d2b..02e923c84 100644
--- a/src/audio_core/renderer/adsp/audio_renderer.h
+++ b/src/audio_core/renderer/adsp/audio_renderer.h
@@ -52,7 +52,7 @@ public:
/**
* Send a message from the host to the AudioRenderer.
*
- * @param message_ - The message to send to the AudioRenderer.
+ * @param message - The message to send to the AudioRenderer.
*/
void HostSendMessage(RenderMessage message);
@@ -66,7 +66,7 @@ public:
/**
* Send a message from the AudioRenderer to the host.
*
- * @param message_ - The message to send to the host.
+ * @param message - The message to send to the host.
*/
void ADSPSendMessage(RenderMessage message);
@@ -91,7 +91,7 @@ public:
* @param session_id - The session id to get (0 or 1).
* @param buffer - The command buffer to set.
*/
- void SetCommandBuffer(u32 session_id, CommandBuffer& buffer);
+ void SetCommandBuffer(u32 session_id, const CommandBuffer& buffer);
/**
* Get the total render time taken for the last command lists sent.
@@ -163,7 +163,7 @@ public:
/**
* Start the AudioRenderer.
*
- * @param The mailbox to use for this session.
+ * @param mailbox The mailbox to use for this session.
*/
void Start(AudioRenderer_Mailbox* mailbox);
diff --git a/src/audio_core/renderer/adsp/command_list_processor.h b/src/audio_core/renderer/adsp/command_list_processor.h
index 3f99173e3..d78269e1d 100644
--- a/src/audio_core/renderer/adsp/command_list_processor.h
+++ b/src/audio_core/renderer/adsp/command_list_processor.h
@@ -33,10 +33,10 @@ public:
/**
* Initialize the processor.
*
- * @param system_ - The core system.
- * @param buffer - The command buffer to process.
- * @param size - The size of the buffer.
- * @param stream_ - The stream to be used for sending the samples.
+ * @param system - The core system.
+ * @param buffer - The command buffer to process.
+ * @param size - The size of the buffer.
+ * @param stream - The stream to be used for sending the samples.
*/
void Initialize(Core::System& system, CpuAddr buffer, u64 size, Sink::SinkStream* stream);
@@ -72,7 +72,8 @@ public:
/**
* Process the command list.
*
- * @param index - Index of the current command list.
+ * @param session_id - Session ID for the commands being processed.
+ *
* @return The time taken to process.
*/
u64 Process(u32 session_id);
@@ -89,7 +90,7 @@ public:
u8* commands{};
/// The command buffer size
u64 commands_buffer_size{};
- /// The maximum processing time alloted
+ /// The maximum processing time allotted
u64 max_process_time{};
/// The number of commands in the buffer
u32 command_count{};
diff --git a/src/audio_core/renderer/audio_device.cpp b/src/audio_core/renderer/audio_device.cpp
index d5886e55e..0d9d8f6ce 100644
--- a/src/audio_core/renderer/audio_device.cpp
+++ b/src/audio_core/renderer/audio_device.cpp
@@ -1,6 +1,9 @@
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include <array>
+#include <span>
+
#include "audio_core/audio_core.h"
#include "audio_core/common/feature_support.h"
#include "audio_core/renderer/audio_device.h"
@@ -9,14 +12,33 @@
namespace AudioCore::AudioRenderer {
+constexpr std::array usb_device_names{
+ AudioDevice::AudioDeviceName{"AudioStereoJackOutput"},
+ AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
+ AudioDevice::AudioDeviceName{"AudioTvOutput"},
+ AudioDevice::AudioDeviceName{"AudioUsbDeviceOutput"},
+};
+
+constexpr std::array device_names{
+ AudioDevice::AudioDeviceName{"AudioStereoJackOutput"},
+ AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
+ AudioDevice::AudioDeviceName{"AudioTvOutput"},
+};
+
+constexpr std::array output_device_names{
+ AudioDevice::AudioDeviceName{"AudioBuiltInSpeakerOutput"},
+ AudioDevice::AudioDeviceName{"AudioTvOutput"},
+ AudioDevice::AudioDeviceName{"AudioExternalOutput"},
+};
+
AudioDevice::AudioDevice(Core::System& system, const u64 applet_resource_user_id_,
const u32 revision)
: 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) {
- std::span<AudioDeviceName> names{};
+ const size_t max_count) const {
+ std::span<const AudioDeviceName> names{};
if (CheckFeatureSupported(SupportTags::AudioUsbDeviceOutput, user_revision)) {
names = usb_device_names;
@@ -24,7 +46,7 @@ u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
names = device_names;
}
- u32 out_count{static_cast<u32>(std::min(max_count, names.size()))};
+ const u32 out_count{static_cast<u32>(std::min(max_count, names.size()))};
for (u32 i = 0; i < out_count; i++) {
out_buffer.push_back(names[i]);
}
@@ -32,8 +54,8 @@ u32 AudioDevice::ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer,
}
u32 AudioDevice::ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer,
- const size_t max_count) {
- u32 out_count{static_cast<u32>(std::min(max_count, output_device_names.size()))};
+ const size_t max_count) const {
+ const u32 out_count{static_cast<u32>(std::min(max_count, output_device_names.size()))};
for (u32 i = 0; i < out_count; i++) {
out_buffer.push_back(output_device_names[i]);
@@ -45,7 +67,7 @@ void AudioDevice::SetDeviceVolumes(const f32 volume) {
output_sink.SetDeviceVolume(volume);
}
-f32 AudioDevice::GetDeviceVolume([[maybe_unused]] std::string_view name) {
+f32 AudioDevice::GetDeviceVolume([[maybe_unused]] std::string_view name) const {
return output_sink.GetDeviceVolume();
}
diff --git a/src/audio_core/renderer/audio_device.h b/src/audio_core/renderer/audio_device.h
index 1f449f261..dd6be70ee 100644
--- a/src/audio_core/renderer/audio_device.h
+++ b/src/audio_core/renderer/audio_device.h
@@ -3,7 +3,7 @@
#pragma once
-#include <span>
+#include <string_view>
#include "audio_core/audio_render_manager.h"
@@ -23,21 +23,13 @@ namespace AudioRenderer {
class AudioDevice {
public:
struct AudioDeviceName {
- std::array<char, 0x100> name;
+ std::array<char, 0x100> name{};
- AudioDeviceName(const char* name_) {
- std::strncpy(name.data(), name_, name.size());
+ constexpr AudioDeviceName(std::string_view name_) {
+ name_.copy(name.data(), name.size() - 1);
}
};
- std::array<AudioDeviceName, 4> usb_device_names{"AudioStereoJackOutput",
- "AudioBuiltInSpeakerOutput", "AudioTvOutput",
- "AudioUsbDeviceOutput"};
- std::array<AudioDeviceName, 3> device_names{"AudioStereoJackOutput",
- "AudioBuiltInSpeakerOutput", "AudioTvOutput"};
- std::array<AudioDeviceName, 3> output_device_names{"AudioBuiltInSpeakerOutput", "AudioTvOutput",
- "AudioExternalOutput"};
-
explicit AudioDevice(Core::System& system, u64 applet_resource_user_id, u32 revision);
/**
@@ -47,7 +39,7 @@ public:
* @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);
+ u32 ListAudioDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count) const;
/**
* Get a list of the available output devices.
@@ -57,7 +49,7 @@ public:
* @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);
+ u32 ListAudioOutputDeviceName(std::vector<AudioDeviceName>& out_buffer, size_t max_count) const;
/**
* Set the volume of all streams in the backend sink.
@@ -73,7 +65,7 @@ public:
* @param name - Name of the device to check. Unused.
* @return Volume of the device.
*/
- f32 GetDeviceVolume(std::string_view name);
+ f32 GetDeviceVolume(std::string_view name) const;
private:
/// Backend output sink for the device
diff --git a/src/audio_core/renderer/behavior/behavior_info.cpp b/src/audio_core/renderer/behavior/behavior_info.cpp
index c5d4d66d8..3d2a91312 100644
--- a/src/audio_core/renderer/behavior/behavior_info.cpp
+++ b/src/audio_core/renderer/behavior/behavior_info.cpp
@@ -34,7 +34,7 @@ void BehaviorInfo::ClearError() {
error_count = 0;
}
-void BehaviorInfo::AppendError(ErrorInfo& error) {
+void BehaviorInfo::AppendError(const ErrorInfo& error) {
LOG_ERROR(Service_Audio, "Error during RequestUpdate, reporting code {:04X} address {:08X}",
error.error_code.raw, error.address);
if (error_count < MaxErrors) {
@@ -42,14 +42,16 @@ void BehaviorInfo::AppendError(ErrorInfo& error) {
}
}
-void BehaviorInfo::CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count) {
- auto error_count_{std::min(error_count, MaxErrors)};
- std::memset(out_errors.data(), 0, MaxErrors * sizeof(ErrorInfo));
+void BehaviorInfo::CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count) const {
+ out_count = std::min(error_count, MaxErrors);
- for (size_t i = 0; i < error_count_; i++) {
- out_errors[i] = errors[i];
+ for (size_t i = 0; i < MaxErrors; i++) {
+ if (i < out_count) {
+ out_errors[i] = errors[i];
+ } else {
+ out_errors[i] = {};
+ }
}
- out_count = error_count_;
}
void BehaviorInfo::UpdateFlags(const Flags flags_) {
diff --git a/src/audio_core/renderer/behavior/behavior_info.h b/src/audio_core/renderer/behavior/behavior_info.h
index 7333c297f..15c948344 100644
--- a/src/audio_core/renderer/behavior/behavior_info.h
+++ b/src/audio_core/renderer/behavior/behavior_info.h
@@ -94,7 +94,7 @@ public:
*
* @param error - The new error.
*/
- void AppendError(ErrorInfo& error);
+ void AppendError(const ErrorInfo& error);
/**
* Copy errors to the given output container.
@@ -102,7 +102,7 @@ public:
* @param out_errors - Output container to receive the errors.
* @param out_count - The number of errors written.
*/
- void CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count);
+ void CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count) const;
/**
* Update the behaviour flags.
diff --git a/src/audio_core/renderer/behavior/info_updater.cpp b/src/audio_core/renderer/behavior/info_updater.cpp
index 06a37e1a6..c0a307b89 100644
--- a/src/audio_core/renderer/behavior/info_updater.cpp
+++ b/src/audio_core/renderer/behavior/info_updater.cpp
@@ -485,7 +485,7 @@ Result InfoUpdater::UpdateBehaviorInfo(BehaviorInfo& behaviour_) {
return ResultSuccess;
}
-Result InfoUpdater::UpdateErrorInfo(BehaviorInfo& behaviour_) {
+Result InfoUpdater::UpdateErrorInfo(const BehaviorInfo& behaviour_) {
auto out_params{reinterpret_cast<BehaviorInfo::OutStatus*>(output)};
behaviour_.CopyErrorInfo(out_params->errors, out_params->error_count);
diff --git a/src/audio_core/renderer/behavior/info_updater.h b/src/audio_core/renderer/behavior/info_updater.h
index f0b445d9c..c817d8d8d 100644
--- a/src/audio_core/renderer/behavior/info_updater.h
+++ b/src/audio_core/renderer/behavior/info_updater.h
@@ -130,7 +130,7 @@ public:
* @param behaviour - Behaviour to update.
* @return Result code.
*/
- Result UpdateErrorInfo(BehaviorInfo& behaviour);
+ Result UpdateErrorInfo(const BehaviorInfo& behaviour);
/**
* Update splitter.
diff --git a/src/audio_core/renderer/command/command_buffer.h b/src/audio_core/renderer/command/command_buffer.h
index 496b0e50a..162170846 100644
--- a/src/audio_core/renderer/command/command_buffer.h
+++ b/src/audio_core/renderer/command/command_buffer.h
@@ -191,6 +191,7 @@ public:
* @param volume - Current mix volume used for calculating the ramp.
* @param prev_volume - Previous mix volume, used for calculating the ramp,
* also applied to the input.
+ * @param prev_samples - Previous sample buffer. Used for depopping.
* @param precision - Number of decimal bits for fixed point operations.
*/
void GenerateMixRampCommand(s32 node_id, s16 buffer_count, s16 input_index, s16 output_index,
@@ -208,6 +209,7 @@ public:
* @param volumes - Current mix volumes used for calculating the ramp.
* @param prev_volumes - Previous mix volumes, used for calculating the ramp,
* also applied to the input.
+ * @param prev_samples - Previous sample buffer. Used for depopping.
* @param precision - Number of decimal bits for fixed point operations.
*/
void GenerateMixRampGroupedCommand(s32 node_id, s16 buffer_count, s16 input_index,
@@ -297,11 +299,11 @@ public:
/**
* Generate a device sink command, adding it to the command list.
*
- * @param node_id - Node id of the voice this command is generated for.
- * @param buffer_offset - Base mix buffer offset to use.
- * @param sink_info - The sink_info to generate this command from.
- * @session_id - System session id this command is generated from.
- * @samples_buffer - The buffer to be sent to the sink if upsampling is not used.
+ * @param node_id - Node id of the voice this command is generated for.
+ * @param buffer_offset - Base mix buffer offset to use.
+ * @param sink_info - The sink_info to generate this command from.
+ * @param session_id - System session id this command is generated from.
+ * @param samples_buffer - The buffer to be sent to the sink if upsampling is not used.
*/
void GenerateDeviceSinkCommand(s32 node_id, s16 buffer_offset, SinkInfoBase& sink_info,
u32 session_id, std::span<s32> samples_buffer);
diff --git a/src/audio_core/renderer/command/command_generator.h b/src/audio_core/renderer/command/command_generator.h
index d80d9b0d8..b3cd7b408 100644
--- a/src/audio_core/renderer/command/command_generator.h
+++ b/src/audio_core/renderer/command/command_generator.h
@@ -197,9 +197,9 @@ public:
/**
* Generate an I3DL2 reverb effect command.
*
- * @param buffer_offset - Base mix buffer offset to use.
- * @param effect_info_base - I3DL2Reverb effect info.
- * @param node_id - Node id of the mix this command is generated for.
+ * @param buffer_offset - Base mix buffer offset to use.
+ * @param effect_info - I3DL2Reverb effect info.
+ * @param node_id - Node id of the mix this command is generated for.
*/
void GenerateI3dl2ReverbEffectCommand(s16 buffer_offset, EffectInfoBase& effect_info,
s32 node_id);
@@ -207,18 +207,18 @@ public:
/**
* Generate an aux effect command.
*
- * @param buffer_offset - Base mix buffer offset to use.
- * @param effect_info_base - Aux effect info.
- * @param node_id - Node id of the mix this command is generated for.
+ * @param buffer_offset - Base mix buffer offset to use.
+ * @param effect_info - Aux effect info.
+ * @param node_id - Node id of the mix this command is generated for.
*/
void GenerateAuxCommand(s16 buffer_offset, EffectInfoBase& effect_info, s32 node_id);
/**
* Generate a biquad filter effect command.
*
- * @param buffer_offset - Base mix buffer offset to use.
- * @param effect_info_base - Aux effect info.
- * @param node_id - Node id of the mix this command is generated for.
+ * @param buffer_offset - Base mix buffer offset to use.
+ * @param effect_info - Aux effect info.
+ * @param node_id - Node id of the mix this command is generated for.
*/
void GenerateBiquadFilterEffectCommand(s16 buffer_offset, EffectInfoBase& effect_info,
s32 node_id);
@@ -226,10 +226,10 @@ public:
/**
* Generate a light limiter effect command.
*
- * @param buffer_offset - Base mix buffer offset to use.
- * @param effect_info_base - Limiter effect info.
- * @param node_id - Node id of the mix this command is generated for.
- * @param effect_index - Index for the statistics state.
+ * @param buffer_offset - Base mix buffer offset to use.
+ * @param effect_info - Limiter effect info.
+ * @param node_id - Node id of the mix this command is generated for.
+ * @param effect_index - Index for the statistics state.
*/
void GenerateLightLimiterEffectCommand(s16 buffer_offset, EffectInfoBase& effect_info,
s32 node_id, u32 effect_index);
@@ -238,21 +238,20 @@ public:
* Generate a capture effect command.
* Writes a mix buffer back to game memory.
*
- * @param buffer_offset - Base mix buffer offset to use.
- * @param effect_info_base - Capture effect info.
- * @param node_id - Node id of the mix this command is generated for.
+ * @param buffer_offset - Base mix buffer offset to use.
+ * @param effect_info - Capture effect info.
+ * @param node_id - Node id of the mix this command is generated for.
*/
void GenerateCaptureCommand(s16 buffer_offset, EffectInfoBase& effect_info, s32 node_id);
/**
* Generate a compressor effect command.
*
- * @param buffer_offset - Base mix buffer offset to use.
- * @param effect_info_base - Compressor effect info.
- * @param node_id - Node id of the mix this command is generated for.
+ * @param buffer_offset - Base mix buffer offset to use.
+ * @param effect_info - Compressor effect info.
+ * @param node_id - Node id of the mix this command is generated for.
*/
- void GenerateCompressorCommand(const s16 buffer_offset, EffectInfoBase& effect_info,
- const s32 node_id);
+ void GenerateCompressorCommand(s16 buffer_offset, EffectInfoBase& effect_info, s32 node_id);
/**
* Generate all effect commands for a mix.
@@ -318,8 +317,9 @@ public:
* Generate a performance command.
* Used to report performance metrics of the AudioRenderer back to the game.
*
- * @param buffer_offset - Base mix buffer offset to use.
- * @param sink_info - Sink info to generate the commands from.
+ * @param node_id - Node ID of the mix this command is generated for
+ * @param state - Output state of the generated performance command
+ * @param entry_addresses - Addresses to be written
*/
void GeneratePerformanceCommand(s32 node_id, PerformanceState state,
const PerformanceEntryAddresses& entry_addresses);
diff --git a/src/audio_core/renderer/command/effect/compressor.cpp b/src/audio_core/renderer/command/effect/compressor.cpp
index 2ebc140f1..7229618e8 100644
--- a/src/audio_core/renderer/command/effect/compressor.cpp
+++ b/src/audio_core/renderer/command/effect/compressor.cpp
@@ -11,7 +11,7 @@
namespace AudioCore::AudioRenderer {
-static void SetCompressorEffectParameter(CompressorInfo::ParameterVersion2& params,
+static void SetCompressorEffectParameter(const CompressorInfo::ParameterVersion2& params,
CompressorInfo::State& state) {
const auto ratio{1.0f / params.compressor_ratio};
auto makeup_gain{0.0f};
@@ -31,9 +31,9 @@ static void SetCompressorEffectParameter(CompressorInfo::ParameterVersion2& para
state.unk_20 = c;
}
-static void InitializeCompressorEffect(CompressorInfo::ParameterVersion2& params,
+static void InitializeCompressorEffect(const CompressorInfo::ParameterVersion2& params,
CompressorInfo::State& state) {
- std::memset(&state, 0, sizeof(CompressorInfo::State));
+ state = {};
state.unk_00 = 0;
state.unk_04 = 1.0f;
@@ -42,7 +42,7 @@ static void InitializeCompressorEffect(CompressorInfo::ParameterVersion2& params
SetCompressorEffectParameter(params, state);
}
-static void ApplyCompressorEffect(CompressorInfo::ParameterVersion2& params,
+static void ApplyCompressorEffect(const CompressorInfo::ParameterVersion2& params,
CompressorInfo::State& state, bool enabled,
std::vector<std::span<const s32>> input_buffers,
std::vector<std::span<s32>> output_buffers, u32 sample_count) {
@@ -103,8 +103,7 @@ static void ApplyCompressorEffect(CompressorInfo::ParameterVersion2& params,
} else {
for (s16 channel = 0; channel < params.channel_count; channel++) {
if (params.inputs[channel] != params.outputs[channel]) {
- std::memcpy((char*)output_buffers[channel].data(),
- (char*)input_buffers[channel].data(),
+ std::memcpy(output_buffers[channel].data(), input_buffers[channel].data(),
output_buffers[channel].size_bytes());
}
}
diff --git a/src/audio_core/renderer/command/mix/mix_ramp.cpp b/src/audio_core/renderer/command/mix/mix_ramp.cpp
index ffdafa1c8..d67123cd8 100644
--- a/src/audio_core/renderer/command/mix/mix_ramp.cpp
+++ b/src/audio_core/renderer/command/mix/mix_ramp.cpp
@@ -7,17 +7,7 @@
#include "common/logging/log.h"
namespace AudioCore::AudioRenderer {
-/**
- * Mix input mix buffer into output mix buffer, with volume applied to the input.
- *
- * @tparam Q - Number of bits for fixed point operations.
- * @param output - Output mix buffer.
- * @param input - Input mix buffer.
- * @param volume - Volume applied to the input.
- * @param ramp - Ramp applied to volume every sample.
- * @param sample_count - Number of samples to process.
- * @return The final gained input sample, used for depopping.
- */
+
template <size_t Q>
s32 ApplyMixRamp(std::span<s32> output, std::span<const s32> input, const f32 volume_,
const f32 ramp_, const u32 sample_count) {
@@ -40,10 +30,8 @@ s32 ApplyMixRamp(std::span<s32> output, std::span<const s32> input, const f32 vo
return sample.to_int();
}
-template s32 ApplyMixRamp<15>(std::span<s32>, std::span<const s32>, const f32, const f32,
- const u32);
-template s32 ApplyMixRamp<23>(std::span<s32>, std::span<const s32>, const f32, const f32,
- const u32);
+template s32 ApplyMixRamp<15>(std::span<s32>, std::span<const s32>, f32, f32, u32);
+template s32 ApplyMixRamp<23>(std::span<s32>, std::span<const s32>, f32, f32, u32);
void MixRampCommand::Dump(const ADSP::CommandListProcessor& processor, std::string& string) {
const auto ramp{(volume - prev_volume) / static_cast<f32>(processor.sample_count)};
diff --git a/src/audio_core/renderer/command/mix/mix_ramp.h b/src/audio_core/renderer/command/mix/mix_ramp.h
index 770f57e80..52f74a273 100644
--- a/src/audio_core/renderer/command/mix/mix_ramp.h
+++ b/src/audio_core/renderer/command/mix/mix_ramp.h
@@ -61,13 +61,13 @@ struct MixRampCommand : ICommand {
* @tparam Q - Number of bits for fixed point operations.
* @param output - Output mix buffer.
* @param input - Input mix buffer.
- * @param volume - Volume applied to the input.
- * @param ramp - Ramp applied to volume every sample.
+ * @param volume_ - Volume applied to the input.
+ * @param ramp_ - Ramp applied to volume every sample.
* @param sample_count - Number of samples to process.
* @return The final gained input sample, used for depopping.
*/
template <size_t Q>
-s32 ApplyMixRamp(std::span<s32> output, std::span<const s32> input, const f32 volume_,
- const f32 ramp_, const u32 sample_count);
+s32 ApplyMixRamp(std::span<s32> output, std::span<const s32> input, f32 volume_, f32 ramp_,
+ u32 sample_count);
} // namespace AudioCore::AudioRenderer
diff --git a/src/audio_core/renderer/command/mix/mix_ramp_grouped.h b/src/audio_core/renderer/command/mix/mix_ramp_grouped.h
index 027276e5a..3b0ce67ef 100644
--- a/src/audio_core/renderer/command/mix/mix_ramp_grouped.h
+++ b/src/audio_core/renderer/command/mix/mix_ramp_grouped.h
@@ -50,9 +50,9 @@ struct MixRampGroupedCommand : ICommand {
std::array<s16, MaxMixBuffers> inputs;
/// Output mix buffer indexes for each mix buffer
std::array<s16, MaxMixBuffers> outputs;
- /// Previous mix vloumes for each mix buffer
+ /// Previous mix volumes for each mix buffer
std::array<f32, MaxMixBuffers> prev_volumes;
- /// Current mix vloumes for each mix buffer
+ /// Current mix volumes for each mix buffer
std::array<f32, MaxMixBuffers> volumes;
/// Pointer to the previous sample buffer, used for depop
CpuAddr previous_samples;
diff --git a/src/audio_core/renderer/command/sink/device.cpp b/src/audio_core/renderer/command/sink/device.cpp
index 47e0c6722..e88372a75 100644
--- a/src/audio_core/renderer/command/sink/device.cpp
+++ b/src/audio_core/renderer/command/sink/device.cpp
@@ -46,6 +46,10 @@ void DeviceSinkCommand::Process(const ADSP::CommandListProcessor& processor) {
out_buffer.tag = reinterpret_cast<u64>(samples.data());
stream->AppendBuffer(out_buffer, samples);
+
+ if (stream->IsPaused()) {
+ stream->Start();
+ }
}
bool DeviceSinkCommand::Verify(const ADSP::CommandListProcessor& processor) {
diff --git a/src/audio_core/renderer/effect/effect_context.h b/src/audio_core/renderer/effect/effect_context.h
index 85955bd9c..8f6d6e7d8 100644
--- a/src/audio_core/renderer/effect/effect_context.h
+++ b/src/audio_core/renderer/effect/effect_context.h
@@ -15,15 +15,15 @@ class EffectContext {
public:
/**
* Initialize the effect context
- * @param effect_infos List of effect infos for this context
- * @param effect_count The number of effects in the list
- * @param result_states_cpu The workbuffer of result states for the CPU for this context
- * @param result_states_dsp The workbuffer of result states for the DSP for this context
- * @param state_count The number of result states
+ * @param effect_infos_ - List of effect infos for this context
+ * @param effect_count_ - The number of effects in the list
+ * @param result_states_cpu_ - The workbuffer of result states for the CPU for this context
+ * @param result_states_dsp_ - The workbuffer of result states for the DSP for this context
+ * @param dsp_state_count - The number of result states
*/
- void Initialize(std::span<EffectInfoBase> effect_infos_, const u32 effect_count_,
+ void Initialize(std::span<EffectInfoBase> effect_infos_, u32 effect_count_,
std::span<EffectResultState> result_states_cpu_,
- std::span<EffectResultState> result_states_dsp_, const size_t dsp_state_count);
+ std::span<EffectResultState> result_states_dsp_, size_t dsp_state_count);
/**
* Get the EffectInfo for a given index
diff --git a/src/audio_core/renderer/effect/effect_info_base.h b/src/audio_core/renderer/effect/effect_info_base.h
index 8c9583878..8525fde05 100644
--- a/src/audio_core/renderer/effect/effect_info_base.h
+++ b/src/audio_core/renderer/effect/effect_info_base.h
@@ -291,7 +291,7 @@ public:
* Update the info with new parameters, version 1.
*
* @param error_info - Used to write call result code.
- * @param in_params - New parameters to update the info with.
+ * @param params - New parameters to update the info with.
* @param pool_mapper - Pool for mapping buffers.
*/
virtual void Update(BehaviorInfo::ErrorInfo& error_info,
@@ -305,7 +305,7 @@ public:
* Update the info with new parameters, version 2.
*
* @param error_info - Used to write call result code.
- * @param in_params - New parameters to update the info with.
+ * @param params - New parameters to update the info with.
* @param pool_mapper - Pool for mapping buffers.
*/
virtual void Update(BehaviorInfo::ErrorInfo& error_info,
diff --git a/src/audio_core/renderer/effect/i3dl2.h b/src/audio_core/renderer/effect/i3dl2.h
index 7a088a627..1ebbc5c4c 100644
--- a/src/audio_core/renderer/effect/i3dl2.h
+++ b/src/audio_core/renderer/effect/i3dl2.h
@@ -99,7 +99,7 @@ public:
return out_sample;
}
- Common::FixedPoint<50, 14> Read() {
+ Common::FixedPoint<50, 14> Read() const {
return *output;
}
@@ -110,7 +110,7 @@ public:
}
}
- Common::FixedPoint<50, 14> TapOut(const s32 index) {
+ Common::FixedPoint<50, 14> TapOut(const s32 index) const {
auto out{input - (index + 1)};
if (out < buffer.data()) {
out += max_delay + 1;
diff --git a/src/audio_core/renderer/effect/reverb.h b/src/audio_core/renderer/effect/reverb.h
index b4df9f6ef..a72475c3c 100644
--- a/src/audio_core/renderer/effect/reverb.h
+++ b/src/audio_core/renderer/effect/reverb.h
@@ -95,7 +95,7 @@ public:
return out_sample;
}
- Common::FixedPoint<50, 14> Read() {
+ Common::FixedPoint<50, 14> Read() const {
return *output;
}
@@ -106,7 +106,7 @@ public:
}
}
- Common::FixedPoint<50, 14> TapOut(const s32 index) {
+ Common::FixedPoint<50, 14> TapOut(const s32 index) const {
auto out{input - (index + 1)};
if (out < buffer.data()) {
out += sample_count;
diff --git a/src/audio_core/renderer/memory/address_info.h b/src/audio_core/renderer/memory/address_info.h
index 4cfefea8e..bb5c930e1 100644
--- a/src/audio_core/renderer/memory/address_info.h
+++ b/src/audio_core/renderer/memory/address_info.h
@@ -19,8 +19,8 @@ public:
/**
* Setup a new AddressInfo.
*
- * @param cpu_address - The CPU address of this region.
- * @param size - The size of this region.
+ * @param cpu_address_ - The CPU address of this region.
+ * @param size_ - The size of this region.
*/
void Setup(CpuAddr cpu_address_, u64 size_) {
cpu_address = cpu_address_;
@@ -42,7 +42,6 @@ public:
* Assign this region to a memory pool.
*
* @param memory_pool_ - Memory pool to assign.
- * @return The CpuAddr address of this region.
*/
void SetPool(MemoryPoolInfo* memory_pool_) {
memory_pool = memory_pool_;
diff --git a/src/audio_core/renderer/nodes/node_states.h b/src/audio_core/renderer/nodes/node_states.h
index a1e0958a2..94b1d1254 100644
--- a/src/audio_core/renderer/nodes/node_states.h
+++ b/src/audio_core/renderer/nodes/node_states.h
@@ -56,7 +56,7 @@ class NodeStates {
*
* @return The current stack position.
*/
- u32 Count() {
+ u32 Count() const {
return pos;
}
@@ -83,7 +83,7 @@ class NodeStates {
*
* @return The node on the top of the stack.
*/
- u32 top() {
+ u32 top() const {
return stack[pos - 1];
}
@@ -112,11 +112,11 @@ public:
/**
* Initialize the node states.
*
- * @param buffer - The workbuffer to use. Unused.
+ * @param buffer_ - The workbuffer to use. Unused.
* @param node_buffer_size - The size of the workbuffer. Unused.
* @param count - The number of nodes in the graph.
*/
- void Initialize(std::span<u8> nodes, u64 node_buffer_size, u32 count);
+ void Initialize(std::span<u8> buffer_, u64 node_buffer_size, u32 count);
/**
* Sort the graph. Only calls DepthFirstSearch.
diff --git a/src/audio_core/renderer/performance/performance_manager.h b/src/audio_core/renderer/performance/performance_manager.h
index b82176bef..b65caa9b6 100644
--- a/src/audio_core/renderer/performance/performance_manager.h
+++ b/src/audio_core/renderer/performance/performance_manager.h
@@ -73,7 +73,8 @@ public:
* Calculate the required size for the performance workbuffer.
*
* @param behavior - Check which version is supported.
- * @param params - Input parameters.
+ * @param params - Input parameters.
+ *
* @return Required workbuffer size.
*/
static u64 GetRequiredBufferSizeForPerformanceMetricsPerFrame(
@@ -104,7 +105,7 @@ public:
* @param workbuffer - Workbuffer to use for performance frames.
* @param workbuffer_size - Size of the workbuffer.
* @param params - Input parameters.
- * @param behavior - Behaviour to check version and data format.
+ * @param behavior - Behaviour to check version and data format.
* @param memory_pool - Used to translate the workbuffer address for the DSP.
*/
virtual void Initialize(std::span<u8> workbuffer, u64 workbuffer_size,
@@ -160,7 +161,8 @@ public:
* workbuffer, to be written by the AudioRenderer.
*
* @param addresses - Filled with pointers to the new detail, which should be passed
- * to the AudioRenderer with Performance commands to be written.
+ * to the AudioRenderer with Performance commands to be written.
+ * @param detail_type - Performance detail type.
* @param entry_type - The type of this detail. See PerformanceEntryType
* @param node_id - Node id for this detail.
* @return True if a new detail was created and the offsets are valid, otherwise false.
diff --git a/src/audio_core/renderer/system_manager.cpp b/src/audio_core/renderer/system_manager.cpp
index b326819ed..9c1331e19 100644
--- a/src/audio_core/renderer/system_manager.cpp
+++ b/src/audio_core/renderer/system_manager.cpp
@@ -15,17 +15,14 @@ MICROPROFILE_DEFINE(Audio_RenderSystemManager, "Audio", "Render System Manager",
MP_RGB(60, 19, 97));
namespace AudioCore::AudioRenderer {
-constexpr std::chrono::nanoseconds BaseRenderTime{5'000'000UL};
-constexpr std::chrono::nanoseconds RenderTimeOffset{400'000UL};
+constexpr std::chrono::nanoseconds RENDER_TIME{5'000'000UL};
SystemManager::SystemManager(Core::System& core_)
: core{core_}, adsp{core.AudioCore().GetADSP()}, mailbox{adsp.GetRenderMailbox()},
thread_event{Core::Timing::CreateEvent(
"AudioRendererSystemManager", [this](std::uintptr_t, s64 time, std::chrono::nanoseconds) {
return ThreadFunc2(time);
- })} {
- core.CoreTiming().RegisterPauseCallback([this](bool paused) { PauseCallback(paused); });
-}
+ })} {}
SystemManager::~SystemManager() {
Stop();
@@ -36,8 +33,8 @@ bool SystemManager::InitializeUnsafe() {
if (adsp.Start()) {
active = true;
thread = std::jthread([this](std::stop_token stop_token) { ThreadFunc(); });
- core.CoreTiming().ScheduleLoopingEvent(std::chrono::nanoseconds(0),
- BaseRenderTime - RenderTimeOffset, thread_event);
+ core.CoreTiming().ScheduleLoopingEvent(std::chrono::nanoseconds(0), RENDER_TIME,
+ thread_event);
}
}
@@ -121,42 +118,9 @@ void SystemManager::ThreadFunc() {
}
std::optional<std::chrono::nanoseconds> SystemManager::ThreadFunc2(s64 time) {
- std::optional<std::chrono::nanoseconds> new_schedule_time{std::nullopt};
- const auto queue_size{core.AudioCore().GetStreamQueue()};
- switch (state) {
- case StreamState::Filling:
- if (queue_size >= 5) {
- new_schedule_time = BaseRenderTime;
- state = StreamState::Steady;
- }
- break;
- case StreamState::Steady:
- if (queue_size <= 2) {
- new_schedule_time = BaseRenderTime - RenderTimeOffset;
- state = StreamState::Filling;
- } else if (queue_size > 5) {
- new_schedule_time = BaseRenderTime + RenderTimeOffset;
- state = StreamState::Draining;
- }
- break;
- case StreamState::Draining:
- if (queue_size <= 5) {
- new_schedule_time = BaseRenderTime;
- state = StreamState::Steady;
- }
- break;
- }
-
update.store(true);
update.notify_all();
- return new_schedule_time;
-}
-
-void SystemManager::PauseCallback(bool paused) {
- if (paused && core.IsPoweredOn() && core.IsShuttingDown()) {
- update.store(true);
- update.notify_all();
- }
+ return std::nullopt;
}
} // namespace AudioCore::AudioRenderer
diff --git a/src/audio_core/renderer/system_manager.h b/src/audio_core/renderer/system_manager.h
index 1291e9e0e..81457a3a1 100644
--- a/src/audio_core/renderer/system_manager.h
+++ b/src/audio_core/renderer/system_manager.h
@@ -73,13 +73,6 @@ private:
*/
std::optional<std::chrono::nanoseconds> ThreadFunc2(s64 time);
- /**
- * Callback from core timing when pausing, used to detect shutdowns and stop ThreadFunc.
- *
- * @param paused - Are we pausing or resuming?
- */
- void PauseCallback(bool paused);
-
enum class StreamState {
Filling,
Steady,
@@ -106,8 +99,6 @@ private:
std::shared_ptr<Core::Timing::EventType> thread_event;
/// Atomic for main thread to wait on
std::atomic<bool> update{};
- /// Current state of the streams
- StreamState state{StreamState::Filling};
};
} // namespace AudioCore::AudioRenderer
diff --git a/src/audio_core/renderer/upsampler/upsampler_manager.h b/src/audio_core/renderer/upsampler/upsampler_manager.h
index 70cd42b08..83c697c0c 100644
--- a/src/audio_core/renderer/upsampler/upsampler_manager.h
+++ b/src/audio_core/renderer/upsampler/upsampler_manager.h
@@ -27,7 +27,7 @@ public:
/**
* Free the given upsampler.
*
- * @param The upsampler to be freed.
+ * @param info The upsampler to be freed.
*/
void Free(UpsamplerInfo* info);
diff --git a/src/audio_core/renderer/voice/voice_info.h b/src/audio_core/renderer/voice/voice_info.h
index 896723e0c..930180895 100644
--- a/src/audio_core/renderer/voice/voice_info.h
+++ b/src/audio_core/renderer/voice/voice_info.h
@@ -185,7 +185,8 @@ public:
/**
* Does this voice ned an update?
*
- * @param params - Input parametetrs to check matching.
+ * @param params - Input parameters to check matching.
+ *
* @return True if this voice needs an update, otherwise false.
*/
bool ShouldUpdateParameters(const InParameter& params) const;
@@ -194,9 +195,9 @@ public:
* Update the parameters of this voice.
*
* @param error_info - Output error code.
- * @param params - Input parametters to udpate from.
+ * @param params - Input parameters to update from.
* @param pool_mapper - Used to map buffers.
- * @param behavior - behavior to check supported features.
+ * @param behavior - behavior to check supported features.
*/
void UpdateParameters(BehaviorInfo::ErrorInfo& error_info, const InParameter& params,
const PoolMapper& pool_mapper, const BehaviorInfo& behavior);
@@ -218,12 +219,12 @@ public:
/**
* Update all wavebuffers.
*
- * @param error_infos - Output 2D array of errors, 2 per wavebuffer.
- * @param error_count - Number of errors provided. Unused.
- * @param params - Input parametters to be used for the update.
+ * @param error_infos - Output 2D array of errors, 2 per wavebuffer.
+ * @param error_count - Number of errors provided. Unused.
+ * @param params - Input parameters to be used for the update.
* @param voice_states - The voice states for each channel in this voice to be updated.
- * @param pool_mapper - Used to map the wavebuffers.
- * @param behavior - Used to check for supported features.
+ * @param pool_mapper - Used to map the wavebuffers.
+ * @param behavior - Used to check for supported features.
*/
void UpdateWaveBuffers(std::span<std::array<BehaviorInfo::ErrorInfo, 2>> error_infos,
u32 error_count, const InParameter& params,
@@ -233,13 +234,13 @@ public:
/**
* Update a wavebuffer.
*
- * @param error_infos - Output array of errors.
+ * @param error_info - Output array of errors.
* @param wave_buffer - The wavebuffer to be updated.
* @param wave_buffer_internal - Input parametters to be used for the update.
* @param sample_format - Sample format of the wavebuffer.
* @param valid - Is this wavebuffer valid?
* @param pool_mapper - Used to map the wavebuffers.
- * @param behavior - Used to check for supported features.
+ * @param behavior - Used to check for supported features.
*/
void UpdateWaveBuffer(std::span<BehaviorInfo::ErrorInfo> error_info, WaveBuffer& wave_buffer,
const WaveBufferInternal& wave_buffer_internal,
@@ -276,7 +277,7 @@ public:
/**
* Check if this voice has any mixing connections.
*
- * @return True if this voice participes in mixing, otherwise false.
+ * @return True if this voice participates in mixing, otherwise false.
*/
bool HasAnyConnection() const;
@@ -301,7 +302,8 @@ public:
/**
* Update this voice on command generation.
*
- * @param voice_states - Voice states for these wavebuffers.
+ * @param voice_context - Voice context for these wavebuffers.
+ *
* @return True if this voice should be generated, otherwise false.
*/
bool UpdateForCommandGeneration(VoiceContext& voice_context);