UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WindowsMMNotificationClient.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "HAL/Platform.h"
6
7#include <atomic>
8#include "AudioMixer.h"
9#include "Misc/ScopeRWLock.h"
10
13
15
17#include <mmdeviceapi.h> // IMMNotificationClient
18#include <audiopolicy.h> // IAudioSessionEvents
20
23
24namespace Audio
25{
26 class IAudioMixerDeviceChangedListener;
27
28 class FWindowsMMNotificationClient final : public IMMNotificationClient
29#if PLATFORM_WINDOWS
30 , public IAudioSessionEvents
31#endif //PLATFORM_WINDOWS
32 {
33 public:
36
37 // TODO: Ideally we'd use the cache instead of ask for this.
39
42
45
48
49 // Begin IUnknown overrides
53 // End IUnknown overrides
54
55 // Begin IMMNotificationClient overrides
61 // End IMMNotificationClient overrides
62
63#if PLATFORM_WINDOWS
67
68 // Begin IAudioSessionEvents overrides
71 LPCGUID EventContext) override;
72
75 LPCGUID EventContext) override;
76
78 float NewVolume,
79 BOOL NewMute,
80 LPCGUID EventContext) override;
81
83 DWORD ChannelCount,
85 DWORD ChangedChannel,
86 LPCGUID EventContext) override;
87
90 LPCGUID EventContext) override;
91
92 HRESULT STDMETHODCALLTYPE OnStateChanged(
93 AudioSessionState NewState) override;
94
97 // End IAudioSessionEvents overrides
98
99 private:
101 TComPtr<IAudioSessionManager> SessionManager;
104
105 bool bComInitialized = false;
106 std::atomic<bool> bHasDisconnectSessionHappened = false;
107
108#endif //PLATFORM_WINDOWS
109
110 private:
111 LONG Ref = 1; // Start with self-reference
113 FRWLock ListenersSetRwLock;
114 TComPtr<IMMDeviceEnumerator> DeviceEnumerator = nullptr;
115 };
116}// namespace Audio
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define THIRD_PARTY_INCLUDES_START
Definition GenericPlatformCompilerPreSetup.h:63
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition WindowsMMNotificationClient.h:32
HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key)
Definition WindowsMMNotificationClient.cpp:187
HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow InFlow, ERole InRole, LPCWSTR pwstrDeviceId) override
Definition WindowsMMNotificationClient.cpp:386
WINDOWSMMDEVICEENUMERATION_API bool IsRenderDevice(const FString &InDeviceId) const
Definition WindowsMMNotificationClient.cpp:368
WINDOWSMMDEVICEENUMERATION_API uint32 ReleaseClient()
Definition WindowsMMNotificationClient.cpp:250
HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState) override
Definition WindowsMMNotificationClient.cpp:306
HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId) override
Definition WindowsMMNotificationClient.cpp:330
HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId) override
Definition WindowsMMNotificationClient.cpp:349
WINDOWSMMDEVICEENUMERATION_API FWindowsMMNotificationClient()
Definition WindowsMMNotificationClient.cpp:483
ULONG STDMETHODCALLTYPE AddRef() override
Definition WindowsMMNotificationClient.cpp:132
WINDOWSMMDEVICEENUMERATION_API FString GetFriendlyName(const FString InDeviceID)
Definition WindowsMMNotificationClient.cpp:288
HRESULT STDMETHODCALLTYPE QueryInterface(const IID &IId, void **UnknownPtrPtr) override
Definition WindowsMMNotificationClient.cpp:149
~FWindowsMMNotificationClient()
Definition WindowsMMNotificationClient.cpp:440
WINDOWSMMDEVICEENUMERATION_API TComPtr< IMMDevice > GetDevice(const FString InDeviceID) const
Definition WindowsMMNotificationClient.cpp:236
WINDOWSMMDEVICEENUMERATION_API void UnRegisterDeviceDeviceChangedListener(Audio::IAudioMixerDeviceChangedListener *DeviceChangedListener)
Definition WindowsMMNotificationClient.cpp:116
ULONG STDMETHODCALLTYPE Release() override
Definition WindowsMMNotificationClient.cpp:137
WINDOWSMMDEVICEENUMERATION_API void RegisterDeviceChangedListener(Audio::IAudioMixerDeviceChangedListener *DeviceChangedListener)
Definition WindowsMMNotificationClient.cpp:123
Definition AudioMixer.h:415
Definition COMPointer.h:19
Definition CriticalSection.h:14
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53
Definition Voronoi.cpp:10