- Timestamp:
- May 7, 2021 4:15:46 PM (4 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHda.cpp
r88919 r88934 1341 1341 STAM_REL_PROFILE_START_NS(&pStreamR3->State.StatReset, a); 1342 1342 hdaStreamLock(pStreamShared); 1343 1344 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO1345 1343 hdaR3StreamAsyncIOLock(pStreamR3); 1346 # endif 1344 1347 1345 /* Deal with reset while running. */ 1348 1346 if (pStreamShared->State.fRunning) … … 1355 1353 hdaR3StreamReset(pThis, pThisCC, pStreamShared, pStreamR3, uSD); 1356 1354 1357 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO1358 1355 hdaR3StreamAsyncIOUnlock(pStreamR3); 1359 # endif1360 1356 hdaStreamUnlock(pStreamShared); 1361 1357 STAM_REL_PROFILE_STOP_NS(&pStreamR3->State.StatReset, a); … … 1375 1371 1376 1372 int rc2 = VINF_SUCCESS; 1377 1378 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO1379 1373 if (fRun) 1380 1374 rc2 = hdaR3StreamAsyncIOCreate(pStreamR3); 1381 1375 1382 1376 hdaR3StreamAsyncIOLock(pStreamR3); 1383 # endif1384 1377 if (fRun) 1385 1378 { … … 1466 1459 } 1467 1460 1468 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 1461 /* Make sure to leave the lock before (eventually) starting the timer. */ 1469 1462 hdaR3StreamAsyncIOUnlock(pStreamR3); 1470 # endif1471 /* Make sure to leave the lock before (eventually) starting the timer. */1472 1463 hdaStreamUnlock(pStreamShared); 1473 1464 STAM_REL_PROFILE_STOP_NS((fRun ? &pStreamR3->State.StatStart : &pStreamR3->State.StatStop), r); … … 2813 2804 PHDASTREAM const pStreamShared = &pThis->aStreams[idxStream]; 2814 2805 hdaStreamLock(pStreamShared); 2815 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2816 2806 hdaR3StreamAsyncIOLock(&pThisCC->aStreams[idxStream]); 2817 # endif2818 2807 2819 2808 /* We're doing this unconditionally, hope that's not problematic in any way... */ … … 2825 2814 hdaR3StreamReset(pThis, pThisCC, pStreamShared, &pThisCC->aStreams[idxStream], (uint8_t)idxStream); 2826 2815 2827 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2828 2816 hdaR3StreamAsyncIOUnlock(&pThisCC->aStreams[idxStream]); 2829 # endif2830 2817 hdaStreamUnlock(pStreamShared); 2831 2818 } … … 3411 3398 cbCircBuf = (uint32_t)RTCircBufSize(pStreamR3->State.pCircBuf); 3412 3399 3413 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO3414 3400 /* We take the AIO lock here and releases it after saving the buffer, 3415 3401 otherwise the AIO thread could race us reading out the buffer data. */ 3416 3402 if ( !pStreamR3->State.AIO.fStarted 3417 3403 || RT_SUCCESS(RTCritSectTryEnter(&pStreamR3->State.AIO.CritSect))) 3418 #endif3419 3404 { 3420 3405 cbCircBufUsed = (uint32_t)RTCircBufUsed(pStreamR3->State.pCircBuf); 3421 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO3422 3406 if (cbCircBufUsed == 0 && pStreamR3->State.AIO.fStarted) 3423 3407 RTCritSectLeave(&pStreamR3->State.AIO.CritSect); 3424 #endif3425 3408 } 3426 3409 } … … 3445 3428 RTCircBufReleaseReadBlock(pStreamR3->State.pCircBuf, 0 /* Don't advance read pointer! */); 3446 3429 3447 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO3448 3430 if (pStreamR3->State.AIO.fStarted) 3449 3431 RTCritSectLeave(&pStreamR3->State.AIO.CritSect); 3450 #endif3451 3432 } 3452 3433 … … 3516 3497 PHDASTREAMR3 pStreamR3 = &pThisCC->aStreams[i]; 3517 3498 3518 int rc2;3519 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO3520 3499 /* Make sure to also create the async I/O thread before actually enabling the stream. */ 3521 rc2 = hdaR3StreamAsyncIOCreate(pStreamR3);3500 int rc2 = hdaR3StreamAsyncIOCreate(pStreamR3); 3522 3501 AssertRC(rc2); 3523 3502 3524 3503 /* ... and enabling it. */ 3525 3504 hdaR3StreamAsyncIOEnable(pStreamR3, true /* fEnable */); 3526 #endif3527 3505 /* (Re-)enable the stream. */ 3528 3506 rc2 = hdaR3StreamEnable(pThis, pStreamShared, pStreamR3, true /* fEnable */); … … 4938 4916 NULL /*pfnLoadPrep*/, hdaR3LoadExec, hdaR3LoadDone); 4939 4917 AssertRCReturn(rc, rc); 4940 4941 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO4942 LogRel(("HDA: Asynchronous I/O enabled\n"));4943 # endif4944 4918 4945 4919 /* -
trunk/src/VBox/Devices/Audio/DevHdaStream.cpp
r88918 r88934 79 79 #endif 80 80 81 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO82 81 AssertPtr(pStreamR3->pHDAStateR3); 83 82 AssertPtr(pStreamR3->pHDAStateR3->pDevIns); … … 85 84 RT_SRC_POS, "hda_sd#%RU8", pStreamShared->u8SD); 86 85 AssertRCReturn(rc, rc); 87 #endif88 86 89 87 #ifdef DEBUG … … 174 172 int rc2; 175 173 176 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO177 174 rc2 = hdaR3StreamAsyncIODestroy(pStreamR3); 178 175 AssertRC(rc2); 179 #endif 180 181 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 176 182 177 if (PDMCritSectIsInitialized(&pStreamShared->CritSect)) 183 178 { … … 185 180 AssertRC(rc2); 186 181 } 187 #endif188 182 189 183 if (pStreamR3->State.pCircBuf) … … 1955 1949 * 1956 1950 * This routine is called by both, the synchronous and the asynchronous 1957 * (VBOX_WITH_AUDIO_HDA_ASYNC_IO),implementations.1951 * implementations. 1958 1952 * 1959 1953 * When running synchronously, the device DMA transfers *and* the mixer sink … … 2009 2003 { 2010 2004 bool fDoRead; /* Whether to push data down the driver stack or not. */ 2011 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2012 2005 if (fInTimer) 2013 # endif2014 2006 { 2015 2007 /* … … 2025 2017 Log(("hdaR3StreamUpdate: Warning! Stream #%u has insufficient space free: %u bytes, need %u. Will try move data out of the buffer...\n", 2026 2018 pStreamShared->u8SD, cbStreamFree, cbPeriod)); 2027 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2028 2019 int rc = RTCritSectTryEnter(&pStreamR3->State.AIO.CritSect); 2029 2020 if (RT_SUCCESS(rc)) … … 2034 2025 else 2035 2026 RTThreadYield(); 2036 #else2037 hdaR3StreamPushToMixer(pStreamShared, pStreamR3, pSink, tsNowNs);2038 #endif2039 2027 Log(("hdaR3StreamUpdate: Gained %u bytes.\n", hdaR3StreamGetFree(pStreamR3) - cbStreamFree)); 2040 2028 … … 2061 2049 * Do the DMA transfer. 2062 2050 */ 2063 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2064 2051 rc2 = PDMDevHlpCritSectEnter(pDevIns, &pStreamShared->CritSect, VERR_IGNORED); 2065 2052 AssertRC(rc2); 2066 # endif2067 2053 2068 2054 uint64_t const offWriteBefore = pStreamR3->State.offWrite; 2069 2055 hdaR3StreamDoDmaOutput(pDevIns, pThis, pStreamShared, pStreamR3, RT_MIN(cbStreamFree, cbPeriod), tsNowNs); 2070 2056 2071 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2072 2057 rc2 = PDMDevHlpCritSectLeave(pDevIns, &pStreamShared->CritSect); 2073 2058 AssertRC(rc2); 2074 # endif2075 2059 2076 2060 /* … … 2113 2097 if (fDoRead) 2114 2098 { 2115 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2116 2099 /* Notify the async I/O worker thread that there's work to do. */ 2117 2100 Log5Func(("Notifying AIO thread\n")); 2118 2101 rc2 = hdaR3StreamAsyncIONotify(pStreamR3); 2119 2102 AssertRC(rc2); 2120 # endif2121 2103 /* Update last read timestamp for logging/debugging. */ 2122 2104 pStreamShared->State.tsLastReadNs = tsNowNs; … … 2128 2110 * the mixer and in direction of the host audio devices. 2129 2111 */ 2130 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2131 2112 else 2132 # else2133 if (fDoRead)2134 # endif2135 2113 hdaR3StreamPushToMixer(pStreamShared, pStreamR3, pSink, tsNowNs); 2136 2114 } … … 2146 2124 * from the mixer and into our internal DMA buffer. 2147 2125 */ 2148 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2149 2126 if (!fInTimer) 2150 # endif2151 2127 hdaR3StreamPullFromMixer(pStreamShared, pStreamR3, pSink); 2152 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO 2153 else /* fInTimer */ 2154 # endif 2128 else 2155 2129 { 2156 2130 /* … … 2197 2171 Log(("hdaR3StreamUpdate: Warning! Stream #%u has insufficient data available: %u bytes, need %u. Will try move pull more data into the buffer...\n", 2198 2172 pStreamShared->u8SD, cbStreamUsed, cbPeriod)); 2199 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2200 2173 int rc = RTCritSectTryEnter(&pStreamR3->State.AIO.CritSect); 2201 2174 if (RT_SUCCESS(rc)) … … 2206 2179 else 2207 2180 RTThreadYield(); 2208 #else2209 hdaR3StreamPullFromMixer(pStreamShared, pStreamR3, pSink);2210 #endif2211 2181 Log(("hdaR3StreamUpdate: Gained %u bytes.\n", hdaR3StreamGetUsed(pStreamR3) - cbStreamUsed)); 2212 2182 cbStreamUsed = hdaR3StreamGetUsed(pStreamR3); … … 2220 2190 do 2221 2191 { 2222 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2223 2192 RTCritSectEnter(&pStreamR3->State.AIO.CritSect); 2224 #endif2225 2193 cbStreamUsed = hdaR3StreamGetUsed(pStreamR3); 2226 2194 if (cbStreamUsed < cbPeriod) … … 2241 2209 } 2242 2210 2243 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2244 2211 RTCritSectLeave(&pStreamR3->State.AIO.CritSect); 2245 #endif2246 2212 } while (cbStreamUsed < cbPeriod); 2247 2213 if (cbSilence > 0) … … 2260 2226 if (cbStreamUsed) 2261 2227 { 2262 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2263 2228 rc2 = PDMDevHlpCritSectEnter(pDevIns, &pStreamShared->CritSect, VERR_IGNORED); 2264 2229 AssertRC(rc2); 2265 # endif2266 2230 2267 2231 hdaR3StreamDoDmaInput(pDevIns, pThis, pStreamShared, pStreamR3, 2268 2232 RT_MIN(cbStreamUsed, cbPeriod), fWriteSilence, tsNowNs); 2269 2233 2270 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2271 2234 rc2 = PDMDevHlpCritSectLeave(pDevIns, &pStreamShared->CritSect); 2272 2235 AssertRC(rc2); 2273 # endif2274 2236 } 2275 2237 2276 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2277 2238 /* 2278 2239 * We should always kick the AIO thread. … … 2285 2246 AssertRC(rc2); 2286 2247 pStreamShared->State.tsLastReadNs = tsNowNs; 2287 # endif2288 2248 } 2289 2249 } … … 2301 2261 { 2302 2262 AssertPtrReturnVoid(pStreamShared); 2303 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2304 2263 int rc2 = PDMCritSectEnter(&pStreamShared->CritSect, VINF_SUCCESS); 2305 2264 AssertRC(rc2); 2306 #endif2307 2265 } 2308 2266 … … 2316 2274 { 2317 2275 AssertPtrReturnVoid(pStreamShared); 2318 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2319 2276 int rc2 = PDMCritSectLeave(&pStreamShared->CritSect); 2320 2277 AssertRC(rc2); 2321 # endif2322 2278 } 2323 2279 … … 2531 2487 2532 2488 # endif /* HDA_USE_DMA_ACCESS_HANDLER */ 2533 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO2534 2489 2535 2490 /** … … 2724 2679 } 2725 2680 2726 # endif /* VBOX_WITH_AUDIO_HDA_ASYNC_IO */2727 2681 #endif /* IN_RING3 */ -
trunk/src/VBox/Devices/Audio/DevHdaStream.h
r88662 r88934 26 26 27 27 28 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO29 28 /** 30 29 * HDA stream's state for asynchronous I/O. … … 48 47 /** Pointer to a HDA stream's asynchronous I/O state. */ 49 48 typedef HDASTREAMSTATEAIO *PHDASTREAMSTATEAIO; 50 #endif51 49 52 50 /** … … 268 266 TMTIMERHANDLE hTimer; 269 267 270 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO271 268 /** Pad the structure size to a 64 byte alignment. */ 272 269 uint64_t au64Padding1[4]; … … 274 271 * I/O thread and (basically) the guest. */ 275 272 PDMCRITSECT CritSect; 276 #endif277 273 } HDASTREAM; 278 274 AssertCompileMemberAlignment(HDASTREAM, State.aBdl, 16); … … 312 308 RTLISTANCHORR3 lstDMAHandlers; 313 309 #endif 314 #ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO315 310 /** Asynchronous I/O state members. */ 316 311 HDASTREAMSTATEAIO AIO; 317 #endif318 312 /** Size of the DMA buffer (pCircBuf) in bytes. */ 319 313 uint32_t StatDmaBufSize; … … 378 372 * @{ 379 373 */ 380 # ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO381 374 int hdaR3StreamAsyncIOCreate(PHDASTREAMR3 pStreamR3); 382 375 void hdaR3StreamAsyncIOLock(PHDASTREAMR3 pStreamR3); … … 384 377 void hdaR3StreamAsyncIOEnable(PHDASTREAMR3 pStreamR3, bool fEnable); 385 378 int hdaR3StreamAsyncIONotify(PHDASTREAMR3 pStreamR3); 386 # endif /* VBOX_WITH_AUDIO_HDA_ASYNC_IO */387 379 /** @} */ 388 380 -
trunk/src/VBox/Devices/Config.kmk
r88880 r88934 116 116 endif 117 117 118 # 119 # Enables asynchronous audio data handling 120 # to speed up the actual DMA data routines and keeping up 121 # audio processing out of EMT as much as possible. 122 # 123 # Disabled for AC'97 for now. 118 # AC'97 needs testing: 124 119 #VBOX_AUDIO_DEFS += VBOX_WITH_AUDIO_AC97_ASYNC_IO 125 VBOX_AUDIO_DEFS += VBOX_WITH_AUDIO_HDA_ASYNC_IO126 120 VBOX_AUDIO_DEFS += VBOX_WITH_AUDIO_SB16_ASYNC_IO 127 121
Note:
See TracChangeset
for help on using the changeset viewer.