1 | /* $Id: VBoxMMNotificationClient.h 68683 2017-09-06 15:26:32Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBoxMMNotificationClient.h - Implementation of the IMMNotificationClient interface
|
---|
4 | * to detect audio endpoint changes.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2017 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_MMNOTIFICATIONCLIENT_H___
|
---|
20 | #define ___VBOX_MMNOTIFICATIONCLIENT_H___
|
---|
21 |
|
---|
22 | #include <iprt/critsect.h>
|
---|
23 | #include <iprt/win/windows.h>
|
---|
24 |
|
---|
25 | #include <Mmdeviceapi.h>
|
---|
26 |
|
---|
27 | #include "DrvAudio.h"
|
---|
28 |
|
---|
29 | class VBoxMMNotificationClient : IMMNotificationClient
|
---|
30 | {
|
---|
31 | public:
|
---|
32 |
|
---|
33 | VBoxMMNotificationClient();
|
---|
34 | virtual ~VBoxMMNotificationClient();
|
---|
35 |
|
---|
36 | HRESULT Initialize();
|
---|
37 | int RegisterCallback(PPDMDRVINS pDrvIns, PFNPDMHOSTAUDIOCALLBACK pfnCallback);
|
---|
38 | void UnregisterCallback(void);
|
---|
39 | void Dispose();
|
---|
40 |
|
---|
41 | /** @name IUnknown interface
|
---|
42 | * @{ */
|
---|
43 | IFACEMETHODIMP_(ULONG) Release();
|
---|
44 | /** @} */
|
---|
45 |
|
---|
46 | private:
|
---|
47 |
|
---|
48 | bool m_fRegisteredClient;
|
---|
49 | IMMDeviceEnumerator *m_pEnum;
|
---|
50 | IMMDevice *m_pEndpoint;
|
---|
51 |
|
---|
52 | long m_cRef;
|
---|
53 |
|
---|
54 | PPDMDRVINS m_pDrvIns;
|
---|
55 | PFNPDMHOSTAUDIOCALLBACK m_pfnCallback;
|
---|
56 |
|
---|
57 | HRESULT AttachToDefaultEndpoint();
|
---|
58 | void DetachFromEndpoint();
|
---|
59 |
|
---|
60 | /** @name IMMNotificationClient interface
|
---|
61 | * @{ */
|
---|
62 | IFACEMETHODIMP OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState);
|
---|
63 | IFACEMETHODIMP OnDeviceAdded(LPCWSTR pwstrDeviceId);
|
---|
64 | IFACEMETHODIMP OnDeviceRemoved(LPCWSTR pwstrDeviceId);
|
---|
65 | IFACEMETHODIMP OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDefaultDeviceId);
|
---|
66 | IFACEMETHODIMP OnPropertyValueChanged(LPCWSTR /*pwstrDeviceId*/, const PROPERTYKEY /*key*/) { return S_OK; }
|
---|
67 | IFACEMETHODIMP OnDeviceQueryRemove() { return S_OK; }
|
---|
68 | IFACEMETHODIMP OnDeviceQueryRemoveFailed() { return S_OK; }
|
---|
69 | IFACEMETHODIMP OnDeviceRemovePending() { return S_OK; }
|
---|
70 | /** @} */
|
---|
71 |
|
---|
72 | /** @name IUnknown interface
|
---|
73 | * @{ */
|
---|
74 | IFACEMETHODIMP QueryInterface(const IID& iid, void** ppUnk);
|
---|
75 | IFACEMETHODIMP_(ULONG) AddRef();
|
---|
76 | /** @} */
|
---|
77 | };
|
---|
78 | #endif /* ___VBOX_MMNOTIFICATIONCLIENT_H___ */
|
---|
79 |
|
---|