Changeset 82254 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Nov 27, 2019 10:09:17 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 135072
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/DrvAudioRec.cpp
r82252 r82254 554 554 555 555 /* Every Opus frame marks a period for now. Optimize this later. */ 556 pCfgAcq->Backend.c fPeriod = DrvAudioHlpMilliToFrames(pSink->Codec.Opus.msFrame, &pCfgAcq->Props);557 pCfgAcq->Backend.c fBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props); /** @todo Make this configurable. */558 pCfgAcq->Backend.c fPreBuf = pCfgAcq->Backend.cfPeriod * 2;556 pCfgAcq->Backend.cFramesPeriod = DrvAudioHlpMilliToFrames(pSink->Codec.Opus.msFrame, &pCfgAcq->Props); 557 pCfgAcq->Backend.cFramesBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props); /** @todo Make this configurable. */ 558 pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesPeriod * 2; 559 559 } 560 560 } … … 675 675 */ 676 676 static DECLCALLBACK(int) drvAudioVideoRecStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 677 void *pvBuf, uint32_t cxBuf, uint32_t *pcxRead)678 { 679 RT_NOREF(pInterface, pStream, pvBuf, cxBuf);680 681 if (p cxRead)682 *p cxRead = 0;677 void *pvBuf, uint32_t uBufSize, uint32_t *puRead) 678 { 679 RT_NOREF(pInterface, pStream, pvBuf, uBufSize); 680 681 if (puRead) 682 *puRead = 0; 683 683 684 684 return VINF_SUCCESS; … … 690 690 */ 691 691 static DECLCALLBACK(int) drvAudioVideoRecStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 692 const void *pvBuf, uint32_t cxBuf, uint32_t *pcxWritten)692 const void *pvBuf, uint32_t uBufSize, uint32_t *puWritten) 693 693 { 694 694 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 695 695 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 696 696 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 697 AssertReturn( cxBuf, VERR_INVALID_PARAMETER);698 /* p cxWritten is optional. */697 AssertReturn(uBufSize, VERR_INVALID_PARAMETER); 698 /* puWritten is optional. */ 699 699 700 700 PDRVAUDIORECORDING pThis = PDMIHOSTAUDIO_2_DRVAUDIORECORDING(pInterface); … … 720 720 size_t cbCircBuf; 721 721 722 uint32_t cbToWrite = cxBuf;722 uint32_t cbToWrite = uBufSize; 723 723 724 724 /* … … 858 858 } 859 859 860 if (p cxWritten)861 *p cxWritten = cbWrittenTotal;860 if (puWritten) 861 *puWritten = cbWrittenTotal; 862 862 #else 863 863 /* Report back all data as being processed. */ 864 if (p cxWritten)865 *p cxWritten = cxBuf;864 if (puWritten) 865 *puWritten = uBufSize; 866 866 867 867 rc = VERR_NOT_SUPPORTED; -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r82252 r82254 93 93 94 94 /* According to the VRDP docs, the VRDP server stores audio in 200ms chunks. */ 95 const uint32_t c fVRDPServer = DrvAudioHlpMilliToFrames(200 /* ms */, &pCfgAcq->Props);96 97 int rc = RTCircBufCreate(&pStreamVRDE->In.pCircBuf, DrvAudioHlpFramesToBytes(c fVRDPServer, &pCfgAcq->Props));95 const uint32_t cFramesVrdpServer = DrvAudioHlpMilliToFrames(200 /* ms */, &pCfgAcq->Props); 96 97 int rc = RTCircBufCreate(&pStreamVRDE->In.pCircBuf, DrvAudioHlpFramesToBytes(cFramesVrdpServer, &pCfgAcq->Props)); 98 98 if (RT_SUCCESS(rc)) 99 99 { … … 105 105 * the data without any layout modification needed. 106 106 */ 107 pCfgAcq->enmLayout = PDMAUDIOSTREAMLAYOUT_RAW; 108 109 pCfgAcq->Backend.cfPeriod = cfVRDPServer; 110 pCfgAcq->Backend.cfBufferSize = pCfgAcq->Backend.cfPeriod * 2; /* Use "double buffering". */ 111 pCfgAcq->Backend.cfPreBuf = pCfgAcq->Backend.cfPeriod; 107 pCfgAcq->enmLayout = PDMAUDIOSTREAMLAYOUT_RAW; 108 pCfgAcq->Backend.cFramesPeriod = cFramesVrdpServer; 109 pCfgAcq->Backend.cFramesBufferSize = pCfgAcq->Backend.cFramesPeriod * 2; /* Use "double buffering". */ 110 pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesPeriod; 112 111 } 113 112 … … 138 137 139 138 /* According to the VRDP docs, the VRDP server stores audio in 200ms chunks. */ 140 pCfgAcq->Backend.c fPeriod = DrvAudioHlpMilliToFrames(20 /* ms */, &pCfgAcq->Props);141 pCfgAcq->Backend.c fBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props);142 pCfgAcq->Backend.c fPreBuf = pCfgAcq->Backend.cfPeriod * 2;139 pCfgAcq->Backend.cFramesPeriod = DrvAudioHlpMilliToFrames(20 /* ms */, &pCfgAcq->Props); 140 pCfgAcq->Backend.cFramesBufferSize = DrvAudioHlpMilliToFrames(100 /* ms */, &pCfgAcq->Props); 141 pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesPeriod * 2; 143 142 } 144 143 … … 233 232 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 234 233 */ 235 static DECLCALLBACK(int) drvAudioVRDEStreamCapture(PPDMIHOSTAUDIO pInterface, 236 PPDMAUDIOBACKENDSTREAM pStream, void *pvBuf, uint32_t cxBuf, uint32_t *pcxRead)234 static DECLCALLBACK(int) drvAudioVRDEStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 235 void *pvBuf, uint32_t uBufSize, uint32_t *puRead) 237 236 { 238 237 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 239 238 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 240 239 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 241 AssertReturn( cxBuf, VERR_INVALID_PARAMETER);242 /* p cxRead is optional. */240 AssertReturn(uBufSize, VERR_INVALID_PARAMETER); 241 /* puRead is optional. */ 243 242 244 243 PVRDESTREAM pStreamVRDE = (PVRDESTREAM)pStream; … … 250 249 void *pvData; 251 250 252 RTCircBufAcquireReadBlock(pStreamVRDE->In.pCircBuf, cxBuf, &pvData, &cbData);251 RTCircBufAcquireReadBlock(pStreamVRDE->In.pCircBuf, uBufSize, &pvData, &cbData); 253 252 254 253 if (cbData) … … 258 257 } 259 258 260 if (p cxRead)261 *p cxRead = (uint32_t)cbData;259 if (puRead) 260 *puRead = (uint32_t)cbData; 262 261 263 262 return VINF_SUCCESS; … … 269 268 */ 270 269 static DECLCALLBACK(int) drvAudioVRDEStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 271 const void *pvBuf, uint32_t cxBuf, uint32_t *pcxWritten)270 const void *pvBuf, uint32_t uBufSize, uint32_t *puWritten) 272 271 { 273 272 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 274 273 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 275 274 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 276 AssertReturn( cxBuf, VERR_INVALID_PARAMETER);277 /* p cxWritten is optional. */275 AssertReturn(uBufSize, VERR_INVALID_PARAMETER); 276 /* puWritten is optional. */ 278 277 279 278 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); … … 283 282 return VERR_NOT_AVAILABLE; 284 283 285 /* Note: We get the number of *frames* in cxBuf284 /* Note: We get the number of *frames* in uBufSize 286 285 * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout) on stream creation. */ 287 uint32_t c fLive = cxBuf;288 289 PPDMAUDIOPCMPROPS pProps 286 uint32_t cFramesLive = uBufSize; 287 288 PPDMAUDIOPCMPROPS pProps = &pStreamVRDE->pCfg->Props; 290 289 291 290 VRDEAUDIOFORMAT format = VRDE_AUDIO_FMT_MAKE(pProps->uHz, … … 296 295 /* Use the internal counter to track if we (still) can write to the VRDP server 297 296 * or if we need to wait another round (time slot). */ 298 uint32_t c fToWrite = cfLive;299 300 Log3Func(("c fLive=%RU32, cfToWrite=%RU32\n", cfLive, cfToWrite));297 uint32_t cFramesToWrite = cFramesLive; 298 299 Log3Func(("cFramesLive=%RU32, cFramesToWrite=%RU32\n", cFramesLive, cFramesToWrite)); 301 300 302 301 /* Don't play more than available. */ 303 if (c fToWrite > cfLive)304 c fToWrite = cfLive;302 if (cFramesToWrite > cFramesLive) 303 cFramesToWrite = cFramesLive; 305 304 306 305 int rc = VINF_SUCCESS; … … 313 312 */ 314 313 uint32_t cfWritten = 0; 315 while (c fToWrite)316 { 317 uint32_t cfChunk = c fToWrite; /** @todo For now write all at once. */314 while (cFramesToWrite) 315 { 316 uint32_t cfChunk = cFramesToWrite; /** @todo For now write all at once. */ 318 317 319 318 if (!cfChunk) /* Nothing to send. Bail out. */ … … 325 324 326 325 cfWritten += cfChunk; 327 Assert(cfWritten <= c fLive);328 329 Assert(c fToWrite >= cfChunk);330 c fToWrite -= cfChunk;326 Assert(cfWritten <= cFramesLive); 327 328 Assert(cFramesToWrite >= cfChunk); 329 cFramesToWrite -= cfChunk; 331 330 } 332 331 … … 335 334 /* Return frames instead of bytes here 336 335 * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */ 337 if (p cxWritten)338 *p cxWritten = cfWritten;336 if (puWritten) 337 *puWritten = cfWritten; 339 338 } 340 339
Note:
See TracChangeset
for help on using the changeset viewer.