7#include "audio_device.hpp"
8#include "../utility/utility.hpp"
9#include "../macros.hpp"
15hi_export_module(hikogui.audio.audio_system);
17hi_export
namespace hi {
inline namespace v1 {
42 [[nodiscard]]
virtual generator<audio_device &>
devices() noexcept = 0;
49 [[nodiscard]]
callback<
void()>
subscribe(Func&& func, callback_flags flags = callback_flags::synchronous) noexcept
51 return _notifier.subscribe(std::forward<Func>(func), flags);
54 auto operator co_await()
const noexcept
56 return _notifier.operator
co_await();
60 notifier<void()> _notifier;
67template<
typename Context>
68concept audio_device_filter = std::convertible_to<Context, audio_device_state> or std::convertible_to<Context, audio_direction>;
70[[nodiscard]]
constexpr bool match_audio_device(audio_device
const &device)
noexcept
76[[nodiscard]]
inline bool match_audio_device(
audio_device const &device, FirstFilter &&first_filter, Filters &&...filters)
noexcept
78 if constexpr (std::convertible_to<FirstFilter, audio_device_state>) {
79 if (device.state() != first_filter) {
82 }
else if constexpr (std::convertible_to<FirstFilter, audio_direction>) {
83 if (not to_bool(device.direction() & first_filter)) {
87 hi_static_no_default();
90 return match_audio_device(device, std::forward<Filters>(filters)...);
100template<audio_device_filter... Filters>
101[[nodiscard]] generator<audio_device &>
audio_devices(Filters &&...filters)
noexcept
104 if (match_audio_device(device, std::forward<Filters>(filters)...)) {
The HikoGUI namespace.
Definition array_generic.hpp:20
generator< audio_device & > audio_devices(Filters &&...filters) noexcept
Get audio devices matching the filter arguments.
Definition audio_system.hpp:101
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
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:230
callback< void()> subscribe(Func &&func, callback_flags flags=callback_flags::synchronous) noexcept
Subscribe a function to be called when the device list changes.
Definition audio_system.hpp:49
virtual generator< audio_device & > devices() noexcept=0
The devices that are part of the audio system.
Definition callback.hpp:77
Definition audio_system.hpp:68
True if T is a forwarded type of Forward.
Definition concepts.hpp:137