1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <span>
#include "common/common_types.h"
#include "core/hle/service/audio/errors.h"
namespace Kernel {
class KProcess;
}
namespace AudioCore::Renderer {
class BehaviorInfo;
class VoiceContext;
class MixContext;
class SinkContext;
class SplitterContext;
class EffectContext;
class MemoryPoolInfo;
class PerformanceManager;
class InfoUpdater {
struct UpdateDataHeader {
explicit UpdateDataHeader(u32 revision_) : revision{revision_} {}
/* 0x00 */ u32 revision;
/* 0x04 */ u32 behaviour_size{};
/* 0x08 */ u32 memory_pool_size{};
/* 0x0C */ u32 voices_size{};
/* 0x10 */ u32 voice_resources_size{};
/* 0x14 */ u32 effects_size{};
/* 0x18 */ u32 mix_size{};
/* 0x1C */ u32 sinks_size{};
/* 0x20 */ u32 performance_buffer_size{};
/* 0x24 */ char unk24[4];
/* 0x28 */ u32 render_info_size{};
/* 0x2C */ char unk2C[0x10];
/* 0x3C */ u32 size{sizeof(UpdateDataHeader)};
};
static_assert(sizeof(UpdateDataHeader) == 0x40, "UpdateDataHeader has the wrong size!");
public:
explicit InfoUpdater(std::span<const u8> input, std::span<u8> output,
Kernel::KProcess* process_handle, BehaviorInfo& behaviour);
/**
* Update the voice channel resources.
*
* @param voice_context - Voice context to update.
* @return Result code.
*/
Result UpdateVoiceChannelResources(VoiceContext& voice_context);
/**
* Update voices.
*
* @param voice_context - Voice context to update.
* @param memory_pools - Memory pools to use for these voices.
* @param memory_pool_count - Number of memory pools.
* @return Result code.
*/
Result UpdateVoices(VoiceContext& voice_context, std::span<MemoryPoolInfo> memory_pools,
u32 memory_pool_count);
/**
* Update effects.
*
* @param effect_context - Effect context to update.
* @param renderer_active - Whether the AudioRenderer is active.
* @param memory_pools - Memory pools to use for these voices.
* @param memory_pool_count - Number of memory pools.
* @return Result code.
*/
Result UpdateEffects(EffectContext& effect_context, bool renderer_active,
std::span<MemoryPoolInfo> memory_pools, u32 memory_pool_count);
/**
* Update mixes.
*
* @param mix_context - Mix context to update.
* @param mix_buffer_count - Number of mix buffers.
* @param effect_context - Effect context to update effort order.
* @param splitter_context - Splitter context for the mixes.
* @return Result code.
*/
Result UpdateMixes(MixContext& mix_context, u32 mix_buffer_count, EffectContext& effect_context,
SplitterContext& splitter_context);
/**
* Update sinks.
*
* @param sink_context - Sink context to update.
* @param memory_pools - Memory pools to use for these voices.
* @param memory_pool_count - Number of memory pools.
* @return Result code.
*/
Result UpdateSinks(SinkContext& sink_context, std::span<MemoryPoolInfo> memory_pools,
u32 memory_pool_count);
/**
* Update memory pools.
*
* @param memory_pools - Memory pools to use for these voices.
* @param memory_pool_count - Number of memory pools.
* @return Result code.
*/
Result UpdateMemoryPools(std::span<MemoryPoolInfo> memory_pools, u32 memory_pool_count);
/**
* Update the performance buffer.
*
* @param output - Output buffer for performance metrics.
* @param output_size - Output buffer size.
* @param performance_manager - Performance manager..
* @return Result code.
*/
Result UpdatePerformanceBuffer(std::span<u8> output, u64 output_size,
PerformanceManager* performance_manager);
/**
* Update behaviour.
*
* @param behaviour - Behaviour to update.
* @return Result code.
*/
Result UpdateBehaviorInfo(BehaviorInfo& behaviour);
/**
* Update errors.
*
* @param behaviour - Behaviour to update.
* @return Result code.
*/
Result UpdateErrorInfo(const BehaviorInfo& behaviour);
/**
* Update splitter.
*
* @param splitter_context - Splitter context to update.
* @return Result code.
*/
Result UpdateSplitterInfo(SplitterContext& splitter_context);
/**
* Update renderer info.
*
* @param elapsed_frames - Number of elapsed frames.
* @return Result code.
*/
Result UpdateRendererInfo(u64 elapsed_frames);
/**
* Check that the input.output sizes match their expected values.
*
* @return Result code.
*/
Result CheckConsumedSize();
private:
/**
* Update effects version 1.
*
* @param effect_context - Effect context to update.
* @param renderer_active - Is the AudioRenderer active?
* @param memory_pools - Memory pools to use for these voices.
* @param memory_pool_count - Number of memory pools.
* @return Result code.
*/
Result UpdateEffectsVersion1(EffectContext& effect_context, bool renderer_active,
std::span<MemoryPoolInfo> memory_pools, u32 memory_pool_count);
/**
* Update effects version 2.
*
* @param effect_context - Effect context to update.
* @param renderer_active - Is the AudioRenderer active?
* @param memory_pools - Memory pools to use for these voices.
* @param memory_pool_count - Number of memory pools.
* @return Result code.
*/
Result UpdateEffectsVersion2(EffectContext& effect_context, bool renderer_active,
std::span<MemoryPoolInfo> memory_pools, u32 memory_pool_count);
/// Input buffer
u8 const* input;
/// Input buffer start
std::span<const u8> input_origin;
/// Output buffer start
u8* output;
/// Output buffer start
std::span<u8> output_origin;
/// Input header
const UpdateDataHeader* in_header;
/// Output header
UpdateDataHeader* out_header;
/// Expected input size, see CheckConsumedSize
u64 expected_input_size;
/// Expected output size, see CheckConsumedSize
u64 expected_output_size;
/// Unused
Kernel::KProcess* process_handle;
/// Behaviour
BehaviorInfo& behaviour;
};
} // namespace AudioCore::Renderer
|