audio_core.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <memory>
  5. #include "audio_core/audio_manager.h"
  6. #include "audio_core/renderer/adsp/adsp.h"
  7. #include "audio_core/sink/sink.h"
  8. namespace Core {
  9. class System;
  10. }
  11. namespace AudioCore {
  12. class AudioManager;
  13. /**
  14. * Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP.
  15. */
  16. class AudioCore {
  17. public:
  18. explicit AudioCore(Core::System& system);
  19. ~AudioCore();
  20. /**
  21. * Shutdown the audio core.
  22. */
  23. void Shutdown();
  24. /**
  25. * Get a reference to the audio manager.
  26. *
  27. * @return Ref to the audio manager.
  28. */
  29. AudioManager& GetAudioManager();
  30. /**
  31. * Get the audio output sink currently in use.
  32. *
  33. * @return Ref to the sink.
  34. */
  35. Sink::Sink& GetOutputSink();
  36. /**
  37. * Get the audio input sink currently in use.
  38. *
  39. * @return Ref to the sink.
  40. */
  41. Sink::Sink& GetInputSink();
  42. /**
  43. * Get the ADSP.
  44. *
  45. * @return Ref to the ADSP.
  46. */
  47. AudioRenderer::ADSP::ADSP& GetADSP();
  48. /**
  49. * Toggle NVDEC state, used to avoid stall in playback.
  50. *
  51. * @param active - Set true if nvdec is active, otherwise false.
  52. */
  53. void SetNVDECActive(bool active);
  54. /**
  55. * Get NVDEC state.
  56. */
  57. bool IsNVDECActive() const;
  58. private:
  59. /**
  60. * Create the sinks on startup.
  61. */
  62. void CreateSinks();
  63. /// Main audio manager for audio in/out
  64. std::unique_ptr<AudioManager> audio_manager;
  65. /// Sink used for audio renderer and audio out
  66. std::unique_ptr<Sink::Sink> output_sink;
  67. /// Sink used for audio input
  68. std::unique_ptr<Sink::Sink> input_sink;
  69. /// The ADSP in the sysmodule
  70. std::unique_ptr<AudioRenderer::ADSP::ADSP> adsp;
  71. /// Is NVDec currently active?
  72. bool nvdec_active{false};
  73. };
  74. } // namespace AudioCore