summaryrefslogtreecommitdiffstats
path: root/src/audio_core/audio_renderer.h
blob: a8521904534b8023d1125b90bd640d2bd8ea38e9 (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
// Copyright 2018 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <array>
#include <memory>
#include <vector>

#include "audio_core/behavior_info.h"
#include "audio_core/command_generator.h"
#include "audio_core/common.h"
#include "audio_core/effect_context.h"
#include "audio_core/memory_pool.h"
#include "audio_core/mix_context.h"
#include "audio_core/sink_context.h"
#include "audio_core/splitter_context.h"
#include "audio_core/stream.h"
#include "audio_core/voice_context.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/swap.h"
#include "core/hle/result.h"

namespace Core::Timing {
class CoreTiming;
}

namespace Kernel {
class WritableEvent;
}

namespace Core::Memory {
class Memory;
}

namespace AudioCore {
using DSPStateHolder = std::array<VoiceState*, AudioCommon::MAX_CHANNEL_COUNT>;

class AudioOut;

class AudioRenderer {
public:
    AudioRenderer(Core::Timing::CoreTiming& core_timing, Core::Memory::Memory& memory_,
                  AudioCommon::AudioRendererParameter params,
                  std::shared_ptr<Kernel::WritableEvent> buffer_event, std::size_t instance_number);
    ~AudioRenderer();

    [[nodiscard]] ResultCode UpdateAudioRenderer(const std::vector<u8>& input_params,
                                                 std::vector<u8>& output_params);
    void QueueMixedBuffer(Buffer::Tag tag);
    void ReleaseAndQueueBuffers();
    [[nodiscard]] u32 GetSampleRate() const;
    [[nodiscard]] u32 GetSampleCount() const;
    [[nodiscard]] u32 GetMixBufferCount() const;
    [[nodiscard]] Stream::State GetStreamState() const;

private:
    BehaviorInfo behavior_info{};

    AudioCommon::AudioRendererParameter worker_params;
    std::shared_ptr<Kernel::WritableEvent> buffer_event;
    std::vector<ServerMemoryPoolInfo> memory_pool_info;
    VoiceContext voice_context;
    EffectContext effect_context;
    MixContext mix_context;
    SinkContext sink_context;
    SplitterContext splitter_context;
    std::vector<VoiceState> voices;
    std::unique_ptr<AudioOut> audio_out;
    StreamPtr stream;
    Core::Memory::Memory& memory;
    CommandGenerator command_generator;
    std::size_t elapsed_frame_count{};
    std::vector<s32> temp_mix_buffer{};
};

} // namespace AudioCore