HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
audio_device.hpp
1// Copyright Take Vos 2019-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 "../bigint.hpp"
8#include "audio_device_delegate.hpp"
9#include "audio_stream_config.hpp"
10#include "audio_channel.hpp"
11#include "audio_direction.hpp"
12#include "speaker_mapping.hpp"
13#include "audio_device_id.hpp"
14#include "../label.hpp"
15#include "../enum_metadata.hpp"
16#include <string>
17#include <memory>
18#include <ostream>
19
20namespace hi::inline v1 {
21
22enum class audio_device_state { active, disabled, not_present, unplugged };
23
24// clang-format off
25constexpr auto audio_device_state_metadata = enum_metadata{
26 audio_device_state::active, "active",
27 audio_device_state::disabled, "disabled",
28 audio_device_state::not_present, "not_present",
29 audio_device_state::unplugged, "unplugged",
30};
31// clang-format on
32
33
34[[nodiscard]] inline std::string_view to_string(audio_device_state const &rhs) noexcept
35{
36 return audio_device_state_metadata[rhs];
37}
38
39inline std::ostream &operator<<(std::ostream &lhs, audio_device_state const &rhs)
40{
41 return lhs << audio_device_state_metadata[rhs];
42}
43
53public:
54 audio_device() noexcept = default;
55 virtual ~audio_device() = default;
56
60
65 [[nodiscard]] virtual std::string name() const noexcept = 0;
66
71 [[nodiscard]] virtual label label() const noexcept = 0;
72
75 [[nodiscard]] virtual audio_device_state state() const noexcept = 0;
76
77 [[nodiscard]] virtual audio_direction direction() const noexcept = 0;
78
83 [[nodiscard]] virtual bool exclusive() const noexcept = 0;
84
99 virtual void set_exclusive(bool exclusive) noexcept = 0;
100
106 [[nodiscard]] virtual double sample_rate() const noexcept = 0;
107
111 virtual void set_sample_rate(double sample_rate) noexcept = 0;
112
117 [[nodiscard]] virtual hi::speaker_mapping input_speaker_mapping() const noexcept = 0;
118
123 virtual void set_input_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept = 0;
124
129 [[nodiscard]] virtual std::vector<hi::speaker_mapping> available_input_speaker_mappings() const noexcept = 0;
130
135 [[nodiscard]] virtual hi::speaker_mapping output_speaker_mapping() const noexcept = 0;
136
141 virtual void set_output_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept = 0;
142
147 [[nodiscard]] virtual std::vector<hi::speaker_mapping> available_output_speaker_mappings() const noexcept = 0;
148
163 // virtual void start_stream(std::string id, std::string name) = 0;
164
168 // virtual void stop_stream() noexcept = 0;
169
170private:
171 std::shared_ptr<audio_device_delegate> delegate = {};
172};
173
174} // namespace hi::inline v1
175
176
177template<typename CharT>
178struct std::formatter<hi::audio_device_state, CharT> : std::formatter<char const *, CharT> {
179 auto format(hi::audio_device_state const &t, auto &fc)
180 {
181 return std::formatter<char const *, CharT>::format(hi::to_const_string(t), fc);
182 }
183};
STL namespace.
A set of audio channels which can be rendered and/or captures at the same time.
Definition audio_device.hpp:52
virtual std::string name() const noexcept=0
Get a user friendly name of the audio device.
audio_device_id id
The nonephemeral unique id that for an audio device on the system.
Definition audio_device.hpp:59
Definition audio_device_delegate.hpp:11
Definition audio_device_id.hpp:14
A label consisting of localizable text and an icon.
Definition label.hpp:27
T to_string(T... args)