diff options
Diffstat (limited to 'src/audio_core/renderer/system.cpp')
| -rw-r--r-- | src/audio_core/renderer/system.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/audio_core/renderer/system.cpp b/src/audio_core/renderer/system.cpp index 31cbee282..28f063641 100644 --- a/src/audio_core/renderer/system.cpp +++ b/src/audio_core/renderer/system.cpp | |||
| @@ -101,15 +101,15 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 101 | Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size, | 101 | Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size, |
| 102 | u32 process_handle_, u64 applet_resource_user_id_, s32 session_id_) { | 102 | u32 process_handle_, u64 applet_resource_user_id_, s32 session_id_) { |
| 103 | if (!CheckValidRevision(params.revision)) { | 103 | if (!CheckValidRevision(params.revision)) { |
| 104 | return Service::Audio::ERR_INVALID_REVISION; | 104 | return Service::Audio::ResultInvalidRevision; |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | if (GetWorkBufferSize(params) > transfer_memory_size) { | 107 | if (GetWorkBufferSize(params) > transfer_memory_size) { |
| 108 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 108 | return Service::Audio::ResultInsufficientBuffer; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | if (process_handle_ == 0) { | 111 | if (process_handle_ == 0) { |
| 112 | return Service::Audio::ERR_INVALID_PROCESS_HANDLE; | 112 | return Service::Audio::ResultInvalidHandle; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | behavior.SetUserLibRevision(params.revision); | 115 | behavior.SetUserLibRevision(params.revision); |
| @@ -143,19 +143,19 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 143 | samples_workbuffer = | 143 | samples_workbuffer = |
| 144 | allocator.Allocate<s32>((voice_channels + mix_buffer_count) * sample_count, 0x10); | 144 | allocator.Allocate<s32>((voice_channels + mix_buffer_count) * sample_count, 0x10); |
| 145 | if (samples_workbuffer.empty()) { | 145 | if (samples_workbuffer.empty()) { |
| 146 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 146 | return Service::Audio::ResultInsufficientBuffer; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | auto upsampler_workbuffer{allocator.Allocate<s32>( | 149 | auto upsampler_workbuffer{allocator.Allocate<s32>( |
| 150 | (voice_channels + mix_buffer_count) * TargetSampleCount * upsampler_count, 0x10)}; | 150 | (voice_channels + mix_buffer_count) * TargetSampleCount * upsampler_count, 0x10)}; |
| 151 | if (upsampler_workbuffer.empty()) { | 151 | if (upsampler_workbuffer.empty()) { |
| 152 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 152 | return Service::Audio::ResultInsufficientBuffer; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | depop_buffer = | 155 | depop_buffer = |
| 156 | allocator.Allocate<s32>(Common::AlignUp(static_cast<u32>(mix_buffer_count), 0x40), 0x40); | 156 | allocator.Allocate<s32>(Common::AlignUp(static_cast<u32>(mix_buffer_count), 0x40), 0x40); |
| 157 | if (depop_buffer.empty()) { | 157 | if (depop_buffer.empty()) { |
| 158 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 158 | return Service::Audio::ResultInsufficientBuffer; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | // invalidate samples_workbuffer DSP cache | 161 | // invalidate samples_workbuffer DSP cache |
| @@ -166,12 +166,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | if (voice_infos.empty()) { | 168 | if (voice_infos.empty()) { |
| 169 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 169 | return Service::Audio::ResultInsufficientBuffer; |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | auto sorted_voice_infos{allocator.Allocate<VoiceInfo*>(params.voices, 0x10)}; | 172 | auto sorted_voice_infos{allocator.Allocate<VoiceInfo*>(params.voices, 0x10)}; |
| 173 | if (sorted_voice_infos.empty()) { | 173 | if (sorted_voice_infos.empty()) { |
| 174 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 174 | return Service::Audio::ResultInsufficientBuffer; |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | std::memset(sorted_voice_infos.data(), 0, sorted_voice_infos.size_bytes()); | 177 | std::memset(sorted_voice_infos.data(), 0, sorted_voice_infos.size_bytes()); |
| @@ -183,12 +183,12 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | if (voice_channel_resources.empty()) { | 185 | if (voice_channel_resources.empty()) { |
| 186 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 186 | return Service::Audio::ResultInsufficientBuffer; |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | auto voice_cpu_states{allocator.Allocate<VoiceState>(params.voices, 0x10)}; | 189 | auto voice_cpu_states{allocator.Allocate<VoiceState>(params.voices, 0x10)}; |
| 190 | if (voice_cpu_states.empty()) { | 190 | if (voice_cpu_states.empty()) { |
| 191 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 191 | return Service::Audio::ResultInsufficientBuffer; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | for (auto& voice_state : voice_cpu_states) { | 194 | for (auto& voice_state : voice_cpu_states) { |
| @@ -198,7 +198,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 198 | auto mix_infos{allocator.Allocate<MixInfo>(params.sub_mixes + 1, 0x10)}; | 198 | auto mix_infos{allocator.Allocate<MixInfo>(params.sub_mixes + 1, 0x10)}; |
| 199 | 199 | ||
| 200 | if (mix_infos.empty()) { | 200 | if (mix_infos.empty()) { |
| 201 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 201 | return Service::Audio::ResultInsufficientBuffer; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | u32 effect_process_order_count{0}; | 204 | u32 effect_process_order_count{0}; |
| @@ -208,7 +208,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 208 | effect_process_order_count = params.effects * (params.sub_mixes + 1); | 208 | effect_process_order_count = params.effects * (params.sub_mixes + 1); |
| 209 | effect_process_order_buffer = allocator.Allocate<s32>(effect_process_order_count, 0x10); | 209 | effect_process_order_buffer = allocator.Allocate<s32>(effect_process_order_count, 0x10); |
| 210 | if (effect_process_order_buffer.empty()) { | 210 | if (effect_process_order_buffer.empty()) { |
| 211 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 211 | return Service::Audio::ResultInsufficientBuffer; |
| 212 | } | 212 | } |
| 213 | } | 213 | } |
| 214 | 214 | ||
| @@ -222,7 +222,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 222 | 222 | ||
| 223 | auto sorted_mix_infos{allocator.Allocate<MixInfo*>(params.sub_mixes + 1, 0x10)}; | 223 | auto sorted_mix_infos{allocator.Allocate<MixInfo*>(params.sub_mixes + 1, 0x10)}; |
| 224 | if (sorted_mix_infos.empty()) { | 224 | if (sorted_mix_infos.empty()) { |
| 225 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 225 | return Service::Audio::ResultInsufficientBuffer; |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | std::memset(sorted_mix_infos.data(), 0, sorted_mix_infos.size_bytes()); | 228 | std::memset(sorted_mix_infos.data(), 0, sorted_mix_infos.size_bytes()); |
| @@ -235,7 +235,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 235 | auto edge_matrix_workbuffer{allocator.Allocate<u8>(edge_matrix_size, 1)}; | 235 | auto edge_matrix_workbuffer{allocator.Allocate<u8>(edge_matrix_size, 1)}; |
| 236 | 236 | ||
| 237 | if (node_states_workbuffer.empty() || edge_matrix_workbuffer.size() == 0) { | 237 | if (node_states_workbuffer.empty() || edge_matrix_workbuffer.size() == 0) { |
| 238 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 238 | return Service::Audio::ResultInsufficientBuffer; |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | mix_context.Initialize(sorted_mix_infos, mix_infos, params.sub_mixes + 1, | 241 | mix_context.Initialize(sorted_mix_infos, mix_infos, params.sub_mixes + 1, |
| @@ -250,7 +250,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 250 | 250 | ||
| 251 | upsampler_manager = allocator.Allocate<UpsamplerManager>(1, 0x10).data(); | 251 | upsampler_manager = allocator.Allocate<UpsamplerManager>(1, 0x10).data(); |
| 252 | if (upsampler_manager == nullptr) { | 252 | if (upsampler_manager == nullptr) { |
| 253 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 253 | return Service::Audio::ResultInsufficientBuffer; |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | memory_pool_workbuffer = allocator.Allocate<MemoryPoolInfo>(memory_pool_count, 0x10); | 256 | memory_pool_workbuffer = allocator.Allocate<MemoryPoolInfo>(memory_pool_count, 0x10); |
| @@ -259,18 +259,18 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | if (memory_pool_workbuffer.empty() && memory_pool_count > 0) { | 261 | if (memory_pool_workbuffer.empty() && memory_pool_count > 0) { |
| 262 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 262 | return Service::Audio::ResultInsufficientBuffer; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | if (!splitter_context.Initialize(behavior, params, allocator)) { | 265 | if (!splitter_context.Initialize(behavior, params, allocator)) { |
| 266 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 266 | return Service::Audio::ResultInsufficientBuffer; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | std::span<EffectResultState> effect_result_states_cpu{}; | 269 | std::span<EffectResultState> effect_result_states_cpu{}; |
| 270 | if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) { | 270 | if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) { |
| 271 | effect_result_states_cpu = allocator.Allocate<EffectResultState>(params.effects, 0x10); | 271 | effect_result_states_cpu = allocator.Allocate<EffectResultState>(params.effects, 0x10); |
| 272 | if (effect_result_states_cpu.empty()) { | 272 | if (effect_result_states_cpu.empty()) { |
| 273 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 273 | return Service::Audio::ResultInsufficientBuffer; |
| 274 | } | 274 | } |
| 275 | std::memset(effect_result_states_cpu.data(), 0, effect_result_states_cpu.size_bytes()); | 275 | std::memset(effect_result_states_cpu.data(), 0, effect_result_states_cpu.size_bytes()); |
| 276 | } | 276 | } |
| @@ -289,7 +289,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 289 | upsampler_workbuffer); | 289 | upsampler_workbuffer); |
| 290 | 290 | ||
| 291 | if (upsampler_infos.empty()) { | 291 | if (upsampler_infos.empty()) { |
| 292 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 292 | return Service::Audio::ResultInsufficientBuffer; |
| 293 | } | 293 | } |
| 294 | 294 | ||
| 295 | auto effect_infos{allocator.Allocate<EffectInfoBase>(params.effects, 0x40)}; | 295 | auto effect_infos{allocator.Allocate<EffectInfoBase>(params.effects, 0x40)}; |
| @@ -298,14 +298,14 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | if (effect_infos.empty() && params.effects > 0) { | 300 | if (effect_infos.empty() && params.effects > 0) { |
| 301 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 301 | return Service::Audio::ResultInsufficientBuffer; |
| 302 | } | 302 | } |
| 303 | 303 | ||
| 304 | std::span<EffectResultState> effect_result_states_dsp{}; | 304 | std::span<EffectResultState> effect_result_states_dsp{}; |
| 305 | if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) { | 305 | if (behavior.IsEffectInfoVersion2Supported() && params.effects > 0) { |
| 306 | effect_result_states_dsp = allocator.Allocate<EffectResultState>(params.effects, 0x40); | 306 | effect_result_states_dsp = allocator.Allocate<EffectResultState>(params.effects, 0x40); |
| 307 | if (effect_result_states_dsp.empty()) { | 307 | if (effect_result_states_dsp.empty()) { |
| 308 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 308 | return Service::Audio::ResultInsufficientBuffer; |
| 309 | } | 309 | } |
| 310 | std::memset(effect_result_states_dsp.data(), 0, effect_result_states_dsp.size_bytes()); | 310 | std::memset(effect_result_states_dsp.data(), 0, effect_result_states_dsp.size_bytes()); |
| 311 | } | 311 | } |
| @@ -319,14 +319,14 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | if (sinks.empty()) { | 321 | if (sinks.empty()) { |
| 322 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 322 | return Service::Audio::ResultInsufficientBuffer; |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | sink_context.Initialize(sinks, params.sinks); | 325 | sink_context.Initialize(sinks, params.sinks); |
| 326 | 326 | ||
| 327 | auto voice_dsp_states{allocator.Allocate<VoiceState>(params.voices, 0x40)}; | 327 | auto voice_dsp_states{allocator.Allocate<VoiceState>(params.voices, 0x40)}; |
| 328 | if (voice_dsp_states.empty()) { | 328 | if (voice_dsp_states.empty()) { |
| 329 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 329 | return Service::Audio::ResultInsufficientBuffer; |
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | for (auto& voice_state : voice_dsp_states) { | 332 | for (auto& voice_state : voice_dsp_states) { |
| @@ -344,7 +344,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 344 | 0xC}; | 344 | 0xC}; |
| 345 | performance_workbuffer = allocator.Allocate<u8>(perf_workbuffer_size, 0x40); | 345 | performance_workbuffer = allocator.Allocate<u8>(perf_workbuffer_size, 0x40); |
| 346 | if (performance_workbuffer.empty()) { | 346 | if (performance_workbuffer.empty()) { |
| 347 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 347 | return Service::Audio::ResultInsufficientBuffer; |
| 348 | } | 348 | } |
| 349 | std::memset(performance_workbuffer.data(), 0, performance_workbuffer.size_bytes()); | 349 | std::memset(performance_workbuffer.data(), 0, performance_workbuffer.size_bytes()); |
| 350 | performance_manager.Initialize(performance_workbuffer, performance_workbuffer.size_bytes(), | 350 | performance_manager.Initialize(performance_workbuffer, performance_workbuffer.size_bytes(), |
| @@ -360,7 +360,7 @@ Result System::Initialize(const AudioRendererParameterInternal& params, | |||
| 360 | command_workbuffer_size = allocator.GetRemainingSize(); | 360 | command_workbuffer_size = allocator.GetRemainingSize(); |
| 361 | command_workbuffer = allocator.Allocate<u8>(command_workbuffer_size, 0x40); | 361 | command_workbuffer = allocator.Allocate<u8>(command_workbuffer_size, 0x40); |
| 362 | if (command_workbuffer.empty()) { | 362 | if (command_workbuffer.empty()) { |
| 363 | return Service::Audio::ERR_INSUFFICIENT_BUFFER_SIZE; | 363 | return Service::Audio::ResultInsufficientBuffer; |
| 364 | } | 364 | } |
| 365 | 365 | ||
| 366 | command_buffer_size = 0; | 366 | command_buffer_size = 0; |