Changeset 73585 in vbox for trunk/src/VBox
- Timestamp:
- Aug 9, 2018 12:32:51 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124224
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r73583 r73585 2277 2277 } 2278 2278 2279 if ( pThis->pHostDrvAudio2280 && pThis->pHostDrvAudio->pfnGetStatus2281 && pThis->pHostDrvAudio->pfnGetStatus(pThis->pHostDrvAudio, PDMAUDIODIR_IN) != PDMAUDIOBACKENDSTS_RUNNING)2282 {2283 rc = VERR_AUDIO_STREAM_NOT_READY;2284 break;2285 }2286 2287 2279 /* 2288 2280 * Read from the parent buffer (that is, the guest buffer) which … … 2291 2283 uint32_t cfReadTotal = 0; 2292 2284 2293 uint32_t cfToRead = RT_MIN(AUDIOMIXBUF_B2F(&pStream->Guest.MixBuf, cbBuf), AudioMixBufLive(&pStream->Guest.MixBuf)); 2285 const uint32_t cfBuf = AUDIOMIXBUF_B2F(&pStream->Guest.MixBuf, cbBuf); 2286 2287 uint32_t cfToRead = RT_MIN(cfBuf, AudioMixBufLive(&pStream->Guest.MixBuf)); 2294 2288 while (cfToRead) 2295 2289 { … … 2315 2309 } 2316 2310 2311 /* If we were not able to read as much data as requested, fill up the returned 2312 * data with silence. 2313 * 2314 * This is needed to keep the device emulation DMA transfers up and running at a constant rate. */ 2315 if (cfReadTotal < cfBuf) 2316 { 2317 Log3Func(("[%s] Filling in silence (%RU64ms / %RU64ms)\n", pStream->szName, 2318 DrvAudioHlpFramesToMilli(cfBuf - cfReadTotal, &pStream->Guest.Cfg.Props), 2319 DrvAudioHlpFramesToMilli(cfBuf, &pStream->Guest.Cfg.Props))); 2320 2321 DrvAudioHlpClearBuf(&pStream->Guest.Cfg.Props, 2322 (uint8_t *)pvBuf + AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfReadTotal), 2323 AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfBuf - cfReadTotal), 2324 cfBuf - cfReadTotal); 2325 2326 cfReadTotal = cfBuf; 2327 } 2328 2317 2329 if (cfReadTotal) 2318 2330 { … … 2326 2338 } 2327 2339 2340 pStream->tsLastReadWrittenNs = RTTimeNanoTS(); 2341 2342 Log3Func(("[%s] fEnabled=%RTbool, cbReadTotal=%RU32, rc=%Rrc\n", pStream->szName, pThis->In.fEnabled, cbReadTotal, rc)); 2343 2328 2344 } while (0); 2329 2345 2330 Log3Func(("[%s] fEnabled=%RTbool, cbReadTotal=%RU32, rc=%Rrc\n", pStream->szName, pThis->In.fEnabled, cbReadTotal, rc));2331 2346 2332 2347 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 2728 2743 const uint32_t cfReadable = AudioMixBufLive(&pStream->Guest.MixBuf); 2729 2744 2730 Log3Func(("[%s] cfReadable=%RU32 (%zu bytes)\n", pStream->szName, cfReadable,2731 AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfReadable)));2732 2733 2745 cbReadable = AUDIOMIXBUF_F2B(&pStream->Guest.MixBuf, cfReadable); 2734 } 2735 2746 2747 if (!cbReadable) 2748 { 2749 /* 2750 * If Nothing is readable, check if the stream on the backend side is ready to be read from. 2751 * If it isn't, return the number of bytes readable since the last read from this stream. 2752 * 2753 * This is needed for backends (e.g. VRDE) which do not provide any input data in certain 2754 * situations, but the device emulation needs input data to keep the DMA transfers moving. 2755 * Reading the actual data from a stream then will return silence then. 2756 */ 2757 if (!DrvAudioHlpStreamStatusCanRead( 2758 pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pStream->pvBackend))) 2759 { 2760 cbReadable = DrvAudioHlpNanoToBytes(RTTimeNanoTS() - pStream->tsLastReadWrittenNs, 2761 &pStream->Host.Cfg.Props); 2762 Log3Func(("[%s] Backend stream not ready, returning silence\n", pStream->szName)); 2763 } 2764 } 2765 2766 /* Make sure to align the readable size to the guest's frame size. */ 2767 cbReadable = DrvAudioHlpBytesAlign(cbReadable, &pStream->Guest.Cfg.Props); 2768 } 2769 2770 Log3Func(("[%s] cbReadable=%RU32 (%RU64ms)\n", 2771 pStream->szName, cbReadable, DrvAudioHlpBytesToMilli(cbReadable, &pStream->Host.Cfg.Props))); 2772 2736 2773 rc2 = RTCritSectLeave(&pThis->CritSect); 2737 2774 AssertRC(rc2); … … 2790 2827 AssertRC(rc2); 2791 2828 2792 /* If the connector is ready to operate, also make sure to ask the backend. */2793 2829 PDMAUDIOSTREAMSTS stsStream = pStream->fStatus; 2794 if (DrvAudioHlpStreamStatusIsReady(stsStream))2795 stsStream = pThis->pHostDrvAudio->pfnStreamGetStatus(pThis->pHostDrvAudio, pStream->pvBackend);2796 2830 2797 2831 #ifdef LOG_ENABLED
Note:
See TracChangeset
for help on using the changeset viewer.