-
Notifications
You must be signed in to change notification settings - Fork 6
/
audio_render_manager.cpp
70 lines (53 loc) · 1.67 KB
/
audio_render_manager.cpp
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
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: MPL-2.0
#include <audio_core/audio_render_manager.h>
#include <audio_core/common/audio_renderer_parameter.h>
#include <audio_core/common/feature_support.h>
#include <core/core.h>
namespace AudioCore::AudioRenderer {
Manager::Manager(Core::System& system_)
: system{system_}, system_manager{std::make_unique<SystemManager>(system)} {
std::iota(session_ids.begin(), session_ids.end(), 0);
}
Manager::~Manager() {
Stop();
}
void Manager::Stop() {
system_manager->Stop();
}
SystemManager& Manager::GetSystemManager() {
return *system_manager;
}
Result Manager::GetWorkBufferSize(const AudioRendererParameterInternal& params,
u64& out_count) const {
if (!CheckValidRevision(params.revision)) {
return Service::Audio::ResultInvalidRevision;
}
out_count = System::GetWorkBufferSize(params);
return ResultSuccess;
}
s32 Manager::GetSessionId() {
std::scoped_lock l{session_lock};
auto session_id{session_ids[session_count]};
if (session_id == -1) {
return -1;
}
session_ids[session_count] = -1;
session_count++;
return session_id;
}
void Manager::ReleaseSessionId(const s32 session_id) {
std::scoped_lock l{session_lock};
session_ids[--session_count] = session_id;
}
u32 Manager::GetSessionCount() const {
std::scoped_lock l{session_lock};
return session_count;
}
bool Manager::AddSystem(System& system_) {
return system_manager->Add(system_);
}
bool Manager::RemoveSystem(System& system_) {
return system_manager->Remove(system_);
}
} // namespace AudioCore::AudioRenderer