summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio_core/renderer/command/command_generator.cpp2
-rw-r--r--src/audio_core/renderer/command/effect/aux_.cpp78
2 files changed, 40 insertions, 40 deletions
diff --git a/src/audio_core/renderer/command/command_generator.cpp b/src/audio_core/renderer/command/command_generator.cpp
index 2ea50d128..fba84c7bd 100644
--- a/src/audio_core/renderer/command/command_generator.cpp
+++ b/src/audio_core/renderer/command/command_generator.cpp
@@ -46,7 +46,7 @@ void CommandGenerator::GenerateDataSourceCommand(VoiceInfo& voice_info,
46 while (destination != nullptr) { 46 while (destination != nullptr) {
47 if (destination->IsConfigured()) { 47 if (destination->IsConfigured()) {
48 auto mix_id{destination->GetMixId()}; 48 auto mix_id{destination->GetMixId()};
49 if (mix_id < mix_context.GetCount()) { 49 if (mix_id < mix_context.GetCount() && mix_id != UnusedSplitterId) {
50 auto mix_info{mix_context.GetInfo(mix_id)}; 50 auto mix_info{mix_context.GetInfo(mix_id)};
51 command_buffer.GenerateDepopPrepareCommand( 51 command_buffer.GenerateDepopPrepareCommand(
52 voice_info.node_id, voice_state, render_context.depop_buffer, 52 voice_info.node_id, voice_state, render_context.depop_buffer,
diff --git a/src/audio_core/renderer/command/effect/aux_.cpp b/src/audio_core/renderer/command/effect/aux_.cpp
index e76db893f..0c69dcc28 100644
--- a/src/audio_core/renderer/command/effect/aux_.cpp
+++ b/src/audio_core/renderer/command/effect/aux_.cpp
@@ -4,6 +4,7 @@
4#include "audio_core/renderer/adsp/command_list_processor.h" 4#include "audio_core/renderer/adsp/command_list_processor.h"
5#include "audio_core/renderer/command/effect/aux_.h" 5#include "audio_core/renderer/command/effect/aux_.h"
6#include "audio_core/renderer/effect/aux_.h" 6#include "audio_core/renderer/effect/aux_.h"
7#include "core/core.h"
7#include "core/memory.h" 8#include "core/memory.h"
8 9
9namespace AudioCore::AudioRenderer { 10namespace AudioCore::AudioRenderer {
@@ -40,11 +41,10 @@ static void ResetAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr aux_in
40 * @param update_count - If non-zero, send_info_ will be updated. 41 * @param update_count - If non-zero, send_info_ will be updated.
41 * @return Number of samples written. 42 * @return Number of samples written.
42 */ 43 */
43static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_info_, 44static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr send_info_,
44 [[maybe_unused]] u32 sample_count, const CpuAddr send_buffer, 45 [[maybe_unused]] u32 sample_count, CpuAddr send_buffer, u32 count_max,
45 const u32 count_max, std::span<const s32> input, 46 std::span<const s32> input, u32 write_count_, u32 write_offset,
46 const u32 write_count_, const u32 write_offset, 47 u32 update_count) {
47 const u32 update_count) {
48 if (write_count_ > count_max) { 48 if (write_count_ > count_max) {
49 LOG_ERROR(Service_Audio, 49 LOG_ERROR(Service_Audio,
50 "write_count must be smaller than count_max! write_count {}, count_max {}", 50 "write_count must be smaller than count_max! write_count {}, count_max {}",
@@ -52,6 +52,11 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
52 return 0; 52 return 0;
53 } 53 }
54 54
55 if (send_info_ == 0) {
56 LOG_ERROR(Service_Audio, "send_info_ is 0!");
57 return 0;
58 }
59
55 if (input.empty()) { 60 if (input.empty()) {
56 LOG_ERROR(Service_Audio, "input buffer is empty!"); 61 LOG_ERROR(Service_Audio, "input buffer is empty!");
57 return 0; 62 return 0;
@@ -66,35 +71,30 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
66 return 0; 71 return 0;
67 } 72 }
68 73
69 AuxInfo::AuxInfoDsp send_info{}; 74 auto send_info{reinterpret_cast<AuxInfo::AuxInfoDsp*>(memory.GetPointer(send_info_))};
70 memory.ReadBlockUnsafe(send_info_, &send_info, sizeof(AuxInfo::AuxInfoDsp));
71 75
72 u32 target_write_offset{send_info.write_offset + write_offset}; 76 u32 target_write_offset{send_info->write_offset + write_offset};
73 if (target_write_offset > count_max || write_count_ == 0) { 77 if (target_write_offset > count_max) {
74 return 0; 78 return 0;
75 } 79 }
76 80
77 u32 write_count{write_count_}; 81 u32 write_count{write_count_};
78 u32 write_pos{0}; 82 u32 read_pos{0};
79 while (write_count > 0) { 83 while (write_count > 0) {
80 u32 to_write{std::min(count_max - target_write_offset, write_count)}; 84 u32 to_write{std::min(count_max - target_write_offset, write_count)};
81 85 if (to_write) {
82 if (to_write > 0) {
83 memory.WriteBlockUnsafe(send_buffer + target_write_offset * sizeof(s32), 86 memory.WriteBlockUnsafe(send_buffer + target_write_offset * sizeof(s32),
84 &input[write_pos], to_write * sizeof(s32)); 87 &input[read_pos], to_write * sizeof(s32));
85 } 88 }
86
87 target_write_offset = (target_write_offset + to_write) % count_max; 89 target_write_offset = (target_write_offset + to_write) % count_max;
88 write_count -= to_write; 90 write_count -= to_write;
89 write_pos += to_write; 91 read_pos += to_write;
90 } 92 }
91 93
92 if (update_count) { 94 if (update_count) {
93 send_info.write_offset = (send_info.write_offset + update_count) % count_max; 95 send_info->write_offset = (send_info->write_offset + update_count) % count_max;
94 } 96 }
95 97
96 memory.WriteBlockUnsafe(send_info_, &send_info, sizeof(AuxInfo::AuxInfoDsp));
97
98 return write_count_; 98 return write_count_;
99} 99}
100 100
@@ -102,7 +102,7 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
102 * Read the given memory at return_buffer into the output mix buffer, and update return_info_ if 102 * Read the given memory at return_buffer into the output mix buffer, and update return_info_ if
103 * update_count is set, to notify the game that an update happened. 103 * update_count is set, to notify the game that an update happened.
104 * 104 *
105 * @param memory - Core memory for writing. 105 * @param memory - Core memory for reading.
106 * @param return_info_ - Meta information for where to read the mix buffer. 106 * @param return_info_ - Meta information for where to read the mix buffer.
107 * @param return_buffer - Memory address to read the samples from. 107 * @param return_buffer - Memory address to read the samples from.
108 * @param count_max - Maximum number of samples in the receiving buffer. 108 * @param count_max - Maximum number of samples in the receiving buffer.
@@ -112,16 +112,21 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
112 * @param update_count - If non-zero, send_info_ will be updated. 112 * @param update_count - If non-zero, send_info_ will be updated.
113 * @return Number of samples read. 113 * @return Number of samples read.
114 */ 114 */
115static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr return_info_, 115static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr return_info_,
116 const CpuAddr return_buffer, const u32 count_max, std::span<s32> output, 116 CpuAddr return_buffer, u32 count_max, std::span<s32> output,
117 const u32 count_, const u32 read_offset, const u32 update_count) { 117 u32 read_count_, u32 read_offset, u32 update_count) {
118 if (count_max == 0) { 118 if (count_max == 0) {
119 return 0; 119 return 0;
120 } 120 }
121 121
122 if (count_ > count_max) { 122 if (read_count_ > count_max) {
123 LOG_ERROR(Service_Audio, "count must be smaller than count_max! count {}, count_max {}", 123 LOG_ERROR(Service_Audio, "count must be smaller than count_max! count {}, count_max {}",
124 count_, count_max); 124 read_count_, count_max);
125 return 0;
126 }
127
128 if (return_info_ == 0) {
129 LOG_ERROR(Service_Audio, "return_info_ is 0!");
125 return 0; 130 return 0;
126 } 131 }
127 132
@@ -135,36 +140,31 @@ static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr return_i
135 return 0; 140 return 0;
136 } 141 }
137 142
138 AuxInfo::AuxInfoDsp return_info{}; 143 auto return_info{reinterpret_cast<AuxInfo::AuxInfoDsp*>(memory.GetPointer(return_info_))};
139 memory.ReadBlockUnsafe(return_info_, &return_info, sizeof(AuxInfo::AuxInfoDsp));
140 144
141 u32 target_read_offset{return_info.read_offset + read_offset}; 145 u32 target_read_offset{return_info->read_offset + read_offset};
142 if (target_read_offset > count_max) { 146 if (target_read_offset > count_max) {
143 return 0; 147 return 0;
144 } 148 }
145 149
146 u32 read_count{count_}; 150 u32 read_count{read_count_};
147 u32 read_pos{0}; 151 u32 write_pos{0};
148 while (read_count > 0) { 152 while (read_count > 0) {
149 u32 to_read{std::min(count_max - target_read_offset, read_count)}; 153 u32 to_read{std::min(count_max - target_read_offset, read_count)};
150 154 if (to_read) {
151 if (to_read > 0) {
152 memory.ReadBlockUnsafe(return_buffer + target_read_offset * sizeof(s32), 155 memory.ReadBlockUnsafe(return_buffer + target_read_offset * sizeof(s32),
153 &output[read_pos], to_read * sizeof(s32)); 156 &output[write_pos], to_read * sizeof(s32));
154 } 157 }
155
156 target_read_offset = (target_read_offset + to_read) % count_max; 158 target_read_offset = (target_read_offset + to_read) % count_max;
157 read_count -= to_read; 159 read_count -= to_read;
158 read_pos += to_read; 160 write_pos += to_read;
159 } 161 }
160 162
161 if (update_count) { 163 if (update_count) {
162 return_info.read_offset = (return_info.read_offset + update_count) % count_max; 164 return_info->read_offset = (return_info->read_offset + update_count) % count_max;
163 } 165 }
164 166
165 memory.WriteBlockUnsafe(return_info_, &return_info, sizeof(AuxInfo::AuxInfoDsp)); 167 return read_count_;
166
167 return count_;
168} 168}
169 169
170void AuxCommand::Dump([[maybe_unused]] const ADSP::CommandListProcessor& processor, 170void AuxCommand::Dump([[maybe_unused]] const ADSP::CommandListProcessor& processor,
@@ -189,7 +189,7 @@ void AuxCommand::Process(const ADSP::CommandListProcessor& processor) {
189 update_count)}; 189 update_count)};
190 190
191 if (read != processor.sample_count) { 191 if (read != processor.sample_count) {
192 std::memset(&output_buffer[read], 0, processor.sample_count - read); 192 std::memset(&output_buffer[read], 0, (processor.sample_count - read) * sizeof(s32));
193 } 193 }
194 } else { 194 } else {
195 ResetAuxBufferDsp(*processor.memory, send_buffer_info); 195 ResetAuxBufferDsp(*processor.memory, send_buffer_info);