diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2022-07-17 00:48:45 +0200 |
---|---|---|
committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2022-07-22 02:11:32 +0200 |
commit | 458da8a94877677f086f06cdeecf959ec4283a33 (patch) | |
tree | 583166d77602ad90a0d552f37de8729ad80fd6c1 /src/audio_core/audio_in_manager.h | |
parent | Merge pull request #8598 from Link4565/recv-dontwait (diff) | |
download | yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.gz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.bz2 yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.lz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.xz yuzu-458da8a94877677f086f06cdeecf959ec4283a33.tar.zst yuzu-458da8a94877677f086f06cdeecf959ec4283a33.zip |
Diffstat (limited to 'src/audio_core/audio_in_manager.h')
-rw-r--r-- | src/audio_core/audio_in_manager.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/audio_core/audio_in_manager.h b/src/audio_core/audio_in_manager.h new file mode 100644 index 000000000..75b73a0b6 --- /dev/null +++ b/src/audio_core/audio_in_manager.h @@ -0,0 +1,92 @@ +// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <array> +#include <mutex> +#include <vector> + +#include "audio_core/renderer/audio_device.h" + +namespace Core { +class System; +} + +namespace AudioCore::AudioIn { +class In; + +constexpr size_t MaxInSessions = 4; +/** + * Manages all audio in sessions. + */ +class Manager { +public: + explicit Manager(Core::System& system); + + /** + * Acquire a free session id for opening a new audio in. + * + * @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 the audio in manager to the main audio manager. + * + * @return Result code. + */ + Result LinkToManager(); + + /** + * Start the audio in manager. + */ + void Start(); + + /** + * Callback function, called by the audio manager when the audio in event is signalled. + */ + void BufferReleaseAndRegister(); + + /** + * Get a list of audio in device names. + * + * @oaram names - Output container to write names to. + * @param max_count - Maximum numebr of deivce names to write. Unused + * @param filter - Should the list be filtered? Unused. + * @return Number of names written. + */ + u32 GetDeviceNames(std::vector<AudioRenderer::AudioDevice::AudioDeviceName>& names, + u32 max_count, bool filter); + + /// Core system + Core::System& system; + /// Array of session ids + std::array<size_t, MaxInSessions> session_ids{}; + /// Array of resource user ids + std::array<size_t, MaxInSessions> applet_resource_user_ids{}; + /// Pointer to each open session + std::array<std::shared_ptr<In>, MaxInSessions> 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::AudioIn |