diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2021-05-03 22:12:53 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2021-05-03 22:12:53 +0000 |
commit | 9ee351988b4d2d42790be57b14d03ca15fa48727 (patch) | |
tree | addb35eb45fa9d85d036b5e5add608aba4153179 /src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp | |
parent | 040ac5dbdba41f807ee81bbd8f1bfe9e8b44da36 (diff) | |
download | VirtualBox-svn-9ee351988b4d2d42790be57b14d03ca15fa48727.tar.gz |
DrvAudio,DrvHostAudioWasApi: Made WAS API device re-init work (i.e. when needing pfnStreamInitAsync). bugref:9890
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@88851 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp')
-rw-r--r-- | src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp b/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp index 737c9b82830..43d7bf032b6 100644 --- a/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp +++ b/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp @@ -525,6 +525,10 @@ private: RT_NOREF(pszCaller, pwszDeviceId); RTCritSectEnter(&m_CritSect); + + /* + * Update our internal device reference. + */ if (m_pDrvWas) { if (fOutput) @@ -548,6 +552,30 @@ private: } else if (pIDevice) pIDevice->Release(); + + /* + * Tell DrvAudio that the device has changed for one of the directions. + * + * We have to exit the critsect when doing so, or we'll create a locking + * order violation. So, try make sure the VM won't be destroyed while + * till DrvAudio have entered its critical section... + */ + if (m_pDrvWas) + { + PPDMIHOSTAUDIOPORT const pIHostAudioPort = m_pDrvWas->pIHostAudioPort; + if (pIHostAudioPort) + { + VMSTATE const enmVmState = PDMDrvHlpVMState(m_pDrvWas->pDrvIns); + if (enmVmState < VMSTATE_POWERING_OFF) + { + RTCritSectLeave(&m_CritSect); + pIHostAudioPort->pfnNotifyDeviceChanged(pIHostAudioPort, fOutput ? PDMAUDIODIR_OUT : PDMAUDIODIR_IN, NULL); + return; + } + LogFlowFunc(("Ignoring change: enmVmState=%d\n", enmVmState)); + } + } + RTCritSectLeave(&m_CritSect); } }; @@ -2031,7 +2059,7 @@ static DECLCALLBACK(int) drvHostAudioWasHA_StreamDrain(PPDMIHOSTAUDIO pInterface * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} */ static DECLCALLBACK(int) drvHostAudioWasHA_StreamControl(PPDMIHOSTAUDIO pInterface, - PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) + PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) { /** @todo r=bird: I'd like to get rid of this pfnStreamControl method, * replacing it with individual StreamXxxx methods. That would save us @@ -2767,7 +2795,7 @@ static DECLCALLBACK(int) drvHostAudioWasConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pThis->pNotifyClient->lockLeave(); /* - * We need a timer and a R/W critical section for draining streams. + * We need a timer for draining streams. */ rc = PDMDrvHlpTMTimerCreate(pDrvIns, TMCLOCK_REAL, drvHostWasDrainStopTimer, NULL /*pvUser*/, 0 /*fFlags*/, "WasAPI drain", &pThis->hDrainTimer); |