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
10struct IMMDevice;
11struct IPropertyStore;
12struct IMMEndpoint;
13struct IAudioEndpointVolume;
14struct IAudioMeterInformation;
15struct IAudioClient;
16
17namespace hi::inline v1 {
18
22public:
23 audio_device_win32(IMMDevice *device);
25
26 [[nodiscard]] std::string name() const noexcept override;
27 [[nodiscard]] hi::label label() const noexcept override;
28 [[nodiscard]] audio_device_state state() const noexcept override;
29 [[nodiscard]] audio_direction direction() const noexcept override;
30 [[nodiscard]] bool exclusive() const noexcept override;
31 void set_exclusive(bool exclusive) noexcept override;
32 [[nodiscard]] double sample_rate() const noexcept override;
33 void set_sample_rate(double sample_rate) noexcept override;
34 [[nodiscard]] hi::speaker_mapping input_speaker_mapping() const noexcept override;
35 void set_input_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept override;
36 [[nodiscard]] std::vector<hi::speaker_mapping> available_input_speaker_mappings() const noexcept override;
37 [[nodiscard]] hi::speaker_mapping output_speaker_mapping() const noexcept override;
38 void set_output_speaker_mapping(hi::speaker_mapping speaker_mapping) noexcept override;
39 [[nodiscard]] std::vector<hi::speaker_mapping> available_output_speaker_mappings() const noexcept override;
40
41 [[nodiscard]] bool supports_format(audio_stream_format const &format) const noexcept;
42
45 [[nodiscard]] static audio_device_id get_id(IMMDevice *device) noexcept;
46
47private:
48 audio_direction _direction;
49 bool _exclusive = false;
50 double _sample_rate = 0.0;
51 hi::speaker_mapping _speaker_mapping = hi::speaker_mapping::none;
52 audio_stream_format _current_stream_format;
53
54 IMMDevice *_device = nullptr;
55 IMMEndpoint *_end_point = nullptr;
56 IPropertyStore *_property_store = nullptr;
57 IAudioClient *_audio_client = nullptr;
58
63 std::string device_name() const noexcept;
64
68 std::string end_point_name() const noexcept;
69
81 [[nodiscard]] audio_stream_format
82 find_exclusive_stream_format(double sample_rate, hi::speaker_mapping speaker_mapping) noexcept;
83
86 [[nodiscard]] audio_stream_format shared_stream_format() const;
87};
88
89} // 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:52
Definition audio_device_id.hpp:14
Definition audio_device_win32.hpp:21
std::string name() const noexcept override
Get a user friendly name of the audio device.
The format of a stream of audio.
Definition audio_stream_format.hpp:15
A label consisting of localizable text and an icon.
Definition label.hpp:27