1 | /* $Id: VBoxMMNotificationClient.h 83238 2020-03-10 09:57:28Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxMMNotificationClient.h - Implementation of the IMMNotificationClient interface
|
---|
4 | * to detect audio endpoint changes.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2017-2020 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef VBOX_INCLUDED_SRC_Audio_VBoxMMNotificationClient_h
|
---|
20 | #define VBOX_INCLUDED_SRC_Audio_VBoxMMNotificationClient_h
|
---|
21 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
22 | # pragma once
|
---|
23 | #endif
|
---|
24 |
|
---|
25 | #include <iprt/critsect.h>
|
---|
26 | #include <iprt/win/windows.h>
|
---|
27 |
|
---|
28 | /* Should fix warning in include\ks.h. */
|
---|
29 | #ifndef _WIN64
|
---|
30 | # ifdef RT_ARCH_X86
|
---|
31 | # define _WIN64 1
|
---|
32 | # else
|
---|
33 | # define _WIN64 0
|
---|
34 | # endif
|
---|
35 | #endif
|
---|
36 |
|
---|
37 | #include <Mmdeviceapi.h>
|
---|
38 |
|
---|
39 | #include "DrvAudio.h"
|
---|
40 |
|
---|
41 | class VBoxMMNotificationClient : IMMNotificationClient
|
---|
42 | {
|
---|
43 | public:
|
---|
44 |
|
---|
45 | VBoxMMNotificationClient();
|
---|
46 | virtual ~VBoxMMNotificationClient();
|
---|
47 |
|
---|
48 | HRESULT Initialize();
|
---|
49 | int RegisterCallback(PPDMDRVINS pDrvIns, PFNPDMHOSTAUDIOCALLBACK pfnCallback);
|
---|
50 | void UnregisterCallback(void);
|
---|
51 | void Dispose();
|
---|
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 | PPDMDRVINS m_pDrvIns;
|
---|
67 | PFNPDMHOSTAUDIOCALLBACK m_pfnCallback;
|
---|
68 |
|
---|
69 | HRESULT AttachToDefaultEndpoint();
|
---|
70 | void DetachFromEndpoint();
|
---|
71 |
|
---|
72 | void doCallback(void);
|
---|
73 |
|
---|
74 | /** @name IMMNotificationClient interface
|
---|
75 | * @{ */
|
---|
76 | IFACEMETHODIMP OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
|
---|
77 | IFACEMETHODIMP OnDeviceAdded(LPCWSTR pwstrDeviceId);
|
---|
78 | IFACEMETHODIMP OnDeviceRemoved(LPCWSTR pwstrDeviceId);
|
---|
79 | IFACEMETHODIMP OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId);
|
---|
80 | IFACEMETHODIMP OnPropertyValueChanged(LPCWSTR /*pwstrDeviceId*/, const PROPERTYKEY /*key*/) { return S_OK; }
|
---|
81 | IFACEMETHODIMP OnDeviceQueryRemove() { return S_OK; }
|
---|
82 | IFACEMETHODIMP OnDeviceQueryRemoveFailed() { return S_OK; }
|
---|
83 | IFACEMETHODIMP OnDeviceRemovePending() { return S_OK; }
|
---|
84 | /** @} */
|
---|
85 |
|
---|
86 | /** @name IUnknown interface
|
---|
87 | * @{ */
|
---|
88 | IFACEMETHODIMP QueryInterface(const IID& iid, void** ppUnk);
|
---|
89 | IFACEMETHODIMP_(ULONG) AddRef();
|
---|
90 | /** @} */
|
---|
91 | };
|
---|
92 | #endif /* !VBOX_INCLUDED_SRC_Audio_VBoxMMNotificationClient_h */
|
---|
93 |
|
---|