Changeset 58378 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Oct 22, 2015 12:46:32 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103601
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r58344 r58378 310 310 } 311 311 312 void drvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf) 313 { 314 AssertPtrReturnVoid(pPCMInfo); 312 /** 313 * Clears a sample buffer by the given amount of audio samples. 314 * 315 * @return IPRT status code. 316 * @param pPCMProps PCM properties to use for the buffer to clear. 317 * @param pvBuf Buffer to clear. 318 * @param cbBuf Size (in bytes) of the buffer. 319 * @param cSamples Number of audio samples to clear in the buffer. 320 */ 321 void DrvAudioClearBuf(PPDMPCMPROPS pPCMProps, void *pvBuf, size_t cbBuf, uint32_t cSamples) 322 { 323 AssertPtrReturnVoid(pPCMProps); 315 324 AssertPtrReturnVoid(pvBuf); 316 325 317 if (!cbBuf )326 if (!cbBuf || !cSamples) 318 327 return; 319 328 320 Log2Func(("pPCMInfo=%p, pvBuf=%p, c bBuf=%zu, fSigned=%RTbool, cBits=%RU8, cShift=%RU8\n",321 pPCM Info, pvBuf, cbBuf, pPCMInfo->fSigned, pPCMInfo->cBits, pPCMInfo->cShift));322 323 if (pPCM Info->fSigned)324 { 325 memset(pvBuf, 0, c bBuf << pPCMInfo->cShift);329 Log2Func(("pPCMInfo=%p, pvBuf=%p, cSamples=%RU32, fSigned=%RTbool, cBits=%RU8, cShift=%RU8\n", 330 pPCMProps, pvBuf, cSamples, pPCMProps->fSigned, pPCMProps->cBits, pPCMProps->cShift)); 331 332 if (pPCMProps->fSigned) 333 { 334 memset(pvBuf, 0, cSamples << pPCMProps->cShift); 326 335 } 327 336 else 328 337 { 329 switch (pPCMInfo->cBits) 330 { 331 332 case 8: 333 memset(pvBuf, 0x80, cbBuf << pPCMInfo->cShift); 334 break; 335 336 case 16: 337 { 338 uint16_t *p = (uint16_t *)pvBuf; 339 int shift = pPCMInfo->cChannels - 1; 340 short s = INT16_MAX; 341 342 if (pPCMInfo->fSwapEndian) 343 s = RT_BSWAP_U16(s); 344 345 for (unsigned i = 0; i < cbBuf << shift; i++) 346 p[i] = s; 347 348 break; 349 } 350 351 case 32: 352 { 353 uint32_t *p = (uint32_t *)pvBuf; 354 int shift = pPCMInfo->cChannels - 1; 355 int32_t s = INT32_MAX; 356 357 if (pPCMInfo->fSwapEndian) 358 s = RT_BSWAP_U32(s); 359 360 for (unsigned i = 0; i < cbBuf << shift; i++) 361 p[i] = s; 362 363 break; 364 } 365 366 default: 367 AssertMsgFailed(("Invalid bits: %RU8\n", pPCMInfo->cBits)); 368 break; 338 switch (pPCMProps->cBits) 339 { 340 case 8: 341 { 342 memset(pvBuf, 0x80, cSamples << pPCMProps->cShift); 343 break; 344 } 345 346 case 16: 347 { 348 uint16_t *p = (uint16_t *)pvBuf; 349 int shift = pPCMProps->cChannels - 1; 350 short s = INT16_MAX; 351 352 if (pPCMProps->fSwapEndian) 353 s = RT_BSWAP_U16(s); 354 355 for (unsigned i = 0; i < cSamples << shift; i++) 356 p[i] = s; 357 358 break; 359 } 360 361 case 32: 362 { 363 uint32_t *p = (uint32_t *)pvBuf; 364 int shift = pPCMProps->cChannels - 1; 365 int32_t s = INT32_MAX; 366 367 if (pPCMProps->fSwapEndian) 368 s = RT_BSWAP_U32(s); 369 370 for (unsigned i = 0; i < cSamples << shift; i++) 371 p[i] = s; 372 373 break; 374 } 375 376 default: 377 { 378 AssertMsgFailed(("Invalid bits: %RU8\n", pPCMProps->cBits)); 379 break; 380 } 369 381 } 370 382 } … … 639 651 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 640 652 641 int rc = drvAudioStreamCfgToProps(pCfg, &pGstStrmOut->Props);653 int rc = DrvAudioStreamCfgToProps(pCfg, &pGstStrmOut->Props); 642 654 if (RT_SUCCESS(rc)) 643 655 { … … 891 903 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 892 904 893 int rc = drvAudioStreamCfgToProps(pCfg, &pGstStrmIn->Props);905 int rc = DrvAudioStreamCfgToProps(pCfg, &pGstStrmIn->Props); 894 906 if (RT_SUCCESS(rc)) 895 907 { … … 1192 1204 while ((pHstStrmOut = drvAudioHstFindAnyEnabledOut(pThis, pHstStrmOut))) 1193 1205 { 1194 cSamplesLive = drvAudioHstOutSamplesLive(pHstStrmOut);1206 cSamplesLive = AudioMixBufAvail(&pHstStrmOut->MixBuf); 1195 1207 1196 1208 /* Has this stream marked as disabled but there still were guest streams relying -
trunk/src/VBox/Devices/Audio/DrvAudio.h
r57451 r58378 110 110 111 111 bool drvAudioPCMPropsAreEqual(PPDMPCMPROPS info, PPDMAUDIOSTREAMCFG pCfg); 112 int drvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps);113 112 void drvAudioStreamCfgPrint(PPDMAUDIOSTREAMCFG pCfg); 114 113 … … 144 143 145 144 /* Common functions between DrvAudio and backends (host audio drivers). */ 146 int drvAudioAttachCapture(PDRVAUDIO pDrvAudio, PPDMAUDIOHSTSTRMOUT pHstStrmOut); 147 void drvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf); 148 void drvAudioDetachCapture(PPDMAUDIOHSTSTRMOUT pHstStrmOut); 149 uint32_t drvAudioHstOutSamplesLive(PPDMAUDIOHSTSTRMOUT pHstStrmOut); 150 145 void DrvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf, uint32_t cSamples); 146 int DrvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps); 151 147 152 148 typedef struct fixed_settings -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r57451 r58378 309 309 } 310 310 311 int drvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps) 312 { 311 /** 312 * Converts an audio stream configuration to matching PCM properties. 313 * 314 * @return IPRT status code. 315 * @param pCfg Audio stream configuration to convert. 316 * @param pProps PCM properties to save result to. 317 */ 318 int DrvAudioStreamCfgToProps(PPDMAUDIOSTREAMCFG pCfg, PPDMPCMPROPS pProps) 319 { 320 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 321 AssertPtrReturn(pProps, VERR_INVALID_POINTER); 322 313 323 int rc = VINF_SUCCESS; 314 324 … … 407 417 } 408 418 } 409 410 /**411 * Finds the number of live samples for a specific output stream.412 *413 * @return uint32_t Minimum number of live host output samples processed414 * by all connected guest output streams.415 * @param pHstStrmOut Host output stream to search in.416 */417 uint32_t drvAudioHstOutSamplesLive(PPDMAUDIOHSTSTRMOUT pHstStrmOut)418 {419 AssertPtrReturn(pHstStrmOut, 0);420 421 uint32_t cSamplesLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);422 423 LogFlowFunc(("%s: cStreamsLive=%RU32, cSamplesLive=%RU32\n", pHstStrmOut->MixBuf.pszName, cSamplesLive));424 return cSamplesLive;425 }426 -
trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp
r57451 r58378 946 946 (uint32_t)cAvail), /* cAvail is always >= 0 */ 947 947 AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, 948 drvAudioHstOutSamplesLive(pHstStrmOut)));948 AudioMixBufAvail(&pHstStrmOut->MixBuf))); 949 949 LogFlowFunc(("cbToRead=%zu, cbAvail=%zu\n", 950 950 cbToRead, AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, cAvail))); … … 1118 1118 streamCfg.enmEndianness = enmEnd; 1119 1119 1120 rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);1120 rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props); 1121 1121 if (RT_FAILURE(rc)) 1122 1122 break; … … 1189 1189 streamCfg.enmEndianness = enmEnd; 1190 1190 1191 rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);1191 rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props); 1192 1192 if (RT_FAILURE(rc)) 1193 1193 break; -
trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
r57571 r58378 1481 1481 /* Not much else to do here. */ 1482 1482 1483 uint32_t cLive = drvAudioHstOutSamplesLive(pHstStrmOut);1483 uint32_t cLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);; 1484 1484 if (!cLive) /* Not samples to play? Bail out. */ 1485 1485 { … … 1508 1508 RTCircBufReleaseWriteBlock(pStreamOut->pBuf, cbCopy); 1509 1509 break; 1510 } 1510 } 1511 1511 1512 1512 Assert(cbCopy <= cbToRead); … … 1879 1879 1880 1880 /* Initialize the hardware info section with the audio settings */ 1881 int rc = drvAudioStreamCfgToProps(pCfg, &pStreamIn->streamIn.Props);1881 int rc = DrvAudioStreamCfgToProps(pCfg, &pStreamIn->streamIn.Props); 1882 1882 if (RT_SUCCESS(rc)) 1883 1883 { … … 1938 1938 1939 1939 /* Initialize the hardware info section with the audio settings */ 1940 drvAudioStreamCfgToProps(pCfg, &pStreamOut->streamOut.Props);1940 DrvAudioStreamCfgToProps(pCfg, &pStreamOut->streamOut.Props); 1941 1941 1942 1942 #if 0 -
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r58075 r58378 514 514 AssertPtrReturnVoid(pDSoundStrmOut); 515 515 516 PPDMAUDIOHSTSTRMOUT pStrmOut = &pDSoundStrmOut->strmOut; 517 516 518 LPVOID pv1, pv2; 517 519 DWORD cb1, cb2; 518 520 HRESULT hr = directSoundPlayLock(pDSoundStrmOut->pDSB, &pDSoundStrmOut->strmOut.Props, 519 0 , pDSoundStrmOut->csPlaybackBufferSize << pDSoundStrmOut->strmOut.Props.cShift,521 0 /* dwOffset */, AUDIOMIXBUF_S2B(&pStrmOut->MixBuf, pDSoundStrmOut->csPlaybackBufferSize), 520 522 &pv1, &pv2, &cb1, &cb2, DSBLOCK_ENTIREBUFFER); 521 523 if (SUCCEEDED(hr)) 522 524 { 523 int len1 = cb1 >> pDSoundStrmOut->strmOut.Props.cShift;524 int len2 = cb2 >> pDSoundStrmOut->strmOut.Props.cShift;525 DWORD len1 = AUDIOMIXBUF_B2S(&pStrmOut->MixBuf, cb1); 526 DWORD len2 = AUDIOMIXBUF_B2S(&pStrmOut->MixBuf, cb2); 525 527 526 528 if (pv1 && len1) 527 drvAudioClearBuf(&pDSoundStrmOut->strmOut.Props, pv1, len1);529 DrvAudioClearBuf(&pDSoundStrmOut->strmOut.Props, pv1, cb1, len1); 528 530 529 531 if (pv2 && len2) 530 drvAudioClearBuf(&pDSoundStrmOut->strmOut.Props, pv2, len2);532 DrvAudioClearBuf(&pDSoundStrmOut->strmOut.Props, pv2, cb2, len2); 531 533 532 534 directSoundPlayUnlock(pDSoundStrmOut->pDSB, pv1, pv2, cb1, cb2); … … 534 536 } 535 537 536 static HRESULT directSoundPlayGetStatus(LPDIRECTSOUNDBUFFER8 pDSB, DWORD *p Status)538 static HRESULT directSoundPlayGetStatus(LPDIRECTSOUNDBUFFER8 pDSB, DWORD *pdwStatus) 537 539 { 538 540 AssertPtrReturn(pDSB, E_POINTER); 539 /* p Status is optional. */541 /* pdwStatus is optional. */ 540 542 541 543 DWORD dwStatus = 0; … … 553 555 if (SUCCEEDED(hr)) 554 556 { 555 if (p Status)556 *p Status = dwStatus;557 if (pdwStatus) 558 *pdwStatus = dwStatus; 557 559 } 558 560 else … … 1024 1026 pDSoundStrmOut->streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS; 1025 1027 1026 int rc = drvAudioStreamCfgToProps(&pDSoundStrmOut->streamCfg, &pDSoundStrmOut->strmOut.Props);1028 int rc = DrvAudioStreamCfgToProps(&pDSoundStrmOut->streamCfg, &pDSoundStrmOut->strmOut.Props); 1027 1029 if (RT_SUCCESS(rc)) 1028 1030 { … … 1120 1122 1121 1123 int cShift = pHstStrmOut->Props.cShift; 1122 DWORD cbBuffer = pDSoundStrmOut->csPlaybackBufferSize << cShift;1124 DWORD cbBuffer = AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, pDSoundStrmOut->csPlaybackBufferSize); 1123 1125 1124 1126 /* Get the current play position which is used for calculating the free space in the buffer. */ … … 1142 1144 1143 1145 DWORD cbFree = cbBuffer - dsoundRingDistance(pDSoundStrmOut->cbPlayWritePos, cbPlayPos, cbBuffer); 1144 1145 /* Check for full buffer, do not allow the cbPlayWritePos to catch cbPlayPos during playback,1146 /* 1147 * Check for full buffer, do not allow the cbPlayWritePos to catch cbPlayPos during playback, 1146 1148 * i.e. always leave a free space for 1 audio sample. 1147 1149 */ 1148 if (cbFree <= (1U << cShift)) 1149 break; 1150 cbFree -= (1U << cShift); 1151 1152 uint32_t csLive = drvAudioHstOutSamplesLive(pHstStrmOut); 1153 uint32_t cbLive = csLive << cShift; 1150 const DWORD cbSample = AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, 1); 1151 if (cbFree <= cbSample) 1152 break; 1153 cbFree -= cbSample; 1154 1155 uint32_t csLive = AudioMixBufAvail(&pHstStrmOut->MixBuf); 1156 uint32_t cbLive = AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, csLive); 1154 1157 1155 1158 /* Do not write more than available space in the DirectSound playback buffer. */ … … 1171 1174 break; 1172 1175 1173 DWORD len1 = cb1 >> cShift;1174 DWORD len2 = cb2 >> cShift;1176 DWORD len1 = AUDIOMIXBUF_B2S(&pHstStrmOut->MixBuf, cb1); 1177 DWORD len2 = AUDIOMIXBUF_B2S(&pHstStrmOut->MixBuf, cb2); 1175 1178 1176 1179 uint32_t cRead = 0; … … 1194 1197 directSoundPlayUnlock(pDSB, pv1, pv2, cb1, cb2); 1195 1198 1196 pDSoundStrmOut->cbPlayWritePos = (pDSoundStrmOut->cbPlayWritePos + (cReadTotal << cShift)) % cbBuffer; 1199 pDSoundStrmOut->cbPlayWritePos = 1200 (pDSoundStrmOut->cbPlayWritePos + AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, cReadTotal)) % cbBuffer; 1197 1201 1198 1202 DSLOGF(("DSound: %RU32 (%RU32 samples) out of %RU32%s, buffer write pos %ld, rc=%Rrc\n", … … 1262 1266 1263 1267 /** @todo caller should already init Props? */ 1264 int rc = drvAudioStreamCfgToProps(&pDSoundStrmIn->streamCfg, &pHstStrmIn->Props);1268 int rc = DrvAudioStreamCfgToProps(&pDSoundStrmIn->streamCfg, &pHstStrmIn->Props); 1265 1269 if (RT_SUCCESS(rc)) 1266 1270 { … … 1405 1409 DWORD cb1, cb2; 1406 1410 hr = directSoundCaptureLock(pDSCB, &pHstStrmIn->Props, 1407 pDSoundStrmIn->csCaptureReadPos << pHstStrmIn->Props.cShift,1408 csCaptured << pHstStrmIn->Props.cShift,1411 AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf, pDSoundStrmIn->csCaptureReadPos), /* dwOffset */ 1412 AUDIOMIXBUF_S2B(&pHstStrmIn->MixBuf, csCaptured), /* dwBytes */ 1409 1413 &pv1, &pv2, &cb1, &cb2, 1410 1414 0 /* dwFlags */); … … 1416 1420 } 1417 1421 1418 DWORD len1 = cb1 >> pHstStrmIn->Props.cShift;1419 DWORD len2 = cb2 >> pHstStrmIn->Props.cShift;1422 DWORD len1 = AUDIOMIXBUF_B2S(&pHstStrmIn->MixBuf, cb1); 1423 DWORD len2 = AUDIOMIXBUF_B2S(&pHstStrmIn->MixBuf, cb2); 1420 1424 1421 1425 uint32_t csWrittenTotal = 0; -
trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
r58372 r58378 112 112 113 113 /* Just adopt the wanted stream configuration. */ 114 int rc = drvAudioStreamCfgToProps(pCfg, &pHstStrmIn->Props);114 int rc = DrvAudioStreamCfgToProps(pCfg, &pHstStrmIn->Props); 115 115 if (RT_SUCCESS(rc)) 116 116 { … … 129 129 130 130 /* Just adopt the wanted stream configuration. */ 131 int rc = drvAudioStreamCfgToProps(pCfg, &pHstStrmOut->Props);131 int rc = DrvAudioStreamCfgToProps(pCfg, &pHstStrmOut->Props); 132 132 if (RT_SUCCESS(rc)) 133 133 { … … 164 164 165 165 /* Consume as many samples as would be played at the current frequency since last call. */ 166 uint32_t csLive = drvAudioHstOutSamplesLive(pHstStrmOut);166 uint32_t csLive = AudioMixBufAvail(&pHstStrmOut->MixBuf);; 167 167 uint64_t u64TicksNow = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns); 168 168 uint64_t u64TicksElapsed = u64TicksNow - pNullStrmOut->u64TicksLast; … … 185 185 186 186 uint32_t csRead = 0; 187 AudioMixBufReadCirc(&pHstStrmOut->MixBuf, pNullStrmOut->pu8PlayBuffer, cSamplesPlayed << pHstStrmOut->Props.cShift, &csRead); 187 AudioMixBufReadCirc(&pHstStrmOut->MixBuf, pNullStrmOut->pu8PlayBuffer, 188 AUDIOMIXBUF_S2B(&pHstStrmOut->MixBuf, cSamplesPlayed), &csRead); 188 189 AudioMixBufFinish(&pHstStrmOut->MixBuf, csRead); 189 190 -
trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp
r57451 r58378 66 66 int cFragments; 67 67 int cbFragmentSize; 68 void *pvBuf; 69 size_t cbBuf; 68 /** Own PCM buffer. */ 69 void *pvPCMBuf; 70 /** Size (in bytes) of own PCM buffer. */ 71 size_t cbPCMBuf; 70 72 int old_optr; 71 73 } OSSAUDIOSTREAMIN, *POSSAUDIOSTREAMIN; … … 79 81 int cbFragmentSize; 80 82 #ifndef RT_OS_L4 83 /** Whether we use a memory mapped file instead of our 84 * own allocated PCM buffer below. */ 81 85 bool fMemMapped; 82 86 #endif 87 /** Own PCM buffer in case memory mapping is unavailable. */ 83 88 void *pvPCMBuf; 89 /** Size (in bytes) of own PCM buffer. */ 90 size_t cbPCMBuf; 84 91 int old_optr; 85 92 } OSSAUDIOSTREAMOUT, *POSSAUDIOSTREAMOUT; … … 353 360 case PDMAUDIOSTREAMCMD_ENABLE: 354 361 { 355 drvAudioClearBuf(&pHstStrmOut->Props,356 pThisStrmOut->pvPCMBuf, AudioMixBufSize(&pHstStrmOut->MixBuf));362 DrvAudioClearBuf(&pHstStrmOut->Props, 363 pThisStrmOut->pvPCMBuf, pThisStrmOut->cbPCMBuf, AudioMixBufSize(&pHstStrmOut->MixBuf)); 357 364 358 365 mask = PCM_ENABLE_OUTPUT; … … 406 413 407 414 int rc = VINF_SUCCESS; 408 size_t cbToRead = RT_MIN(pThisStrmIn->cb Buf,415 size_t cbToRead = RT_MIN(pThisStrmIn->cbPCMBuf, 409 416 AudioMixBufFreeBytes(&pHstStrmIn->MixBuf)); 410 417 … … 418 425 while (cbToRead) 419 426 { 420 cbTemp = RT_MIN(cbToRead, pThisStrmIn->cb Buf);427 cbTemp = RT_MIN(cbToRead, pThisStrmIn->cbPCMBuf); 421 428 AssertBreakStmt(cbTemp, rc = VERR_NO_DATA); 422 cbRead = read(pThisStrmIn->hFile, (uint8_t *)pThisStrmIn->pv Buf + offWrite, cbTemp);429 cbRead = read(pThisStrmIn->hFile, (uint8_t *)pThisStrmIn->pvPCMBuf + offWrite, cbTemp); 423 430 424 431 LogFlowFunc(("cbRead=%zi, cbTemp=%RU32, cbToRead=%zu\n", … … 455 462 uint32_t cWritten; 456 463 rc = AudioMixBufWriteCirc(&pHstStrmIn->MixBuf, 457 pThisStrmIn->pv Buf, cbRead,464 pThisStrmIn->pvPCMBuf, cbRead, 458 465 &cWritten); 459 466 if (RT_FAILURE(rc)) … … 501 508 LogFlowFuncEnter(); 502 509 503 if (pThisStrmIn->pvBuf) 504 { 505 RTMemFree(pThisStrmIn->pvBuf); 506 pThisStrmIn->pvBuf = NULL; 510 if (pThisStrmIn->pvPCMBuf) 511 { 512 Assert(pThisStrmIn->cbPCMBuf); 513 514 RTMemFree(pThisStrmIn->pvPCMBuf); 515 pThisStrmIn->pvPCMBuf = NULL; 507 516 } 517 518 pThisStrmIn->cbPCMBuf = 0; 508 519 509 520 return VINF_SUCCESS; … … 524 535 if (pThisStrmOut->pvPCMBuf) 525 536 { 537 Assert(pThisStrmOut->cbPCMBuf); 538 526 539 RTMemFree(pThisStrmOut->pvPCMBuf); 527 540 pThisStrmOut->pvPCMBuf = NULL; 528 541 } 542 543 pThisStrmOut->cbPCMBuf = 0; 529 544 } 530 545 #endif … … 587 602 streamCfg.enmEndianness = obtStream.enmENDIANNESS; 588 603 589 rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);604 rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props); 590 605 if (RT_SUCCESS(rc)) 591 606 { … … 599 614 if (RT_SUCCESS(rc)) 600 615 { 601 size_t cb Buf = cSamples *(1 << pHstStrmIn->Props.cShift);602 pThisStrmIn->pvBuf = RTMemAlloc(cbBuf);603 if (!pThisStrmIn->pvBuf)604 {605 LogRel(("OSS: Failed allocating ADC buffer with %RU32 samples, each %d bytes\n",606 cSamples, 1 << pHstStrmIn->Props.cShift));616 size_t cbSample = (1 << pHstStrmIn->Props.cShift); 617 size_t cbBuf = cSamples * cbSample; 618 pThisStrmIn->pvPCMBuf = RTMemAlloc(cbBuf); 619 if (!pThisStrmIn->pvPCMBuf) 620 { 621 LogRel(("OSS: Failed allocating ADC buffer with %RU32 samples (%zu bytes per sample)\n", cSamples, cbSample)); 607 622 rc = VERR_NO_MEMORY; 608 623 } 609 624 610 pThisStrmIn->cb Buf = cbBuf;625 pThisStrmIn->cbPCMBuf = cbBuf; 611 626 612 627 if (pcSamples) … … 664 679 streamCfg.enmEndianness = obtStream.enmENDIANNESS; 665 680 666 rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);681 rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props); 667 682 if (RT_SUCCESS(rc)) 668 683 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) … … 714 729 cSamples << pHstStrmOut->Props.cShift); 715 730 if (rc2) 716 LogRel(("OSS: Failed to unmap DAC output file: %s\n", 717 strerror(errno))); 718 731 LogRel(("OSS: Failed to unmap DAC output file: %s\n", strerror(errno))); 719 732 break; 720 733 } … … 728 741 { 729 742 #endif 743 size_t cbSample = (1 << pHstStrmOut->Props.cShift); 744 size_t cbPCMBuf = cSamples * cbSample; 745 730 746 LogFlowFunc(("cSamples=%RU32\n", cSamples)); 731 pThisStrmOut->pvPCMBuf = RTMemAlloc(cSamples * (1 << pHstStrmOut->Props.cShift)); 747 748 pThisStrmOut->pvPCMBuf = RTMemAlloc(cbPCMBuf); 732 749 if (!pThisStrmOut->pvPCMBuf) 733 750 { 734 LogRel(("OSS: Failed allocating DAC buffer with %RU32 samples, each %d bytes\n", 735 cSamples, 1 << pHstStrmOut->Props.cShift)); 751 LogRel(("OSS: Failed allocating DAC buffer with %RU32 samples (%zu bytes per sample)\n", cSamples, cbSample)); 736 752 rc = VERR_NO_MEMORY; 737 753 break; 738 754 } 755 756 pThisStrmOut->cbPCMBuf = cbPCMBuf; 739 757 #ifndef RT_OS_L4 740 758 } … … 776 794 size_t cbBuf = AudioMixBufSizeBytes(&pHstStrmOut->MixBuf); 777 795 778 uint32_t cLive = drvAudioHstOutSamplesLive(pHstStrmOut);796 uint32_t cLive = AudioMixBufAvail(&pHstStrmOut->MixBuf); 779 797 uint32_t cToRead; 780 798 … … 858 876 if (cbWritten == -1) 859 877 { 860 LogRel(("OSS: Failed writing output data %s\n", strerror(errno)));878 LogRel(("OSS: Failed writing output data: %s\n", strerror(errno))); 861 879 rc = RTErrConvertFromErrno(errno); 862 880 break; -
trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
r57451 r58378 599 599 streamCfg.cChannels = pThisStrmOut->SampleSpec.channels; 600 600 601 rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props);601 rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmOut->Props); 602 602 if (RT_SUCCESS(rc)) 603 603 { … … 682 682 streamCfg.cChannels = pThisStrmIn->SampleSpec.channels; 683 683 684 rc = drvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props);684 rc = DrvAudioStreamCfgToProps(&streamCfg, &pHstStrmIn->Props); 685 685 if (RT_SUCCESS(rc)) 686 686 { … … 833 833 uint32_t cbReadTotal = 0; 834 834 835 uint32_t cLive = drvAudioHstOutSamplesLive(pHstStrmOut);835 uint32_t cLive = AudioMixBufAvail(&pHstStrmOut->MixBuf); 836 836 if (!cLive) 837 837 { -
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r57358 r58378 50 50 PDMPCMPROPS props; 51 51 52 int rc = drvAudioStreamCfgToProps(&config, &props);52 int rc = DrvAudioStreamCfgToProps(&config, &props); 53 53 AssertRC(rc); 54 54 … … 149 149 PDMPCMPROPS props; 150 150 151 int rc = drvAudioStreamCfgToProps(&cfg_p, &props);151 int rc = DrvAudioStreamCfgToProps(&cfg_p, &props); 152 152 AssertRC(rc); 153 153 … … 163 163 }; 164 164 165 rc = drvAudioStreamCfgToProps(&cfg_c1, &props);165 rc = DrvAudioStreamCfgToProps(&cfg_c1, &props); 166 166 AssertRC(rc); 167 167 … … 178 178 }; 179 179 180 rc = drvAudioStreamCfgToProps(&cfg_c2, &props);180 rc = DrvAudioStreamCfgToProps(&cfg_c2, &props); 181 181 AssertRC(rc); 182 182 … … 260 260 }; 261 261 262 int rc = drvAudioStreamCfgToProps(&cfg_p, &props);262 int rc = DrvAudioStreamCfgToProps(&cfg_p, &props); 263 263 AssertRC(rc); 264 264 … … 281 281 }; 282 282 283 rc = drvAudioStreamCfgToProps(&cfg_c, &props);283 rc = DrvAudioStreamCfgToProps(&cfg_c, &props); 284 284 AssertRC(rc); 285 285 … … 364 364 }; 365 365 366 int rc = drvAudioStreamCfgToProps(&cfg_p, &props);366 int rc = DrvAudioStreamCfgToProps(&cfg_p, &props); 367 367 AssertRC(rc); 368 368 … … 378 378 }; 379 379 380 rc = drvAudioStreamCfgToProps(&cfg_c, &props);380 rc = DrvAudioStreamCfgToProps(&cfg_c, &props); 381 381 AssertRC(rc); 382 382 … … 462 462 }; 463 463 464 int rc = drvAudioStreamCfgToProps(&cfg, &props);464 int rc = DrvAudioStreamCfgToProps(&cfg, &props); 465 465 AssertRC(rc); 466 466
Note:
See TracChangeset
for help on using the changeset viewer.