1 | /* $Id: DrvHostAudioDSoundMMNotifClient.h 88628 2021-04-21 10:37:57Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Host audio driver - DSound - Implementation of the IMMNotificationClient interface to detect audio endpoint changes.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2017-2020 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef VBOX_INCLUDED_SRC_Audio_DrvHostAudioDSoundMMNotifClient_h
|
---|
19 | #define VBOX_INCLUDED_SRC_Audio_DrvHostAudioDSoundMMNotifClient_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include <iprt/critsect.h>
|
---|
25 | #include <iprt/win/windows.h>
|
---|
26 |
|
---|
27 | /* Should fix warning in include\ks.h. */
|
---|
28 | #ifndef _WIN64
|
---|
29 | # ifdef RT_ARCH_X86
|
---|
30 | # define _WIN64 1
|
---|
31 | # else
|
---|
32 | # define _WIN64 0
|
---|
33 | # endif
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | #include <Mmdeviceapi.h>
|
---|
37 |
|
---|
38 | #include <VBox/vmm/pdmaudioifs.h>
|
---|
39 |
|
---|
40 |
|
---|
41 | class DrvHostAudioDSoundMMNotifClient : public IMMNotificationClient
|
---|
42 | {
|
---|
43 | public:
|
---|
44 |
|
---|
45 | DrvHostAudioDSoundMMNotifClient(PPDMIAUDIONOTIFYFROMHOST pInterface);
|
---|
46 | virtual ~DrvHostAudioDSoundMMNotifClient();
|
---|
47 |
|
---|
48 | HRESULT Initialize();
|
---|
49 |
|
---|
50 | HRESULT Register(void);
|
---|
51 | void Unregister(void);
|
---|
52 |
|
---|
53 | /** @name IUnknown interface
|
---|
54 | * @{ */
|
---|
55 | IFACEMETHODIMP_(ULONG) Release();
|
---|
56 | /** @} */
|
---|
57 |
|
---|
58 | private:
|
---|
59 |
|
---|
60 | bool m_fRegisteredClient;
|
---|
61 | IMMDeviceEnumerator *m_pEnum;
|
---|
62 | IMMDevice *m_pEndpoint;
|
---|
63 |
|
---|
64 | long m_cRef;
|
---|
65 |
|
---|
66 | PPDMIAUDIONOTIFYFROMHOST m_pIAudioNotifyFromHost;
|
---|
67 |
|
---|
68 | HRESULT AttachToDefaultEndpoint();
|
---|
69 | void DetachFromEndpoint();
|
---|
70 |
|
---|
71 | void doCallback(void);
|
---|
72 |
|
---|
73 | /** @name IMMNotificationClient interface
|
---|
74 | * @{ */
|
---|
75 | IFACEMETHODIMP OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
|
---|
76 | IFACEMETHODIMP OnDeviceAdded(LPCWSTR pwstrDeviceId);
|
---|
77 | IFACEMETHODIMP OnDeviceRemoved(LPCWSTR pwstrDeviceId);
|
---|
78 | IFACEMETHODIMP OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId);
|
---|
79 | IFACEMETHODIMP OnPropertyValueChanged(LPCWSTR /*pwstrDeviceId*/, const PROPERTYKEY /*key*/) { return S_OK; }
|
---|
80 | /** @} */
|
---|
81 |
|
---|
82 | /** @name IUnknown interface
|
---|
83 | * @{ */
|
---|
84 | IFACEMETHODIMP QueryInterface(const IID& iid, void** ppUnk);
|
---|
85 | IFACEMETHODIMP_(ULONG) AddRef();
|
---|
86 | /** @} */
|
---|
87 | };
|
---|
88 | #endif /* !VBOX_INCLUDED_SRC_Audio_DrvHostAudioDSoundMMNotifClient_h */
|
---|
89 |
|
---|