Changeset 89885 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Jun 24, 2021 11:28:32 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145343
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHda.cpp
r89878 r89885 4528 4528 "BufSizeInMs" 4529 4529 "|BufSizeOutMs" 4530 "|InitialDelayMs"4531 4530 "|DebugEnabled" 4532 4531 "|DebugPathOut", … … 4552 4551 return PDMDEV_SET_ERROR(pDevIns, VERR_OUT_OF_RANGE, 4553 4552 N_("HDA configuration error: 'BufSizeOutMs' is out of bound, max 2000 ms")); 4554 4555 /** @devcfgm{hda,InitialDelayMs,uint16_t,0,256,12,ms}4556 * How long to delay when a stream starts before engaging the asynchronous I/O4557 * thread from the DMA timer callback. Because it's used from the DMA timer4558 * callback, it will implicitly be rounded up to the next timer period.4559 * This is for adding a little host scheduling leeway into the playback. */4560 /** @todo InitialDelayMs is rather pointless, DrvAudio does pre-buffering in4561 * both directions now. (bird, 2021-06-08) */4562 rc = pHlp->pfnCFGMQueryU16Def(pCfg, "InitialDelayMs", &pThis->msInitialDelay, 12);4563 if (RT_FAILURE(rc))4564 return PDMDEV_SET_ERROR(pDevIns, rc, N_("HDA configuration error: failed to read 'InitialDelayMs' as uint16_t"));4565 if (pThis->msInitialDelay > 256)4566 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,4567 N_("HDA configuration error: Out of range: 0 <= InitialDelayMs < 256: %u"), pThis->msInitialDelay);4568 4553 4569 4554 rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "DebugEnabled", &pThisCC->Dbg.fEnabled, false); -
trunk/src/VBox/Devices/Audio/DevHda.h
r89878 r89885 143 143 /** Current IRQ level. */ 144 144 uint8_t u8IRQL; 145 uint8_t abPadding[4 + 2];146 /** Number of milliseconds to delay kicking off the AIO when a stream starts.147 * @sa InitialDelayMs config value. */148 uint16_t msInitialDelay;149 145 /** Config: Internal input DMA buffer size override, specified in milliseconds. 150 146 * Zero means default size according to buffer and stream config. -
trunk/src/VBox/Devices/Audio/DevHdaStream.cpp
r89884 r89885 683 683 work the AIO thread. */ 684 684 pStreamShared->State.fInputPreBuffered = false; 685 pStreamShared->State.cbInputPreBuffer = PDMAudioPropsMilliToBytes(&pCfg->Props, pThis->msInitialDelay); 686 pStreamShared->State.cbInputPreBuffer = RT_MIN(cbMaxPeriod * 2, pStreamShared->State.cbInputPreBuffer); 685 pStreamShared->State.cbInputPreBuffer = cbMaxPeriod * 2; 687 686 688 687 /* … … 750 749 * channels we don't support / need to save space. 751 750 */ 752 uint32_t cbCircBuf = PDMAudioPropsMilliToBytes(&pCfg->Props, pThis->msInitialDelay +RT_MS_1SEC * 6 / uTransferHz);751 uint32_t cbCircBuf = PDMAudioPropsMilliToBytes(&pCfg->Props, RT_MS_1SEC * 6 / uTransferHz); 753 752 LogRel2(("HDA: Stream #%RU8 default ring buffer size is %RU32 bytes / %RU64 ms\n", 754 753 uSD, cbCircBuf, PDMAudioPropsBytesToMilli(&pCfg->Props, cbCircBuf))); … … 861 860 pStreamShared->State.tsLastTransferNs = 0; 862 861 pStreamShared->State.tsLastReadNs = 0; 863 pStreamShared->State.tsAioDelayEnd = UINT64_MAX;864 862 pStreamShared->State.tsStart = 0; 865 863 … … 1007 1005 pStreamShared->State.tsLastReadNs = RTTimeNanoTS(); 1008 1006 pStreamShared->State.tsStart = tsNow; 1009 pStreamShared->State.tsAioDelayEnd = tsNow + PDMDevHlpTimerFromMilli(pDevIns, pStreamShared->hTimer, pThis->msInitialDelay); 1010 Log3Func(("#%u: tsStart=%RU64 tsAioDelayEnd=%RU64 tsLastReadNs=%RU64\n", pStreamShared->u8SD, 1011 pStreamShared->State.tsStart, pStreamShared->State.tsAioDelayEnd, pStreamShared->State.tsLastReadNs)); 1012 1007 Log3Func(("#%u: tsStart=%RU64 tsLastReadNs=%RU64\n", 1008 pStreamShared->u8SD, pStreamShared->State.tsStart, pStreamShared->State.tsLastReadNs)); 1009 RT_NOREF(pDevIns, pThis); 1013 1010 } 1014 1011 … … 1019 1016 { 1020 1017 Log3Func(("#%u\n", pStreamShared->u8SD)); 1021 pStreamShared->State.tsAioDelayEnd = UINT64_MAX;1018 RT_NOREF(pStreamShared); 1022 1019 } 1023 1020 … … 1372 1369 } 1373 1370 #endif /* IN_RING3 || VBOX_HDA_WITH_ON_REG_ACCESS_DMA */ 1374 1375 1371 1376 1372 #ifdef IN_RING3 … … 2236 2232 /* 2237 2233 * Should we push data to down thru the mixer to and to the host drivers? 2238 *2239 * We initially delay this by pThis->msInitialDelay, but after than we'll2240 * kick the AIO thread every time we've put more data in the buffer (which is2241 * every time) as the host audio device needs to get data in a timely manner.2242 *2243 * (We used to try only wake up the AIO thread according to pThis->uIoTimer2244 * and host wall clock, but that meant we would miss a wakup after the DMA2245 * timer was called a little late or if TM entered into catch-up mode.)2246 2234 */ 2247 bool fKickAioThread; 2248 if (!pStreamShared->State.tsAioDelayEnd) 2249 fKickAioThread = pStreamShared->State.offWrite > offWriteBefore 2250 || hdaR3StreamGetFree(pStreamR3) < pStreamShared->State.cbAvgTransfer * 2; 2251 else if (PDMDevHlpTimerGet(pDevIns, pStreamShared->hTimer) >= pStreamShared->State.tsAioDelayEnd) 2252 { 2253 Log3Func(("Initial delay done: Passed tsAioDelayEnd.\n")); 2254 pStreamShared->State.tsAioDelayEnd = 0; 2255 fKickAioThread = true; 2256 } 2257 else if (hdaR3StreamGetFree(pStreamR3) < pStreamShared->State.cbAvgTransfer * 2) 2258 { 2259 Log3Func(("Initial delay done: Passed running short on buffer.\n")); 2260 pStreamShared->State.tsAioDelayEnd = 0; 2261 fKickAioThread = true; 2262 } 2263 else 2264 { 2265 Log3Func(("Initial delay pending...\n")); 2266 fKickAioThread = false; 2267 } 2235 bool fKickAioThread = pStreamShared->State.offWrite > offWriteBefore 2236 || hdaR3StreamGetFree(pStreamR3) < pStreamShared->State.cbAvgTransfer * 2; 2268 2237 2269 2238 Log3Func(("msDelta=%RU64 (vs %u) cbStreamFree=%#x (vs %#x) => fKickAioThread=%RTbool\n", -
trunk/src/VBox/Devices/Audio/DevHdaStream.h
r89876 r89885 116 116 uint64_t tsLastReadNs; 117 117 118 /** This is set to the timer clock time when the msInitialDelay period is over.119 * Once reached, this is set to zero to avoid unnecessary time queries. */120 uint64_t tsAioDelayEnd;121 118 /** The start time for the playback (on the timer clock). */ 122 119 uint64_t tsStart; … … 154 151 /** Current loop number within the current scheduling step. */ 155 152 uint32_t idxScheduleLoop; 156 157 /** Aligning the next members on 16 bytes. */158 uint64_t u64Padding;159 153 160 154 /** Buffer descriptors and additional timer scheduling state. … … 252 246 TMTIMERHANDLE hTimer; 253 247 254 #if 0255 248 /** Pad the structure size to a 64 byte alignment. */ 256 249 uint64_t au64Padding1[2]; 257 #endif258 250 } HDASTREAM; 259 251 AssertCompileMemberAlignment(HDASTREAM, State.aBdl, 16);
Note:
See TracChangeset
for help on using the changeset viewer.