7#include "audio_device.hpp"
8#include "../utility/utility.hpp"
9#include "../coroutine/module.hpp"
10#include "../macros.hpp"
15hi_export_module(hikogui.audio.audio_system);
17namespace hi {
inline namespace v1 {
24 using notifier_type = notifier<>;
25 using callback_token = notifier_type::callback_token;
26 using callback_proto = notifier_type::callback_proto;
46 [[nodiscard]]
virtual generator<audio_device &>
devices() noexcept = 0;
52 callback_token
subscribe(
forward_of<callback_proto> auto&& func, callback_flags flags = callback_flags::synchronous) noexcept
54 return _notifier.subscribe(hi_forward(func), flags);
57 auto operator co_await()
noexcept
59 return _notifier.operator
co_await();
65 notifier_type _notifier;
68template<
typename Context>
69concept audio_device_filter = std::same_as<Context, audio_device_state> or std::same_as<Context, audio_direction>;
71[[nodiscard]]
constexpr bool match_audio_device(
audio_device const &device)
noexcept
77[[nodiscard]]
inline bool match_audio_device(
audio_device const &device, FirstFilter &&first_filter, Filters &&...filters)
noexcept
79 if constexpr (std::same_as<FirstFilter, audio_device_state>) {
80 if (device.state() != first_filter) {
83 }
else if constexpr (std::same_as<FirstFilter, audio_direction>) {
84 if (not to_bool(device.direction() & first_filter)) {
88 hi_static_no_default();
102[[nodiscard]] generator<audio_device &>
audio_devices(Filters &&...filters)
noexcept
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
The HikoGUI API version 1.
Definition lookahead_iterator.hpp:6
generator< audio_device & > audio_devices(Filters &&...filters) noexcept
Get audio devices matching the filter arguments.
Definition audio_system.hpp:102
A set of audio channels which can be rendered and/or captures at the same time.
Definition audio_device.hpp:34
Definition audio_system.hpp:22
static audio_system & global() noexcept
Create an audio system object specific for the current operating system.
Definition audio_system_win32.hpp:229
callback_token subscribe(forward_of< callback_proto > auto &&func, callback_flags flags=callback_flags::synchronous) noexcept
Subscribe a function to be called when the device list changes.
Definition audio_system.hpp:52
virtual generator< audio_device & > devices() noexcept=0
The devices that are part of the audio system.
Definition audio_system.hpp:69
True if T is a forwarded type of Forward.
Definition concepts.hpp:131