diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2022-07-17 00:48:45 +0200 |
---|---|---|
committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2022-07-22 02:11:32 +0200 |
commit | 458da8a94877677f086f06cdeecf959ec4283a33 (patch) | |
tree | 583166d77602ad90a0d552f37de8729ad80fd6c1 /src/audio_core/audio_core.h | |
parent | Merge pull request #8598 from Link4565/recv-dontwait (diff) | |
download | yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.gz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.bz2 yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.lz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.xz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.zst yuzu-458da8a94877677f086f06cdeecf959ec4283a33.zip |
Diffstat (limited to 'src/audio_core/audio_core.h')
-rw-r--r-- | src/audio_core/audio_core.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h new file mode 100644 index 000000000..0f7d61ee4 --- /dev/null +++ b/src/audio_core/audio_core.h @@ -0,0 +1,100 @@ +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <memory> + +#include "audio_core/audio_manager.h" +#include "audio_core/renderer/adsp/adsp.h" +#include "audio_core/sink/sink.h" + +namespace Core { +class System; +} + +namespace AudioCore { + +class AudioManager; +/** + * Main audio class, sotred inside the core, and holding the audio manager, all sinks, and the ADSP. + */ +class AudioCore { +public: + explicit AudioCore(Core::System& system); + ~AudioCore(); + + /** + * Shutdown the audio core. + */ + void Shutdown(); + + /** + * Get a reference to the audio manager. + * + * @return Ref to the audio manager. + */ + AudioManager& GetAudioManager(); + + /** + * Get the audio output sink currently in use. + * + * @return Ref to the sink. + */ + Sink::Sink& GetOutputSink(); + + /** + * Get the audio input sink currently in use. + * + * @return Ref to the sink. + */ + Sink::Sink& GetInputSink(); + + /** + * Get the ADSP. + * + * @return Ref to the ADSP. + */ + AudioRenderer::ADSP::ADSP& GetADSP(); + + /** + * Pause the sink. Called from the core. + * + * @param pausing - Is this pause due to an actual pause, or shutdown? + * Unfortunately, shutdown also pauses streams, which can cause issues. + */ + void PauseSinks(bool pausing) const; + + /** + * Get the size of the current stream queue. + * + * @return Current stream queue size. + */ + u32 GetStreamQueue() const; + + /** + * Get the size of the current stream queue. + * + * @param size - New stream size. + */ + void SetStreamQueue(u32 size); + +private: + /** + * Create the sinks on startup. + */ + void CreateSinks(); + + /// Main audio manager for audio in/out + std::unique_ptr<AudioManager> audio_manager; + /// Sink used for audio renderer and audio out + std::unique_ptr<Sink::Sink> output_sink; + /// Sink used for audio input + std::unique_ptr<Sink::Sink> input_sink; + /// The ADSP in the sysmodule + std::unique_ptr<AudioRenderer::ADSP::ADSP> adsp; + /// Current size of the stream queue + std::atomic<u32> estimated_queue{0}; +}; + +} // namespace AudioCore |