buffer_mixer.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <array>
  5. #include "audio_core/common/common.h"
  6. #include "audio_core/renderer/effect/effect_info_base.h"
  7. #include "common/common_types.h"
  8. namespace AudioCore::Renderer {
  9. class BufferMixerInfo : public EffectInfoBase {
  10. public:
  11. struct ParameterVersion1 {
  12. /* 0x00 */ std::array<s8, MaxMixBuffers> inputs;
  13. /* 0x18 */ std::array<s8, MaxMixBuffers> outputs;
  14. /* 0x30 */ std::array<f32, MaxMixBuffers> volumes;
  15. /* 0x90 */ u32 mix_count;
  16. };
  17. static_assert(sizeof(ParameterVersion1) <= sizeof(EffectInfoBase::InParameterVersion1),
  18. "BufferMixerInfo::ParameterVersion1 has the wrong size!");
  19. struct ParameterVersion2 {
  20. /* 0x00 */ std::array<s8, MaxMixBuffers> inputs;
  21. /* 0x18 */ std::array<s8, MaxMixBuffers> outputs;
  22. /* 0x30 */ std::array<f32, MaxMixBuffers> volumes;
  23. /* 0x90 */ u32 mix_count;
  24. };
  25. static_assert(sizeof(ParameterVersion2) <= sizeof(EffectInfoBase::InParameterVersion2),
  26. "BufferMixerInfo::ParameterVersion2 has the wrong size!");
  27. /**
  28. * Update the info with new parameters, version 1.
  29. *
  30. * @param error_info - Used to write call result code.
  31. * @param in_params - New parameters to update the info with.
  32. * @param pool_mapper - Pool for mapping buffers.
  33. */
  34. void Update(BehaviorInfo::ErrorInfo& error_info, const InParameterVersion1& in_params,
  35. const PoolMapper& pool_mapper) override;
  36. /**
  37. * Update the info with new parameters, version 2.
  38. *
  39. * @param error_info - Used to write call result code.
  40. * @param in_params - New parameters to update the info with.
  41. * @param pool_mapper - Pool for mapping buffers.
  42. */
  43. void Update(BehaviorInfo::ErrorInfo& error_info, const InParameterVersion2& in_params,
  44. const PoolMapper& pool_mapper) override;
  45. /**
  46. * Update the info after command generation. Usually only changes its state.
  47. */
  48. void UpdateForCommandGeneration() override;
  49. /**
  50. * Initialize a new result state. Version 2 only, unused.
  51. *
  52. * @param result_state - Result state to initialize.
  53. */
  54. void InitializeResultState(EffectResultState& result_state) override;
  55. /**
  56. * Update the host-side state with the ADSP-side state. Version 2 only, unused.
  57. *
  58. * @param cpu_state - Host-side result state to update.
  59. * @param dsp_state - AudioRenderer-side result state to update from.
  60. */
  61. void UpdateResultState(EffectResultState& cpu_state, EffectResultState& dsp_state) override;
  62. };
  63. } // namespace AudioCore::Renderer