Changeset 68683 in vbox
- Timestamp:
- Sep 6, 2017 3:26:32 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 117914
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r68680 r68683 139 139 { 140 140 /** Pointer to the driver instance structure. */ 141 PPDMDRVINS pDrvIns;141 PPDMDRVINS pDrvIns; 142 142 /** Our audio host audio interface. */ 143 PDMIHOSTAUDIO IHostAudio; 143 PDMIHOSTAUDIO IHostAudio; 144 /** Critical section to serialize access. */ 145 RTCRITSECT CritSect; 144 146 /** List of found host input devices. */ 145 RTLISTANCHOR lstDevInput;147 RTLISTANCHOR lstDevInput; 146 148 /** List of found host output devices. */ 147 RTLISTANCHOR lstDevOutput;149 RTLISTANCHOR lstDevOutput; 148 150 /** DirectSound configuration options. */ 149 DSOUNDHOSTCFG cfg;151 DSOUNDHOSTCFG cfg; 150 152 /** Whether this backend supports any audio input. */ 151 bool fEnabledIn;153 bool fEnabledIn; 152 154 /** Whether this backend supports any audio output. */ 153 bool fEnabledOut;155 bool fEnabledOut; 154 156 /** The Direct Sound playback interface. */ 155 LPDIRECTSOUND8 pDS;157 LPDIRECTSOUND8 pDS; 156 158 /** The Direct Sound capturing interface. */ 157 LPDIRECTSOUNDCAPTURE8 pDSC;159 LPDIRECTSOUNDCAPTURE8 pDSC; 158 160 #ifdef VBOX_WITH_AUDIO_MMNOTIFICATION_CLIENT 159 VBoxMMNotificationClient *m_pNotificationClient; 161 VBoxMMNotificationClient *m_pNotificationClient; 162 #endif 163 #ifdef VBOX_WITH_AUDIO_CALLBACKS 164 /** Callback function to the upper driver. 165 * Can be NULL if not being used / registered. */ 166 PFNPDMHOSTAUDIOCALLBACK pfnCallback; 160 167 #endif 161 168 #ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS 162 169 /** Pointer to the audio connector interface of the driver/device above us. */ 163 PPDMIAUDIOCONNECTOR pUpIAudioConnector;170 PPDMIAUDIOCONNECTOR pUpIAudioConnector; 164 171 /** Stopped indicator. */ 165 bool fStopped;172 bool fStopped; 166 173 /** Shutdown indicator. */ 167 bool fShutdown;174 bool fShutdown; 168 175 /** Notification thread. */ 169 RTTHREAD Thread;176 RTTHREAD Thread; 170 177 /** Array of events to wait for in notification thread. */ 171 HANDLE aEvents[VBOX_DSOUND_MAX_EVENTS];178 HANDLE aEvents[VBOX_DSOUND_MAX_EVENTS]; 172 179 /** Number of events to wait for in notification thread. 173 180 * Must not exceed VBOX_DSOUND_MAX_EVENTS. */ 174 uint8_t cEvents;181 uint8_t cEvents; 175 182 /** Pointer to the input stream. */ 176 PDSOUNDSTREAM pDSStrmIn;183 PDSOUNDSTREAM pDSStrmIn; 177 184 /** Pointer to the output stream. */ 178 PDSOUNDSTREAM pDSStrmOut;185 PDSOUNDSTREAM pDSStrmOut; 179 186 #endif 180 187 } DRVHOSTDSOUND, *PDRVHOSTDSOUND; … … 2168 2175 2169 2176 2170 static voiddsoundConfigInit(PDRVHOSTDSOUND pThis, PCFGMNODE pCfg)2177 static int dsoundConfigInit(PDRVHOSTDSOUND pThis, PCFGMNODE pCfg) 2171 2178 { 2172 2179 unsigned int uBufsizeOut, uBufsizeIn; … … 2185 2192 &pThis->cfg.uuidPlay, 2186 2193 &pThis->cfg.uuidCapture)); 2194 2195 return VINF_SUCCESS; 2187 2196 } 2188 2197 … … 2375 2384 } 2376 2385 2386 #ifdef VBOX_WITH_AUDIO_CALLBACKS 2387 /** 2388 * @interface_method_impl{PDMIHOSTAUDIO,pfnSetCallback} 2389 */ 2390 static DECLCALLBACK(int) drvHostDSoundSetCallback(PPDMIHOSTAUDIO pInterface, PFNPDMHOSTAUDIOCALLBACK pfnCallback) 2391 { 2392 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2393 /* pfnCallback will be handled below. */ 2394 2395 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 2396 2397 int rc = RTCritSectEnter(&pThis->CritSect); 2398 if (RT_SUCCESS(rc)) 2399 { 2400 LogFunc(("pfnCallback=%p\n", pfnCallback)); 2401 2402 if (pfnCallback) /* Register. */ 2403 { 2404 Assert(pThis->pfnCallback == NULL); 2405 pThis->pfnCallback = pfnCallback; 2406 2407 #ifdef VBOX_WITH_AUDIO_MMNOTIFICATION_CLIENT 2408 if (pThis->m_pNotificationClient) 2409 pThis->m_pNotificationClient->RegisterCallback(pThis->pDrvIns, pfnCallback); 2410 #endif 2411 } 2412 else /* Unregister. */ 2413 { 2414 if (pThis->pfnCallback) 2415 pThis->pfnCallback = NULL; 2416 2417 #ifdef VBOX_WITH_AUDIO_MMNOTIFICATION_CLIENT 2418 if (pThis->m_pNotificationClient) 2419 pThis->m_pNotificationClient->UnregisterCallback(); 2420 #endif 2421 } 2422 2423 int rc2 = RTCritSectLeave(&pThis->CritSect); 2424 AssertRC(rc2); 2425 } 2426 2427 return rc; 2428 } 2429 #endif 2377 2430 2378 2431 /********************************************************************************************************************************* … … 2420 2473 if (pThis->pDrvIns) 2421 2474 CoUninitialize(); 2475 2476 int rc2 = RTCritSectDelete(&pThis->CritSect); 2477 AssertRC(rc2); 2422 2478 2423 2479 LogFlowFuncLeave(); … … 2454 2510 PDMAUDIO_IHOSTAUDIO_CALLBACKS(drvHostDSound); 2455 2511 2512 #ifdef VBOX_WITH_AUDIO_CALLBACKS 2513 /* This backend supports host audio callbacks. */ 2514 pThis->IHostAudio.pfnSetCallback = drvHostDSoundSetCallback; 2515 pThis->pfnCallback = NULL; 2516 #endif 2517 2456 2518 #ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS 2457 2519 /* … … 2500 2562 #endif 2501 2563 2502 /* 2503 * Initialize configuration values. 2504 */ 2505 dsoundConfigInit(pThis, pCfg); 2564 if (RT_SUCCESS(rc)) 2565 { 2566 /* 2567 * Initialize configuration values. 2568 */ 2569 rc = dsoundConfigInit(pThis, pCfg); 2570 if (RT_SUCCESS(rc)) 2571 rc = RTCritSectInit(&pThis->CritSect); 2572 } 2506 2573 2507 2574 return rc; -
trunk/src/VBox/Devices/Audio/VBoxMMNotificationClient.cpp
r68680 r68683 27 27 #pragma warning(pop) 28 28 29 #ifdef LOG_GROUP 30 # undef LOG_GROUP 31 #endif 29 32 #define LOG_GROUP LOG_GROUP_DRV_HOST_AUDIO 30 33 #include <VBox/log.h> … … 69 72 } 70 73 74 int VBoxMMNotificationClient::RegisterCallback(PPDMDRVINS pDrvIns, PFNPDMHOSTAUDIOCALLBACK pfnCallback) 75 { 76 this->m_pDrvIns = pDrvIns; 77 this->m_pfnCallback = pfnCallback; 78 79 return VINF_SUCCESS; 80 } 81 82 void VBoxMMNotificationClient::UnregisterCallback(void) 83 { 84 this->m_pDrvIns = NULL; 85 this->m_pfnCallback = NULL; 86 } 87 71 88 HRESULT VBoxMMNotificationClient::AttachToDefaultEndpoint(void) 72 89 { … … 81 98 STDMETHODIMP VBoxMMNotificationClient::OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState) 82 99 { 83 char *pszState = "UNKNOWN";100 char *pszState = "unknown"; 84 101 85 102 switch (dwNewState) 86 103 { 87 104 case DEVICE_STATE_ACTIVE: 88 pszState = " ACTIVE";105 pszState = "active"; 89 106 break; 90 107 case DEVICE_STATE_DISABLED: 91 pszState = " DISABLED";108 pszState = "disabled"; 92 109 break; 93 110 case DEVICE_STATE_NOTPRESENT: 94 pszState = " NOTPRESENT";111 pszState = "not present"; 95 112 break; 96 113 case DEVICE_STATE_UNPLUGGED: 97 pszState = "UNPLUGGED"; 114 pszState = "unplugged"; 115 break; 116 default: 98 117 break; 99 118 } 100 119 101 LogFunc(("%ls: %s\n", pwstrDeviceId, pszState)); 120 LogRel2(("Audio: Device '%ls' has changed state to '%s'\n", pwstrDeviceId, pszState)); 121 122 #ifdef VBOX_WITH_AUDIO_CALLBACKS 123 AssertPtr(this->m_pDrvIns); 124 AssertPtr(this->m_pfnCallback); 125 126 if (this->m_pfnCallback) 127 /* Ignore rc */ this->m_pfnCallback(this->m_pDrvIns, PDMAUDIOBACKENDCBTYPE_DEVICES_CHANGED, NULL, 0); 128 #endif 129 102 130 return S_OK; 103 131 } -
trunk/src/VBox/Devices/Audio/VBoxMMNotificationClient.h
r68680 r68683 25 25 #include <Mmdeviceapi.h> 26 26 27 #include "DrvAudio.h" 28 27 29 class VBoxMMNotificationClient : IMMNotificationClient 28 30 { … … 33 35 34 36 HRESULT Initialize(); 37 int RegisterCallback(PPDMDRVINS pDrvIns, PFNPDMHOSTAUDIOCALLBACK pfnCallback); 38 void UnregisterCallback(void); 35 39 void Dispose(); 36 40 … … 42 46 private: 43 47 44 bool m_fRegisteredClient;45 IMMDeviceEnumerator *m_pEnum;46 IMMDevice *m_pEndpoint;48 bool m_fRegisteredClient; 49 IMMDeviceEnumerator *m_pEnum; 50 IMMDevice *m_pEndpoint; 47 51 48 long m_cRef; 52 long m_cRef; 53 54 PPDMDRVINS m_pDrvIns; 55 PFNPDMHOSTAUDIOCALLBACK m_pfnCallback; 49 56 50 57 HRESULT AttachToDefaultEndpoint();
Note:
See TracChangeset
for help on using the changeset viewer.