2022-07-16 18:48:45 -04:00
|
|
|
// 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;
|
|
|
|
/**
|
2022-09-13 13:50:39 -04:00
|
|
|
* Main audio class, stored inside the core, and holding the audio manager, all sinks, and the ADSP.
|
2022-07-16 18:48:45 -04:00
|
|
|
*/
|
|
|
|
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();
|
|
|
|
|
2022-09-04 00:41:06 -04:00
|
|
|
/**
|
|
|
|
* Toggle NVDEC state, used to avoid stall in playback.
|
|
|
|
*
|
|
|
|
* @param active - Set true if nvdec is active, otherwise false.
|
|
|
|
*/
|
|
|
|
void SetNVDECActive(bool active);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get NVDEC state.
|
|
|
|
*/
|
|
|
|
bool IsNVDECActive() const;
|
|
|
|
|
2022-07-16 18:48:45 -04:00
|
|
|
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;
|
2022-09-04 00:41:06 -04:00
|
|
|
/// Is NVDec currently active?
|
|
|
|
bool nvdec_active{false};
|
2022-07-16 18:48:45 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace AudioCore
|