HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
audio_system.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "audio_device.hpp"
8#include "../unfair_recursive_mutex.hpp"
9#include "../generator.hpp"
10#include <vector>
11#include <memory>
12
13namespace hi::inline v1 {
14
19public:
20 using token_type = notifier<>::token_type;
21
24 [[nodiscard]] static std::unique_ptr<audio_system> make_unique() noexcept;
25
26 audio_system() = default;
27 virtual ~audio_system() = default;
28 audio_system(audio_system const&) = delete;
29 audio_system(audio_system&&) = delete;
30 audio_system& operator=(audio_system const&) = delete;
31 audio_system& operator=(audio_system&&) = delete;
32
40 [[nodiscard]] virtual generator<audio_device *> devices() noexcept = 0;
41
46 token_type subscribe(callback_flags flags, std::invocable<> auto&& func) noexcept
47 {
48 return _notifier.subscribe(flags, hi_forward(func));
49 }
50
55 token_type subscribe(std::invocable<> auto&& func) noexcept
56 {
57 return subscribe(callback_flags::synchronous, hi_forward(func));
58 }
59
60 auto operator co_await() noexcept
61 {
62 return _notifier.operator co_await();
63 }
64
65protected:
66 notifier<> _notifier;
67};
68
69} // namespace hi::inline v1
#define hi_forward(x)
Forward a value, based on the decltype of the value.
Definition required.hpp:29
STL namespace.
A set of audio channels which can be rendered and/or captures at the same time.
Definition audio_device.hpp:31
Definition audio_system.hpp:18
static std::unique_ptr< audio_system > make_unique() noexcept
Create an audio system object specific for the current operating system.
token_type subscribe(std::invocable<> auto &&func) noexcept
Subscribe a function to be called when the device list changes.
Definition audio_system.hpp:55
A return value for a generator-function.
Definition generator.hpp:28
A notifier which can be used to call a set of registered callbacks.
Definition notifier.hpp:24