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 tt {
18
22public:
23 audio_device_win32(IMMDevice *device);
25
26 [[nodiscard]] std::string name() const noexcept override;
27 [[nodiscard]] tt::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]] tt::speaker_mapping input_speaker_mapping() const noexcept override;
35 void set_input_speaker_mapping(tt::speaker_mapping speaker_mapping) noexcept override;
36 [[nodiscard]] std::vector<tt::speaker_mapping> available_input_speaker_mappings() const noexcept override;
37 [[nodiscard]] tt::speaker_mapping output_speaker_mapping() const noexcept override;
38 void set_output_speaker_mapping(tt::speaker_mapping speaker_mapping) noexcept override;
39 [[nodiscard]] std::vector<tt::speaker_mapping> available_output_speaker_mappings() const noexcept override;
40
41
42 [[nodiscard]] bool supports_format(audio_stream_format const &format) const noexcept;
43
46 [[nodiscard]] static audio_device_id get_id(IMMDevice *device) noexcept;
47
48private:
49 audio_direction _direction;
50 bool _exclusive = false;
51 double _sample_rate = 0.0;
52 tt::speaker_mapping _speaker_mapping = tt::speaker_mapping::none;
53 audio_stream_format _current_stream_format;
54
55 IMMDevice *_device = nullptr;
56 IMMEndpoint *_end_point = nullptr;
57 IPropertyStore *_property_store = nullptr;
58 IAudioClient *_audio_client = nullptr;
59
64 std::string device_name() const noexcept;
65
69 std::string end_point_name() const noexcept;
70
82 [[nodiscard]] audio_stream_format find_exclusive_stream_format(double sample_rate, tt::speaker_mapping speaker_mapping) noexcept;
83
86 [[nodiscard]] audio_stream_format shared_stream_format() const;
87};
88
89} // namespace tt
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
void set_output_speaker_mapping(tt::speaker_mapping speaker_mapping) noexcept override
Set the output speaker mapping.
static audio_device_id get_id(IMMDevice *device) noexcept
Get the device id for the given win32 audio end-point.
std::vector< tt::speaker_mapping > available_output_speaker_mappings() const noexcept override
Speaker mapping that are available in the current configuration.
audio_device_state state() const noexcept override
Get the current state of the audio device.
bool exclusive() const noexcept override
Check if the device is in exclusive mode.
std::string name() const noexcept override
Get a user friendly name of the audio device.
tt::speaker_mapping input_speaker_mapping() const noexcept override
Get the currently configured input speaker mapping.
void set_exclusive(bool exclusive) noexcept override
Set the device in exclusive or shared mode.
tt::speaker_mapping output_speaker_mapping() const noexcept override
Get the currently configured output speaker mapping.
void set_input_speaker_mapping(tt::speaker_mapping speaker_mapping) noexcept override
Set the input speaker mapping.
double sample_rate() const noexcept override
Get the currently configured sample rate.
std::vector< tt::speaker_mapping > available_input_speaker_mappings() const noexcept override
Speaker mapping that are available in the current configuration.
void set_sample_rate(double sample_rate) noexcept override
Set the sample rate.
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