28 audio_system_win32() : super(), _notification_client(std::make_unique<audio_system_win32_notification_client>(
this))
37 reinterpret_cast<LPVOID *
>(&_device_enumerator)));
38 hi_assert(_device_enumerator);
40 _device_enumerator->RegisterEndpointNotificationCallback(_notification_client.
get());
48 if (_device_enumerator) {
49 _device_enumerator->UnregisterEndpointNotificationCallback(_notification_client.
get());
50 _device_enumerator->Release();
56 for (hilet& device : _devices) {
62 class audio_system_win32_notification_client :
public IMMNotificationClient {
64 virtual ~audio_system_win32_notification_client() =
default;
66 audio_system_win32_notification_client(
audio_system_win32 *system) : IMMNotificationClient(), _system(system) {}
70 loop::main().wfree_post_function([
this]() {
71 _system->update_device_list();
79 loop::main().wfree_post_function([
this]() {
80 _system->update_device_list();
95 hi_assert_not_null(device_id);
96 loop::main().wfree_post_function([
this]() {
97 _system->update_device_list();
105 loop::main().wfree_post_function([
this]() {
106 _system->update_device_list();
107 _system->_notifier();
114 loop::main().wfree_post_function([
this]() {
115 _system->update_device_list();
116 _system->_notifier();
137 audio_system_win32 *_system;
158 hi_axiom(loop::main().on_thread());
159 hi_log_info(
"Updating audio device list:");
162 if (
FAILED(_device_enumerator->EnumAudioEndpoints(
191 hi_log_error(
"EnumAudioEndpoints()->Item({})->get_device_id failed: {}", i, e.
what());
198 return item->id() == win32_device_id;
208 _devices.
back()->update_state();
226 friend class audio_system_win32_notification_client;
std::string get_last_error_message()
Get the OS error message from the last error received on this thread.
Definition exception_win32_impl.hpp:31
static audio_system & global() noexcept
Create an audio system object specific for the current operating system.
Definition audio_system_win32.hpp:229