diff options
Diffstat (limited to 'src/audio_core/mix_context.cpp')
| -rw-r--r-- | src/audio_core/mix_context.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/audio_core/mix_context.cpp b/src/audio_core/mix_context.cpp index f6f119a11..042891490 100644 --- a/src/audio_core/mix_context.cpp +++ b/src/audio_core/mix_context.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "audio_core/behavior_info.h" | 5 | #include "audio_core/behavior_info.h" |
| 6 | #include "audio_core/common.h" | 6 | #include "audio_core/common.h" |
| 7 | #include "audio_core/effect_context.h" | ||
| 7 | #include "audio_core/mix_context.h" | 8 | #include "audio_core/mix_context.h" |
| 8 | #include "audio_core/splitter_context.h" | 9 | #include "audio_core/splitter_context.h" |
| 9 | 10 | ||
| @@ -11,7 +12,8 @@ namespace AudioCore { | |||
| 11 | MixContext::MixContext() = default; | 12 | MixContext::MixContext() = default; |
| 12 | MixContext::~MixContext() = default; | 13 | MixContext::~MixContext() = default; |
| 13 | 14 | ||
| 14 | void MixContext::Initialize(const BehaviorInfo& behavior_info, std::size_t mix_count) { | 15 | void MixContext::Initialize(const BehaviorInfo& behavior_info, std::size_t mix_count, |
| 16 | std::size_t effect_count) { | ||
| 15 | info_count = mix_count; | 17 | info_count = mix_count; |
| 16 | infos.resize(info_count); | 18 | infos.resize(info_count); |
| 17 | auto& final_mix = GetInfo(AudioCommon::FINAL_MIX); | 19 | auto& final_mix = GetInfo(AudioCommon::FINAL_MIX); |
| @@ -21,6 +23,10 @@ void MixContext::Initialize(const BehaviorInfo& behavior_info, std::size_t mix_c | |||
| 21 | sorted_info.push_back(&info); | 23 | sorted_info.push_back(&info); |
| 22 | } | 24 | } |
| 23 | 25 | ||
| 26 | for (auto& info : infos) { | ||
| 27 | info.SetEffectCount(effect_count); | ||
| 28 | } | ||
| 29 | |||
| 24 | // Only initialize our edge matrix and node states if splitters are supported | 30 | // Only initialize our edge matrix and node states if splitters are supported |
| 25 | if (behavior_info.IsSplitterSupported()) { | 31 | if (behavior_info.IsSplitterSupported()) { |
| 26 | node_states.Initialize(mix_count); | 32 | node_states.Initialize(mix_count); |
| @@ -185,7 +191,8 @@ ServerMixInfo::InParams& ServerMixInfo::GetInParams() { | |||
| 185 | } | 191 | } |
| 186 | 192 | ||
| 187 | bool ServerMixInfo::Update(EdgeMatrix& edge_matrix, const MixInfo::InParams& mix_in, | 193 | bool ServerMixInfo::Update(EdgeMatrix& edge_matrix, const MixInfo::InParams& mix_in, |
| 188 | BehaviorInfo& behavior_info, SplitterContext& splitter_context) { | 194 | BehaviorInfo& behavior_info, SplitterContext& splitter_context, |
| 195 | EffectContext& effect_context) { | ||
| 189 | in_params.volume = mix_in.volume; | 196 | in_params.volume = mix_in.volume; |
| 190 | in_params.sample_rate = mix_in.sample_rate; | 197 | in_params.sample_rate = mix_in.sample_rate; |
| 191 | in_params.buffer_count = mix_in.buffer_count; | 198 | in_params.buffer_count = mix_in.buffer_count; |
| @@ -206,6 +213,15 @@ bool ServerMixInfo::Update(EdgeMatrix& edge_matrix, const MixInfo::InParams& mix | |||
| 206 | in_params.splitter_id = AudioCommon::NO_SPLITTER; | 213 | in_params.splitter_id = AudioCommon::NO_SPLITTER; |
| 207 | } | 214 | } |
| 208 | 215 | ||
| 216 | ResetEffectProcessingOrder(); | ||
| 217 | const auto effect_count = effect_context.GetCount(); | ||
| 218 | for (std::size_t i = 0; i < effect_count; i++) { | ||
| 219 | auto* effect_info = effect_context.GetInfo(i); | ||
| 220 | if (effect_info->GetMixID() == in_params.mix_id) { | ||
| 221 | effect_processing_order[effect_info->GetProcessingOrder()] = static_cast<s32>(i); | ||
| 222 | } | ||
| 223 | } | ||
| 224 | |||
| 209 | // TODO(ogniK): Update effect processing order | 225 | // TODO(ogniK): Update effect processing order |
| 210 | return require_sort; | 226 | return require_sort; |
| 211 | } | 227 | } |
| @@ -228,6 +244,21 @@ void ServerMixInfo::Cleanup() { | |||
| 228 | std::memset(in_params.mix_volume.data(), 0, sizeof(float) * in_params.mix_volume.size()); | 244 | std::memset(in_params.mix_volume.data(), 0, sizeof(float) * in_params.mix_volume.size()); |
| 229 | } | 245 | } |
| 230 | 246 | ||
| 247 | void ServerMixInfo::SetEffectCount(std::size_t count) { | ||
| 248 | effect_processing_order.resize(count); | ||
| 249 | ResetEffectProcessingOrder(); | ||
| 250 | } | ||
| 251 | |||
| 252 | void ServerMixInfo::ResetEffectProcessingOrder() { | ||
| 253 | for (auto& order : effect_processing_order) { | ||
| 254 | order = AudioCommon::NO_EFFECT_ORDER; | ||
| 255 | } | ||
| 256 | } | ||
| 257 | |||
| 258 | s32 ServerMixInfo::GetEffectOrder(std::size_t i) const { | ||
| 259 | return effect_processing_order.at(i); | ||
| 260 | } | ||
| 261 | |||
| 231 | bool ServerMixInfo::UpdateConnection(EdgeMatrix& edge_matrix, const MixInfo::InParams& mix_in, | 262 | bool ServerMixInfo::UpdateConnection(EdgeMatrix& edge_matrix, const MixInfo::InParams& mix_in, |
| 232 | SplitterContext& splitter_context) { | 263 | SplitterContext& splitter_context) { |
| 233 | // Mixes are identical | 264 | // Mixes are identical |