-
Notifications
You must be signed in to change notification settings - Fork 6
/
audio_out_manager.h
89 lines (75 loc) · 2.19 KB
/
audio_out_manager.h
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
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
// SPDX-License-Identifier: MPL-2.0
#pragma once
#include <array>
#include <mutex>
#include <audio_core/renderer/audio_device.h>
namespace Core {
class System;
}
namespace AudioCore::AudioOut {
class Out;
constexpr size_t MaxOutSessions = 12;
/**
* Manages all audio out sessions.
*/
class Manager {
public:
explicit Manager(Core::System& system);
/**
* Acquire a free session id for opening a new audio out.
*
* @param session_id - Output session_id.
* @return Result code.
*/
Result AcquireSessionId(size_t& session_id);
/**
* Release a session id on close.
*
* @param session_id - Session id to free.
*/
void ReleaseSessionId(size_t session_id);
/**
* Link this manager to the main audio manager.
*
* @return Result code.
*/
Result LinkToManager();
/**
* Start the audio out manager.
*/
void Start();
/**
* Callback function, called by the audio manager when the audio out event is signalled.
*/
void BufferReleaseAndRegister();
/**
* Get a list of audio out device names.
*
* @oaram names - Output container to write names to.
* @return Number of names written.
*/
u32 GetAudioOutDeviceNames(
std::vector<AudioRenderer::AudioDevice::AudioDeviceName>& names) const;
/// Core system
Core::System& system;
/// Array of session ids
std::array<size_t, MaxOutSessions> session_ids{};
/// Array of resource user ids
std::array<size_t, MaxOutSessions> applet_resource_user_ids{};
/// Pointer to each open session
std::array<std::shared_ptr<Out>, MaxOutSessions> sessions{};
/// The number of free sessions
size_t num_free_sessions{};
/// The next session id to be taken
size_t next_session_id{};
/// The next session id to be freed
size_t free_session_id{};
/// Whether this is linked to the audio manager
bool linked_to_manager{};
/// Whether the sessions have been started
bool sessions_started{};
/// Protect state due to audio manager callback
std::recursive_mutex mutex{};
};
} // namespace AudioCore::AudioOut