Changeset 89184 in vbox for trunk/src/VBox
- Timestamp:
- May 19, 2021 8:58:09 PM (4 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r89131 r89184 2063 2063 2064 2064 /** 2065 * Asynchronous worker for drvAudioStreamDestroy. 2066 * 2067 * Does DISABLE and releases reference, possibly destroying the stream. 2068 * 2069 * @param pThis Pointer to the DrvAudio instance data. 2070 * @param pStreamEx The stream. One reference for us to release. 2071 */ 2072 static DECLCALLBACK(void) drvAudioStreamDestroyAsync(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx) 2073 { 2074 LogFlow(("pThis=%p pStreamEx=%p (%s)\n", pThis, pStreamEx, pStreamEx->Core.szName)); 2075 2076 /** @todo r=bird: This isn't doing the trick for core audio, as the big 2077 * simple-minded critsect is held while the often very slow 2078 * AudioQueueDestroy call is made, blocking creation and manipulation 2079 * of new streams. Sigh^3. */ 2080 2081 /** @todo can we somehow drain it instead? */ 2082 int rc2 = drvAudioStreamControlInternal(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE); 2083 LogFlow(("DISABLE done: %Rrc\n", rc2)); 2084 AssertRC(rc2); 2085 2086 drvAudioStreamReleaseInternal(pThis, pStreamEx, true /*fMayDestroy*/); 2087 LogFlow(("returning\n")); 2088 } 2089 2090 2091 /** 2065 2092 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamDestroy} 2066 2093 */ … … 2121 2148 } 2122 2149 2123 /* We don't really care about the status here as we'll release a reference regardless of the state. */ 2124 /** @todo can we somehow drain it instead? */ 2125 int rc2 = drvAudioStreamControlInternal(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE); 2126 AssertRC(rc2); 2127 2128 drvAudioStreamReleaseInternal(pThis, pStreamEx, true /*fMayDestroy*/); 2150 /* 2151 * Now, if the backend requests asynchronous disabling and destruction 2152 * push the disabling and destroying over to a worker thread. 2153 * 2154 * This is a general offloading feature that all backends should make use of, 2155 * however it's rather precarious on macs where stopping an already draining 2156 * stream may take 8-10ms which naturally isn't something we should be doing 2157 * on an EMT. 2158 */ 2159 if (!(pThis->BackendCfg.fFlags & PDMAUDIOBACKEND_F_ASYNC_STREAM_DESTROY)) 2160 drvAudioStreamDestroyAsync(pThis, pStreamEx); 2161 else 2162 { 2163 int rc2 = RTReqPoolCallEx(pThis->hReqPool, 0 /*cMillies*/, NULL /*phReq*/, 2164 RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT, 2165 (PFNRT)drvAudioStreamDestroyAsync, 2, pThis, pStreamEx); 2166 LogFlowFunc(("hReqInitAsync=%p rc2=%Rrc\n", pStreamEx->hReqInitAsync, rc2)); 2167 AssertRCStmt(rc2, drvAudioStreamDestroyAsync(pThis, pStreamEx)); 2168 } 2129 2169 } 2130 2170 else … … 4387 4427 && ( pIHostDrvAudio->pfnStreamInitAsync 4388 4428 || pIHostDrvAudio->pfnDoOnWorkerThread 4389 || (pThis->BackendCfg.fFlags & PDMAUDIOBACKEND_F_ASYNC_HINT) ))4429 || (pThis->BackendCfg.fFlags & (PDMAUDIOBACKEND_F_ASYNC_HINT | PDMAUDIOBACKEND_F_ASYNC_STREAM_DESTROY)) )) 4390 4430 { 4391 4431 char szName[16]; -
trunk/src/VBox/Devices/Audio/DrvHostAudioCoreAudio.cpp
r89167 r89184 703 703 RTStrCopy(pBackendCfg->szName, sizeof(pBackendCfg->szName), "Core Audio"); 704 704 pBackendCfg->cbStream = sizeof(COREAUDIOSTREAM); 705 pBackendCfg->fFlags = 0;705 pBackendCfg->fFlags = PDMAUDIOBACKEND_F_ASYNC_STREAM_DESTROY; 706 706 /* For Core Audio we provide one stream per device for now. */ 707 707 pBackendCfg->cMaxStreamsIn = PDMAudioHostEnumCountMatching(&pThis->Devices, PDMAUDIODIR_IN); … … 1637 1637 1638 1638 /** 1639 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamInitAsync}1640 */1641 static DECLCALLBACK(int) drvHostAudioCaHA_StreamInitAsync(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, bool fDestroyed)1642 {1643 RT_NOREF(pInterface, pStream, fDestroyed);1644 return VINF_SUCCESS;1645 }1646 1647 1648 /**1649 1639 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 1650 1640 */ … … 1707 1697 if (pStreamCA->hAudioQueue) 1708 1698 { 1709 LogFlowFunc(("Disposing of the queue ...\n" , orc));1710 orc = AudioQueueDispose(pStreamCA->hAudioQueue, TRUE /*inImmediate/synchronously*/); 1699 LogFlowFunc(("Disposing of the queue ...\n")); 1700 orc = AudioQueueDispose(pStreamCA->hAudioQueue, TRUE /*inImmediate/synchronously*/); /* may take some time */ 1711 1701 LogFlowFunc(("AudioQueueDispose -> %#x (%d)\n", orc, orc)); 1712 1702 AssertMsg(orc == noErr, ("AudioQueueDispose -> orc=%#x\n", orc)); … … 2643 2633 pThis->IHostAudio.pfnStreamConfigHint = NULL; 2644 2634 pThis->IHostAudio.pfnStreamCreate = drvHostAudioCaHA_StreamCreate; 2645 pThis->IHostAudio.pfnStreamInitAsync = drvHostAudioCaHA_StreamInitAsync;2635 pThis->IHostAudio.pfnStreamInitAsync = NULL; 2646 2636 pThis->IHostAudio.pfnStreamDestroy = drvHostAudioCaHA_StreamDestroy; 2647 2637 pThis->IHostAudio.pfnStreamNotifyDeviceChanged = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.