summaryrefslogtreecommitdiffstats
path: root/src/audio_core/audio_core.h
blob: e33e00a3e90c683de099b94be4e9ca5401bb7c1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// 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, stored 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();

    /**
     * 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;

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;
    /// Is NVDec currently active?
    bool nvdec_active{false};
};

} // namespace AudioCore