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
91
92
93
94
95
96
97
98
99
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <span>
#include "audio_core/renderer/system.h"
#include "core/hle/service/audio/errors.h"
namespace Core {
class System;
}
namespace Kernel {
class KTransferMemory;
class KProcess;
} // namespace Kernel
namespace AudioCore {
struct AudioRendererParameterInternal;
namespace Renderer {
class Manager;
/**
* Audio Renderer, wraps the main audio system and is mainly responsible for handling service calls.
*/
class Renderer {
public:
explicit Renderer(Core::System& system, Manager& manager, Kernel::KEvent* rendered_event);
/**
* Initialize the renderer.
* Registers the system with the Renderer::Manager, allocates workbuffers and initializes
* everything to a default state.
*
* @param params - Input parameters to initialize the system with.
* @param transfer_memory - Game-supplied memory for all workbuffers. Unused.
* @param transfer_memory_size - Size of the transfer memory. Unused.
* @param process_handle - Process handle, also used for memory.
* @param applet_resource_user_id - Applet id for this renderer. Unused.
* @param session_id - Session id of this renderer.
* @return Result code.
*/
Result Initialize(const AudioRendererParameterInternal& params,
Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size,
Kernel::KProcess* process_handle, u64 applet_resource_user_id,
s32 session_id);
/**
* Finalize the renderer for shutdown.
*/
void Finalize();
/**
* Get the renderer's system.
*
* @return Reference to the system.
*/
System& GetSystem();
/**
* Start the renderer.
*/
void Start();
/**
* Stop the renderer.
*/
void Stop();
/**
* Update the audio renderer with new information.
* Called via RequestUpdate from the AudRen:U service.
*
* @param input - Input buffer containing the new data.
* @param performance - Optional performance buffer for outputting performance metrics.
* @param output - Output data from the renderer.
* @return Result code.
*/
Result RequestUpdate(std::span<const u8> input, std::span<u8> performance,
std::span<u8> output);
private:
/// System core
Core::System& core;
/// Manager this renderer is registered with
Manager& manager;
/// Is the audio renderer initialized?
bool initialized{};
/// Is the system registered with the manager?
bool system_registered{};
/// Audio render system, main driver of audio rendering
System system;
};
} // namespace Renderer
} // namespace AudioCore
|