HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
audio_device_win32.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 "audio_stream_format.hpp"
9#include "audio_format_range.hpp"
10#include "../generator.hpp"
11
12struct IMMDevice;
13struct IPropertyStore;
14struct IMMEndpoint;
15struct IAudioEndpointVolume;
16struct IAudioMeterInformation;
17struct IAudioClient;
18
19namespace hi::inline v1 {
20
24public:
25 audio_device_win32(IMMDevice *device);
27
34 [[nodiscard]] static std::string get_device_id(IMMDevice *device);
35
37 void update_state() noexcept override;
38 [[nodiscard]] hi::label label() const noexcept override;
39 [[nodiscard]] audio_device_state state() const noexcept override;
40 [[nodiscard]] audio_direction direction() const noexcept override;
41 [[nodiscard]] bool exclusive() const noexcept override;
42 void set_exclusive(bool exclusive) noexcept override;
43 [[nodiscard]] double sample_rate() const noexcept override;
44 void set_sample_rate(double sample_rate) noexcept override;
45 [[nodiscard]] hi::speaker_mapping input_speaker_mapping() const noexcept override;
46 void set_input_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept override;
47 [[nodiscard]] std::vector<hi::speaker_mapping> available_input_speaker_mappings() const noexcept override;
48 [[nodiscard]] hi::speaker_mapping output_speaker_mapping() const noexcept override;
49 void set_output_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept override;
50 [[nodiscard]] std::vector<hi::speaker_mapping> available_output_speaker_mappings() const noexcept override;
51 [[nodiscard]] bool supports_format(audio_stream_format const& format) const noexcept;
53private:
54 std::string _end_point_id;
55 audio_device_state _previous_state;
56 audio_direction _direction;
57 bool _exclusive = false;
58 double _sample_rate = 0.0;
59 hi::speaker_mapping _speaker_mapping = hi::speaker_mapping::none;
60 audio_stream_format _current_stream_format;
61
62 IMMDevice *_device = nullptr;
63 IMMEndpoint *_end_point = nullptr;
64 IPropertyStore *_property_store = nullptr;
65 IAudioClient *_audio_client = nullptr;
66
67 [[nodiscard]] std::string end_point_name() const noexcept;
68
73 [[nodiscard]] std::string device_name() const noexcept;
74
78 [[nodiscard]] std::string end_point_description() const noexcept;
79
80 GUID pin_category() const noexcept;
81
87 unsigned int wave_id() const;
88
91 void update_supported_formats() noexcept;
92
104 [[nodiscard]] audio_stream_format
105 find_exclusive_stream_format(double sample_rate, hi::speaker_mapping speaker_mapping) noexcept;
106
109 [[nodiscard]] audio_stream_format shared_stream_format() const;
110
111 [[nodiscard]] generator<audio_format_range> get_format_ranges() const noexcept;
112};
113
114} // namespace hi::inline v1
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_device_win32.hpp:23
static std::string get_device_id(IMMDevice *device)
Get the device id for the given win32 audio end-point.
void update_state() noexcept override
@beginprivatemethods
Definition audio_format_range.hpp:14
The format of a stream of audio.
Definition audio_stream_format.hpp:15
A return value for a generator-function.
Definition generator.hpp:28
A label consisting of localizable text and an icon.
Definition label.hpp:27