Changeset 88253 in vbox for trunk/src/VBox/Main
- Timestamp:
- Mar 22, 2021 6:14:09 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143453
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleVRDPServer.h
r82968 r88253 136 136 void SendUpdateBitmap (unsigned uScreenId, uint32_t x, uint32_t y, uint32_t w, uint32_t h) const; 137 137 138 void SendAudioSamples (void *pvSamples, uint32_t cSamples, VRDEAUDIOFORMAT format) const;138 void SendAudioSamples (void const *pvSamples, uint32_t cSamples, VRDEAUDIOFORMAT format) const; 139 139 void SendAudioVolume (uint16_t left, uint16_t right) const; 140 140 void SendUSBRequest (uint32_t u32ClientId, void *pvParms, uint32_t cbParms) const; -
trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp
r82968 r88253 3730 3730 } 3731 3731 3732 void ConsoleVRDPServer::SendAudioSamples(void *pvSamples, uint32_t cSamples, VRDEAUDIOFORMAT format) const3732 void ConsoleVRDPServer::SendAudioSamples(void const *pvSamples, uint32_t cSamples, VRDEAUDIOFORMAT format) const 3733 3733 { 3734 3734 if (mpEntryPoints && mhServer) -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r88028 r88253 106 106 pCfgAcq->enmLayout = PDMAUDIOSTREAMLAYOUT_RAW; 107 107 pCfgAcq->Backend.cFramesPeriod = cFramesVrdpServer; 108 pCfgAcq->Backend.cFramesBufferSize = pCfgAcq->Backend.cFramesPeriod * 2; /* Use "double buffering". */ 109 pCfgAcq->Backend.cFramesPreBuffering = pCfgAcq->Backend.cFramesPeriod; 108 /** @todo r=bird: This is inconsistent with the above buffer allocation and I 109 * think also ALSA and Pulse backends way of setting cFramesBufferSize. */ 110 pCfgAcq->Backend.cFramesBufferSize = cFramesVrdpServer * 2; /* Use "double buffering". */ 111 pCfgAcq->Backend.cFramesPreBuffering = cFramesVrdpServer; 110 112 } 111 113 … … 270 272 */ 271 273 static DECLCALLBACK(int) drvAudioVrdeHA_StreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, 272 const void *pvBuf, uint32_t uBufSize, uint32_t *puWritten) 273 { 274 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 275 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 276 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 277 AssertReturn(uBufSize, VERR_INVALID_PARAMETER); 278 /* puWritten is optional. */ 279 280 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 281 PVRDESTREAM pStreamVRDE = (PVRDESTREAM)pStream; 274 const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 275 { 276 PDRVAUDIOVRDE pDrv = RT_FROM_MEMBER(pInterface, DRVAUDIOVRDE, IHostAudio); 277 AssertPtr(pDrv); 278 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 279 PVRDESTREAM pStreamVRDE = (PVRDESTREAM)pStream; 280 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 281 AssertReturn(cbBuf, VERR_INVALID_PARAMETER); 282 AssertPtrReturn(pcbWritten, VERR_INVALID_POINTER); 282 283 283 284 if (!pDrv->pConsoleVRDPServer) 284 285 return VERR_NOT_AVAILABLE; 285 286 286 /* Note: We get the number of *frames* in uBufSize 287 * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout) on stream creation. */ 288 uint32_t cFramesLive = uBufSize; 289 287 /* Prepate the format. */ 290 288 PPDMAUDIOPCMPROPS pProps = &pStreamVRDE->pCfg->Props; 291 292 VRDEAUDIOFORMAT format = VRDE_AUDIO_FMT_MAKE(pProps->uHz, 293 pProps->cChannels, 294 pProps->cbSample * 8 /* Bit */, 295 pProps->fSigned); 296 297 /* Use the internal counter to track if we (still) can write to the VRDP server 298 * or if we need to wait another round (time slot). */ 299 uint32_t cFramesToWrite = cFramesLive; 300 301 Log3Func(("cFramesLive=%RU32, cFramesToWrite=%RU32\n", cFramesLive, cFramesToWrite)); 302 303 /* Don't play more than available. */ 304 if (cFramesToWrite > cFramesLive) 305 cFramesToWrite = cFramesLive; 306 307 int rc = VINF_SUCCESS; 308 309 PPDMAUDIOFRAME paSampleBuf = (PPDMAUDIOFRAME)pvBuf; 310 AssertPtr(paSampleBuf); 289 VRDEAUDIOFORMAT const VrdpFormat = VRDE_AUDIO_FMT_MAKE(pProps->uHz, 290 pProps->cChannels, 291 pProps->cbSample * 8 /* Bit */, 292 pProps->fSigned); 293 294 /* We specified PDMAUDIOSTREAMLAYOUT_RAW (== S64), so 295 convert the buffer pointe and size accordingly: */ 296 PCPDMAUDIOFRAME paSampleBuf = (PCPDMAUDIOFRAME)pvBuf; 297 uint32_t const cFramesToWrite = cbBuf / sizeof(paSampleBuf[0]); 298 Assert(cFramesToWrite * sizeof(paSampleBuf[0]) == cbBuf); 299 300 /** @todo r=bird: there was some incoherent mumbling about "using the 301 * internal counter to track if we (still) can write to the VRDP 302 * server or if need to wait anothe round (time slot)". However it 303 * wasn't accessing any internal counter nor doing anything else 304 * sensible, so I've removed it. */ 311 305 312 306 /* 313 307 * Call the VRDP server with the data. 314 308 */ 315 uint32_t cfWritten = 0; 316 while (cFramesToWrite) 317 { 318 uint32_t cfChunk = cFramesToWrite; /** @todo For now write all at once. */ 319 320 if (!cfChunk) /* Nothing to send. Bail out. */ 321 break; 322 323 /* Note: The VRDP server expects int64_t samples per channel, regardless of the actual 324 * sample bits (e.g 8 or 16 bits). */ 325 pDrv->pConsoleVRDPServer->SendAudioSamples(paSampleBuf + cfWritten, cfChunk /* Frames */, format); 326 327 cfWritten += cfChunk; 328 Assert(cfWritten <= cFramesLive); 329 330 Assert(cFramesToWrite >= cfChunk); 331 cFramesToWrite -= cfChunk; 332 } 333 334 if (RT_SUCCESS(rc)) 335 { 336 /* Return frames instead of bytes here 337 * (since we specified PDMAUDIOSTREAMLAYOUT_RAW as the audio data layout). */ 338 if (puWritten) 339 *puWritten = cfWritten; 340 } 341 342 return rc; 309 uint32_t cFramesWritten = 0; 310 while (cFramesWritten < cFramesToWrite) 311 { 312 uint32_t const cFramesChunk = cFramesToWrite - cFramesWritten; /** @todo For now write all at once. */ 313 314 /* Note: The VRDP server expects int64_t samples per channel, regardless 315 of the actual sample bits (e.g 8 or 16 bits). */ 316 pDrv->pConsoleVRDPServer->SendAudioSamples(&paSampleBuf[cFramesWritten], cFramesChunk /* Frames */, VrdpFormat); 317 318 cFramesWritten += cFramesChunk; 319 } 320 321 Log3Func(("cFramesWritten=%RU32\n", cFramesWritten)); 322 if (pcbWritten) 323 *pcbWritten = cFramesWritten * sizeof(PDMAUDIOFRAME); 324 return VINF_SUCCESS; 343 325 } 344 326
Note:
See TracChangeset
for help on using the changeset viewer.