- Timestamp:
- Aug 16, 2016 9:37:04 AM (8 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r63360 r63529 521 521 */ 522 522 523 /* Make the acquired host configuration the requested host configuration by default. */524 PDMAUDIOSTREAMCFG CfgAcq;525 memcpy(&CfgAcq, pCfgHost, sizeof(PDMAUDIOSTREAMCFG));526 527 uint32_t cSamples = 0; 523 /* Make the acquired host configuration the requested host configuration initially, 524 * in case the backend does not report back an acquired configuration. */ 525 PDMAUDIOSTREAMCFG CfgHostAcq; 526 memcpy(&CfgHostAcq, pCfgHost, sizeof(PDMAUDIOSTREAMCFG)); 527 528 528 int rc = pThis->pHostDrvAudio->pfnStreamCreate(pThis->pHostDrvAudio, pHstStream, 529 pCfgHost /* pCfgReq */, &Cfg Acq /* pCfgAcq */);529 pCfgHost /* pCfgReq */, &CfgHostAcq /* pCfgAcq */); 530 530 if (RT_SUCCESS(rc)) 531 531 { … … 538 538 LogFlowFunc(("[%s] Initializing stream in host backend failed with rc=%Rrc\n", pStream->szName, rc)); 539 539 540 int rc2 = DrvAudioHlpStreamCfgToProps(pCfgHost, &pHstStream->Props); 540 PDMAUDIOPCMPROPS PCMProps; 541 int rc2 = DrvAudioHlpStreamCfgToProps(&CfgHostAcq, &PCMProps); 541 542 AssertRC(rc2); 542 543 … … 544 545 AudioMixBufDestroy(&pHstStream->MixBuf); 545 546 546 if (cSamples) 547 { 548 cSamples = cSamples * 4; 549 550 LogFlowFunc(("[%s] cSamples=%RU32\n", pHstStream->szName, cSamples)); 551 552 rc2 = AudioMixBufInit(&pHstStream->MixBuf, pHstStream->szName, &pHstStream->Props, cSamples); 547 if (CfgHostAcq.cSamples) 548 { 549 LogFlowFunc(("[%s] cSamples=%RU32\n", pHstStream->szName, CfgHostAcq.cSamples * 4)); 550 551 rc2 = AudioMixBufInit(&pHstStream->MixBuf, pHstStream->szName, &PCMProps, CfgHostAcq.cSamples * 4); 553 552 AssertRC(rc2); 554 553 } … … 561 560 */ 562 561 563 rc2 = DrvAudioHlpStreamCfgToProps(pCfgGuest, &pGstStream->Props); 562 RT_ZERO(PCMProps); 563 rc2 = DrvAudioHlpStreamCfgToProps(pCfgGuest, &PCMProps); 564 564 AssertRC(rc2); 565 565 … … 567 567 AudioMixBufDestroy(&pGstStream->MixBuf); 568 568 569 if (cSamples) 570 { 571 cSamples = cSamples * 2; 572 573 LogFlowFunc(("[%s] cSamples=%RU32\n", pGstStream->szName, cSamples)); 574 575 rc2 = AudioMixBufInit(&pGstStream->MixBuf, pGstStream->szName, &pGstStream->Props, cSamples); 569 if (CfgHostAcq.cSamples) 570 { 571 LogFlowFunc(("[%s] cSamples=%RU32\n", pGstStream->szName, CfgHostAcq.cSamples * 2)); 572 573 rc2 = AudioMixBufInit(&pGstStream->MixBuf, pGstStream->szName, &PCMProps, CfgHostAcq.cSamples * 2); 576 574 AssertRC(rc2); 577 575 } … … 581 579 #endif 582 580 583 if ( cSamples)581 if (CfgHostAcq.cSamples) 584 582 { 585 583 if (pCfgGuest->enmDir == PDMAUDIODIR_IN) -
trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp
r63500 r63529 123 123 pASBD->mBytesPerFrame = pASBD->mChannelsPerFrame * (pASBD->mBitsPerChannel / 8); 124 124 pASBD->mBytesPerPacket = pASBD->mFramesPerPacket * pASBD->mBytesPerFrame; 125 } 126 127 static int coreAudioStreamCfgToASBD(PPDMAUDIOSTREAMCFG pCfg, AudioStreamBasicDescription *pASBD) 128 { 129 AssertPtrReturn(pCfg, VERR_INVALID_PARAMETER); 130 AssertPtrReturn(pASBD, VERR_INVALID_PARAMETER); 131 132 PDMAUDIOPCMPROPS Props; 133 int rc = DrvAudioHlpStreamCfgToProps(pCfg, &Props); 134 if (RT_SUCCESS(rc)) 135 coreAudioPCMPropsToASBD(&Props, pASBD); 136 137 return rc; 125 138 } 126 139 … … 1141 1154 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1142 1155 { 1143 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 1144 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1145 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 1146 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 1156 RT_NOREF(pThis); 1147 1157 1148 1158 int rc = VINF_SUCCESS; … … 1152 1162 1153 1163 OSStatus err = noErr; 1164 UInt32 uSize = 0; 1165 1154 1166 AudioDeviceID deviceID = pStreamIn->deviceID; 1155 1156 UInt32 uSize = 0;1157 1167 if (deviceID == kAudioDeviceUnknown) 1158 1168 { … … 1341 1351 /* Create an AudioStreamBasicDescription based on our required audio settings. */ 1342 1352 RT_ZERO(pStreamIn->streamFormat); 1343 coreAudio PCMPropsToASBD(&pStreamIn->Stream.Props, &pStreamIn->streamFormat);1353 coreAudioStreamCfgToASBD(pCfgReq, &pStreamIn->streamFormat); 1344 1354 1345 1355 coreAudioPrintASBD("Recording device", &pStreamIn->deviceFormat); … … 1512 1522 } 1513 1523 1514 if (RT_SUCCESS(rc)) 1515 rc = RTCircBufCreate(&pStreamIn->pCircBuf, cSamples << pStreamIn->Stream.Props.cShift); 1524 PDMAUDIOPCMPROPS PCMProps; 1525 int rc2 = DrvAudioHlpStreamCfgToProps(pCfgAcq, &PCMProps); 1526 AssertRC(rc2); 1527 1528 rc = RTCircBufCreate(&pStreamIn->pCircBuf, cSamples << PCMProps.cShift); 1529 if (RT_FAILURE(rc)) 1530 break; 1516 1531 1517 1532 /* Init the converter callback context. */ 1518 if (RT_SUCCESS(rc)) 1519 rc = coreAudioInitConvCbCtx(&pStreamIn->convCbCtx, 1520 &pStreamIn->deviceFormat /* Source */, &pStreamIn->streamFormat /* Dest */); 1533 rc = coreAudioInitConvCbCtx(&pStreamIn->convCbCtx, 1534 &pStreamIn->deviceFormat /* Source */, &pStreamIn->streamFormat /* Dest */); 1521 1535 1522 1536 if (RT_SUCCESS(rc)) … … 1573 1587 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 1574 1588 { 1575 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 1576 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1577 AssertPtrReturn(pCfgReq, VERR_INVALID_POINTER); 1578 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 1589 RT_NOREF(pThis); 1579 1590 1580 1591 int rc = VINF_SUCCESS; … … 1584 1595 1585 1596 OSStatus err = noErr; 1597 UInt32 uSize = 0; 1598 1586 1599 AudioDeviceID deviceID = pStreamOut->deviceID; 1587 1588 UInt32 uSize = 0; 1589 if (pStreamOut->deviceID == kAudioDeviceUnknown) 1600 if (deviceID == kAudioDeviceUnknown) 1590 1601 { 1591 1602 /* Fetch the default audio recording device currently in use. */ 1592 1603 AudioObjectPropertyAddress propAdr = { kAudioHardwarePropertyDefaultOutputDevice, 1593 1604 kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; 1594 uSize = sizeof( pStreamOut->deviceID);1595 err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propAdr, 0, NULL, &uSize, & pStreamOut->deviceID);1605 uSize = sizeof(deviceID); 1606 err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propAdr, 0, NULL, &uSize, &deviceID); 1596 1607 if (err != noErr) 1597 1608 { … … 1753 1764 1754 1765 /* Create an AudioStreamBasicDescription based on our required audio settings. */ 1755 coreAudio PCMPropsToASBD(&pStreamOut->Stream.Props, &pStreamOut->streamFormat);1766 coreAudioStreamCfgToASBD(pCfgReq, &pStreamOut->streamFormat); 1756 1767 1757 1768 coreAudioPrintASBD("Playback device", &pStreamOut->deviceFormat); … … 1834 1845 } 1835 1846 1836 /* Create the internal ring buffer. */ 1837 rc = RTCircBufCreate(&pStreamOut->pCircBuf, cSamples << pStream->Props.cShift); 1838 if (RT_SUCCESS(rc)) 1839 { 1840 /* 1841 * Register callbacks. 1842 */ 1847 PDMAUDIOPCMPROPS PCMProps; 1848 int rc2 = DrvAudioHlpStreamCfgToProps(pCfgAcq, &PCMProps); 1849 AssertRC(rc2); 1850 1851 rc = RTCircBufCreate(&pStreamOut->pCircBuf, cSamples << PCMProps.cShift); 1852 if (RT_FAILURE(rc)) 1853 break; 1854 1855 /* 1856 * Register callbacks. 1857 */ 1843 1858 #ifdef DEBUG 1844 1845 1846 1847 1848 1849 1859 propAdr.mSelector = kAudioDeviceProcessorOverload; 1860 propAdr.mScope = kAudioUnitScope_Global; 1861 err = AudioObjectAddPropertyListener(pStreamOut->deviceID, &propAdr, 1862 coreAudioPlaybackAudioDevicePropertyChanged, (void *)pStreamOut); 1863 if (err != noErr) 1864 LogRel(("CoreAudio: Failed to register processor overload listener for output stream (%RI32)\n", err)); 1850 1865 #endif /* DEBUG */ 1851 1866 1852 propAdr.mSelector = kAudioDevicePropertyNominalSampleRate; 1853 propAdr.mScope = kAudioUnitScope_Global; 1854 err = AudioObjectAddPropertyListener(pStreamOut->deviceID, &propAdr, 1855 coreAudioPlaybackAudioDevicePropertyChanged, (void *)pStreamOut); 1856 /* Not fatal. */ 1857 if (err != noErr) 1858 LogRel(("CoreAudio: Failed to register sample rate changed listener for output stream (%RI32)\n", err)); 1859 } 1867 propAdr.mSelector = kAudioDevicePropertyNominalSampleRate; 1868 propAdr.mScope = kAudioUnitScope_Global; 1869 err = AudioObjectAddPropertyListener(pStreamOut->deviceID, &propAdr, 1870 coreAudioPlaybackAudioDevicePropertyChanged, (void *)pStreamOut); 1871 /* Not fatal. */ 1872 if (err != noErr) 1873 LogRel(("CoreAudio: Failed to register sample rate changed listener for output stream (%RI32)\n", err)); 1860 1874 1861 1875 } while (0); -
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r63527 r63529 107 107 typedef struct DSOUNDSTREAMOUT 108 108 { 109 /** Associated host output stream. 110 * Note: Always must come first! */ 109 /** Note: Always must come first! */ 111 110 PDMAUDIOSTREAM Stream; 111 /** The PCM properties of this stream. */ 112 PDMAUDIOPCMPROPS Props; 112 113 LPDIRECTSOUND8 pDS; /** @todo Move this out of this structure! Not required per-stream (e.g. for multi-channel). */ 113 114 LPDIRECTSOUNDBUFFER8 pDSB; … … 121 122 typedef struct DSOUNDSTREAMIN 122 123 { 123 /** Associated host input stream. 124 * Note: Always must come first! */ 124 /** Associated host input stream. */ 125 125 PDMAUDIOSTREAM Stream; 126 /** The PCM properties of this stream. */ 127 PDMAUDIOPCMPROPS Props; 126 128 LPDIRECTSOUNDCAPTURE8 pDSC; 127 129 LPDIRECTSOUNDCAPTUREBUFFER8 pDSCB; … … 557 559 static HRESULT directSoundPlayOpen(PDRVHOSTDSOUND pThis, PDSOUNDSTREAMOUT pDSoundStream) 558 560 { 559 AssertPtrReturn(pThis, E_POINTER);561 AssertPtrReturn(pThis, E_POINTER); 560 562 AssertPtrReturn(pDSoundStream, E_POINTER); 561 563 … … 563 565 pDSoundStream, 564 566 pThis->cfg.cbBufferOut, 565 pDSoundStream-> Stream.Props.uHz,566 pDSoundStream-> Stream.Props.cChannels,567 pDSoundStream-> Stream.Props.cBits,568 pDSoundStream-> Stream.Props.fSigned));567 pDSoundStream->Props.uHz, 568 pDSoundStream->Props.cChannels, 569 pDSoundStream->Props.cBits, 570 pDSoundStream->Props.fSigned)); 569 571 570 572 if (pDSoundStream->pDSB != NULL) … … 666 668 wfx.cbSize)); 667 669 668 if (bc.dwBufferBytes & pDSoundStream-> Stream.Props.uAlign)670 if (bc.dwBufferBytes & pDSoundStream->Props.uAlign) 669 671 DSLOGREL(("DSound: Playback capabilities returned misaligned buffer: size %RU32, alignment %RU32\n", 670 bc.dwBufferBytes, pDSoundStream-> Stream.Props.uAlign + 1));672 bc.dwBufferBytes, pDSoundStream->Props.uAlign + 1)); 671 673 672 674 if (bc.dwBufferBytes != pThis->cfg.cbBufferOut) … … 679 681 * playback buffer position. 680 682 */ 681 pDSoundStream->cMaxSamplesInBuffer = bc.dwBufferBytes >> pDSoundStream-> Stream.Props.cShift;683 pDSoundStream->cMaxSamplesInBuffer = bc.dwBufferBytes >> pDSoundStream->Props.cShift; 682 684 DSLOG(("DSound: cMaxSamplesInBuffer=%RU32\n", pDSoundStream->cMaxSamplesInBuffer)); 683 685 … … 1038 1040 pDSoundStream, 1039 1041 pThis->cfg.cbBufferIn, 1040 pDSoundStream-> Stream.Props.uHz,1041 pDSoundStream-> Stream.Props.cChannels,1042 pDSoundStream-> Stream.Props.cBits,1043 pDSoundStream-> Stream.Props.fSigned));1042 pDSoundStream->Props.uHz, 1043 pDSoundStream->Props.cChannels, 1044 pDSoundStream->Props.cBits, 1045 pDSoundStream->Props.fSigned)); 1044 1046 1045 1047 if (pDSoundStream->pDSCB != NULL) … … 1137 1139 wfx.cbSize)); 1138 1140 1139 if (bc.dwBufferBytes & pDSoundStream-> Stream.Props.uAlign)1141 if (bc.dwBufferBytes & pDSoundStream->Props.uAlign) 1140 1142 DSLOGREL(("DSound: Capture GetCaps returned misaligned buffer: size %RU32, alignment %RU32\n", 1141 bc.dwBufferBytes, pDSoundStream-> Stream.Props.uAlign + 1));1143 bc.dwBufferBytes, pDSoundStream->Props.uAlign + 1)); 1142 1144 1143 1145 if (bc.dwBufferBytes != pThis->cfg.cbBufferIn) … … 1146 1148 1147 1149 /* Initial state: reading at the initial capture position, no error. */ 1148 pDSoundStream->idxSampleCaptureReadPos = offByteReadPos >> pDSoundStream->Stream.Props.cShift;1149 pDSoundStream->cMaxSamplesInBuffer = bc.dwBufferBytes >> pDSoundStream->Stream.Props.cShift;1150 pDSoundStream->hrLastCapture = S_OK;1150 pDSoundStream->idxSampleCaptureReadPos = offByteReadPos >> pDSoundStream->Props.cShift; 1151 pDSoundStream->cMaxSamplesInBuffer = bc.dwBufferBytes >> pDSoundStream->Props.cShift; 1152 pDSoundStream->hrLastCapture = S_OK; 1151 1153 1152 1154 DSLOG(("DSound: idxSampleCaptureReadPos=%RU32, cMaxSamplesInBuffer=%RU32\n", … … 1450 1452 pDSoundStream->streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS; 1451 1453 1452 int rc = DrvAudioHlpStreamCfgToProps(&pDSoundStream->streamCfg, &pDSoundStream-> Stream.Props);1454 int rc = DrvAudioHlpStreamCfgToProps(&pDSoundStream->streamCfg, &pDSoundStream->Props); 1453 1455 if (RT_SUCCESS(rc)) 1454 1456 { … … 1460 1462 1461 1463 if (pCfgAcq) 1462 pCfgAcq->cSamples = pThis->cfg.cbBufferOut >> p Stream->Props.cShift; /** @todo Get rid of using Props! */1464 pCfgAcq->cSamples = pThis->cfg.cbBufferOut >> pDSoundStream->Props.cShift; 1463 1465 1464 1466 /* Try to open playback in case the device is already there. */ … … 1567 1569 /* Do not write more than available space in the DirectSound playback buffer. */ 1568 1570 cbLive = RT_MIN(cbFree, cbLive); 1569 cbLive &= ~p Stream->Props.uAlign;1571 cbLive &= ~pDSoundStream->Props.uAlign; 1570 1572 if (cbLive == 0 || cbLive > cbBuffer) 1571 1573 { … … 1580 1582 PVOID pv1, pv2; 1581 1583 DWORD cb1, cb2; 1582 HRESULT hr = directSoundPlayLock(pThis, pDSB, &p Stream->Props, pDSoundStream->offPlayWritePos, cbLive,1584 HRESULT hr = directSoundPlayLock(pThis, pDSB, &pDSoundStream->Props, pDSoundStream->offPlayWritePos, cbLive, 1583 1585 &pv1, &pv2, &cb1, &cb2, 0 /* dwFlags */); 1584 1586 if (FAILED(hr)) … … 1700 1702 1701 1703 /** @todo caller should already init Props? */ 1702 int rc = DrvAudioHlpStreamCfgToProps(&pDSoundStream->streamCfg, &p Stream->Props); /** @todo Get rid of using Props! */1704 int rc = DrvAudioHlpStreamCfgToProps(&pDSoundStream->streamCfg, &pDSoundStream->Props); 1703 1705 if (RT_SUCCESS(rc)) 1704 1706 { … … 1712 1714 1713 1715 if (pCfgAcq) 1714 pCfgAcq->cSamples = pThis->cfg.cbBufferIn >> p Stream->Props.cShift; /** @todo Get rid of using Props! */1716 pCfgAcq->cSamples = pThis->cfg.cbBufferIn >> pDSoundStream->Props.cShift; 1715 1717 1716 1718 /* Try to open capture in case the device is already there. */ … … 1819 1821 pDSoundStream->hrLastCapture = hr; 1820 1822 1821 if (offByteReadPos & p Stream->Props.uAlign)1822 DSLOGF(("DSound: Misaligned capture read position %ld (alignment: %RU32)\n", offByteReadPos, p Stream->Props.uAlign));1823 if (offByteReadPos & pDSoundStream->Props.uAlign) 1824 DSLOGF(("DSound: Misaligned capture read position %ld (alignment: %RU32)\n", offByteReadPos, pDSoundStream->Props.uAlign)); 1823 1825 1824 1826 /* Capture position in samples. */ 1825 DWORD idxSampleReadPos = offByteReadPos >> p Stream->Props.cShift;1827 DWORD idxSampleReadPos = offByteReadPos >> pDSoundStream->Props.cShift; 1826 1828 1827 1829 /* Number of samples available in the DirectSound capture buffer. */ … … 1848 1850 PVOID pv1, pv2; 1849 1851 DWORD cb1, cb2; 1850 hr = directSoundCaptureLock(pDSCB, &p Stream->Props,1852 hr = directSoundCaptureLock(pDSCB, &pDSoundStream->Props, 1851 1853 AUDIOMIXBUF_S2B(&pStream->MixBuf, pDSoundStream->idxSampleCaptureReadPos), /* dwOffset */ 1852 1854 AUDIOMIXBUF_S2B(&pStream->MixBuf, cSamplesToCapture), /* dwBytes */ -
trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
r63488 r63529 133 133 134 134 /* Just adopt the wanted stream configuration. */ 135 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pStream->Props); 135 PDMAUDIOPCMPROPS Props; 136 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &Props); 136 137 if (RT_SUCCESS(rc)) 137 138 { … … 157 158 if (RT_SUCCESS(rc)) 158 159 { 159 pDbgStream->Out.tsLastPlayed = 0;160 pDbgStream->Out.tsLastPlayed = 0; 160 161 pDbgStream->Out.cMaxSamplesInPlayBuffer = _1K; 161 pDbgStream->Out.pu8PlayBuffer = (uint8_t *)RTMemAlloc(pDbgStream->Out.cMaxSamplesInPlayBuffer << Props.cShift);162 pDbgStream->Out.pu8PlayBuffer = (uint8_t *)RTMemAlloc(pDbgStream->Out.cMaxSamplesInPlayBuffer << Props.cShift); 162 163 if (!pDbgStream->Out.pu8PlayBuffer) 163 164 rc = VERR_NO_MEMORY; … … 193 194 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 194 195 */ 195 static DECLCALLBACK(int) drvHostDebugAudioStreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 196 static DECLCALLBACK(int) drvHostDebugAudioStreamCreate(PPDMIHOSTAUDIO pInterface, 197 PPDMAUDIOSTREAM pStream, 198 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 196 199 { 197 200 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 213 216 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 214 217 */ 215 static DECLCALLBACK(int) drvHostDebugAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 218 static DECLCALLBACK(int) drvHostDebugAudioStreamPlay(PPDMIHOSTAUDIO pInterface, 219 PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, 220 uint32_t *pcbWritten) 216 221 { 217 222 RT_NOREF(pvBuf, cbBuf); … … 284 289 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 285 290 */ 286 static DECLCALLBACK(int) drvHostDebugAudioStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 291 static DECLCALLBACK(int) drvHostDebugAudioStreamCapture(PPDMIHOSTAUDIO pInterface, 292 PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 287 293 { 288 294 RT_NOREF(pInterface, pStream, pvBuf, cbBuf); -
trunk/src/VBox/Devices/Audio/DrvHostNullAudio.cpp
r63481 r63529 62 62 typedef struct NULLAUDIOSTREAMOUT 63 63 { 64 /** @note Always must come first! */ 64 65 PDMAUDIOSTREAM Stream; 66 /** The PCM properties of this stream. */ 67 PDMAUDIOPCMPROPS Props; 65 68 uint64_t u64TicksLast; 66 69 uint64_t cMaxSamplesInPlayBuffer; … … 73 76 /** @note Always must come first! */ 74 77 PDMAUDIOSTREAM Stream; 78 /** The PCM properties of this stream. */ 79 PDMAUDIOPCMPROPS Props; 75 80 } NULLAUDIOSTREAMIN; 76 81 typedef NULLAUDIOSTREAMIN *PNULLAUDIOSTREAMIN; … … 150 155 static DECLCALLBACK(int) drvHostNullAudioStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 151 156 { 157 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 158 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 159 152 160 RT_NOREF2(pvBuf, cbBuf); 153 161 … … 169 177 * If rounding is not taken into account then the playback rate will be consistently lower that expected. 170 178 */ 171 uint64_t cSamplesPlayed = (2 * u64TicksElapsed * p Stream->Props.uHz + u64TicksFreq) / u64TicksFreq / 2;179 uint64_t cSamplesPlayed = (2 * u64TicksElapsed * pNullStream->Props.uHz + u64TicksFreq) / u64TicksFreq / 2; 172 180 173 181 /* Don't play more than available. */ … … 206 214 static int nullCreateStreamIn(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 207 215 { 216 PNULLAUDIOSTREAMIN pNullStream = RT_FROM_MEMBER(pStream, NULLAUDIOSTREAMIN, Stream); 217 208 218 /* Just adopt the wanted stream configuration. */ 209 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &p Stream->Props);219 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pNullStream->Props); 210 220 if (RT_SUCCESS(rc)) 211 221 { … … 221 231 static int nullCreateStreamOut(PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 222 232 { 233 PNULLAUDIOSTREAMOUT pNullStream = RT_FROM_MEMBER(pStream, NULLAUDIOSTREAMOUT, Stream); 234 223 235 /* Just adopt the wanted stream configuration. */ 224 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &p Stream->Props);236 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pNullStream->Props); 225 237 if (RT_SUCCESS(rc)) 226 238 { 227 PNULLAUDIOSTREAMOUT pNullStream = RT_FROM_MEMBER(pStream, NULLAUDIOSTREAMOUT, Stream);228 229 239 pNullStream->u64TicksLast = 0; 230 240 pNullStream->cMaxSamplesInPlayBuffer = _1K; 231 241 232 pNullStream->pbPlayBuffer = (uint8_t *)RTMemAlloc(_1K << p Stream->Props.cShift);242 pNullStream->pbPlayBuffer = (uint8_t *)RTMemAlloc(_1K << pNullStream->Props.cShift); 233 243 if (pNullStream->pbPlayBuffer) 234 244 { -
trunk/src/VBox/Devices/Audio/DrvHostOSSAudio.cpp
r63481 r63529 84 84 /** Note: Always must come first! */ 85 85 PDMAUDIOSTREAM pStreamIn; 86 /** The PCM properties of this stream. */ 87 PDMAUDIOPCMPROPS Props; 86 88 int hFile; 87 89 int cFragments; … … 98 100 /** Note: Always must come first! */ 99 101 PDMAUDIOSTREAM pStreamOut; 102 /** The PCM properties of this stream. */ 103 PDMAUDIOPCMPROPS Props; 100 104 int hFile; 101 105 int cFragments; … … 363 367 case PDMAUDIOSTREAMCMD_RESUME: 364 368 { 365 DrvAudioHlpClearBuf(&pStream ->Props, /** @todo Get rid of using Props! */369 DrvAudioHlpClearBuf(&pStreamOut->Props, 366 370 pStreamOut->pvBuf, pStreamOut->cbBuf, AudioMixBufSize(&pStream->MixBuf)); 367 371 … … 675 679 pCfgAcq->enmEndianness = obtStream.enmENDIANNESS; 676 680 677 PDMAUDIOPCMPROPS Props; 678 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &Props); 681 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &pStrm->Props); 679 682 if (RT_SUCCESS(rc)) 680 683 { 681 if (obtStream.cFragments * obtStream.cbFragmentSize & Props.uAlign)684 if (obtStream.cFragments * obtStream.cbFragmentSize & pStrm->Props.uAlign) 682 685 { 683 686 LogRel(("OSS: Warning: Misaligned capturing buffer: Size = %zu, Alignment = %u\n", 684 obtStream.cFragments * obtStream.cbFragmentSize, Props.uAlign + 1));687 obtStream.cFragments * obtStream.cbFragmentSize, pStrm->Props.uAlign + 1)); 685 688 } 686 689 687 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) >> Props.cShift;690 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) >> pStrm->Props.cShift; 688 691 if (!cSamples) 689 692 rc = VERR_INVALID_PARAMETER; … … 692 695 if (RT_SUCCESS(rc)) 693 696 { 694 size_t cbSample = (1 << Props.cShift);697 size_t cbSample = (1 << pStrm->Props.cShift); 695 698 696 699 size_t cbBuf = cSamples * cbSample; … … 740 743 reqStream.cbFragmentSize = s_OSSConf.fragsize; 741 744 742 PDMAUDIOPCMPROPS Props;743 RT_ZERO(Props);744 745 745 rc = ossStreamOpen(s_OSSConf.devpath_out, O_WRONLY | O_NONBLOCK, &reqStream, &obtStream, &hFile); 746 746 if (RT_SUCCESS(rc)) … … 751 751 pCfgAcq->enmEndianness = obtStream.enmENDIANNESS; 752 752 753 rc = DrvAudioHlpStreamCfgToProps(pCfg Req, &Props);753 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &pStrm->Props); 754 754 if (RT_SUCCESS(rc)) 755 755 { 756 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) >> Props.cShift;757 758 if (obtStream.cFragments * obtStream.cbFragmentSize & Props.uAlign)756 cSamples = (obtStream.cFragments * obtStream.cbFragmentSize) >> pStrm->Props.cShift; 757 758 if (obtStream.cFragments * obtStream.cbFragmentSize & pStrm->Props.uAlign) 759 759 { 760 760 LogRel(("OSS: Warning: Misaligned playback buffer: Size = %zu, Alignment = %u\n", 761 obtStream.cFragments * obtStream.cbFragmentSize, Props.uAlign + 1));761 obtStream.cFragments * obtStream.cbFragmentSize, pStrm->Props.uAlign + 1)); 762 762 } 763 763 } … … 768 768 pStrm->fMemMapped = false; 769 769 770 size_t cbSamples = cSamples << Props.cShift;770 size_t cbSamples = cSamples << pStrm->Props.cShift; 771 771 Assert(cbSamples); 772 772 -
trunk/src/VBox/Devices/Audio/DrvHostPulseAudio.cpp
r63481 r63529 670 670 pCfgAcq->cChannels = pStrm->SampleSpec.channels; 671 671 672 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &pStream->Props); 672 PDMAUDIOPCMPROPS Props; 673 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &Props); 673 674 if (RT_SUCCESS(rc)) 674 675 { … … 681 682 { 682 683 pStrm->cbPCMBuf = cbBuf; 683 684 pCfgAcq->cSamples = cbBuf >> pStream->Props.cShift; /** @todo Get rid of using Props! */ 685 686 /* Save pointer to driver instance. */ 687 pStrm->pDrv = pThis; 684 pStrm->pDrv = pThis; 685 686 pCfgAcq->cSamples = cbBuf >> Props.cShift; 688 687 } 689 688 else … … 702 701 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 703 702 { 704 PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface); 705 PPULSEAUDIOSTREAM pStrm = (PPULSEAUDIOSTREAM)pStream; 706 707 pStrm->SampleSpec.format = paFmtToPulse(pCfgReq->enmFormat); 708 pStrm->SampleSpec.rate = pCfgReq->uHz; 709 pStrm->SampleSpec.channels = pCfgReq->cChannels; 710 711 /* XXX check these values */ 712 pStrm->BufAttr.fragsize = (pa_bytes_per_second(&pStrm->SampleSpec) 713 * s_pulseCfg.buffer_msecs_in) / 1000; 714 pStrm->BufAttr.maxlength = (pStrm->BufAttr.fragsize * 3) / 2; 703 PDRVHOSTPULSEAUDIO pThis = PDMIHOSTAUDIO_2_DRVHOSTPULSEAUDIO(pInterface); 704 PPULSEAUDIOSTREAM pPAStrm = (PPULSEAUDIOSTREAM)pStream; 705 706 pPAStrm->SampleSpec.format = paFmtToPulse(pCfgReq->enmFormat); 707 pPAStrm->SampleSpec.rate = pCfgReq->uHz; 708 pPAStrm->SampleSpec.channels = pCfgReq->cChannels; 709 710 /** @todo Check these values! */ 711 pPAStrm->BufAttr.fragsize = (pa_bytes_per_second(&pPAStrm->SampleSpec) * s_pulseCfg.buffer_msecs_in) / 1000; 712 pPAStrm->BufAttr.maxlength = (pPAStrm->BufAttr.fragsize * 3) / 2; 715 713 716 714 /* Note: Other members of BufAttr are ignored for record streams. */ 717 int rc = paStreamOpen(pThis, true /* fIn */, "PulseAudio (In)", &p Strm->SampleSpec, &pStrm->BufAttr,718 &p Strm->pPAStream);715 int rc = paStreamOpen(pThis, true /* fIn */, "PulseAudio (In)", &pPAStrm->SampleSpec, &pPAStrm->BufAttr, 716 &pPAStrm->pPAStream); 719 717 if (RT_FAILURE(rc)) 720 718 return rc; 721 719 722 rc = paPulseToFmt(p Strm->SampleSpec.format, &pCfgAcq->enmFormat,720 rc = paPulseToFmt(pPAStrm->SampleSpec.format, &pCfgAcq->enmFormat, 723 721 &pCfgAcq->enmEndianness); 724 722 if (RT_FAILURE(rc)) 725 723 { 726 LogRel(("PulseAudio: Cannot find audio capture format %ld\n", p Strm->SampleSpec.format));724 LogRel(("PulseAudio: Cannot find audio capture format %ld\n", pPAStrm->SampleSpec.format)); 727 725 return rc; 728 726 } 729 727 730 pCfgAcq->uHz = pStrm->SampleSpec.rate; 731 pCfgAcq->cChannels = pStrm->SampleSpec.channels; 732 733 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &pStream->Props); 728 PDMAUDIOPCMPROPS Props; 729 rc = DrvAudioHlpStreamCfgToProps(pCfgAcq, &Props); 734 730 if (RT_SUCCESS(rc)) 735 731 { 736 p CfgAcq->cSamples = RT_MIN(pStrm->BufAttr.fragsize * 10, pStrm->BufAttr.maxlength)737 >> pStream->Props.cShift; /** @todo Get rid of using Props! */738 739 /* Save pointer to driver instance. */740 p Strm->pDrv = pThis;741 p Strm->pu8PeekBuf = NULL;732 pPAStrm->pDrv = pThis; 733 pPAStrm->pu8PeekBuf = NULL; 734 735 pCfgAcq->uHz = pPAStrm->SampleSpec.rate; 736 pCfgAcq->cChannels = pPAStrm->SampleSpec.channels; 737 pCfgAcq->cSamples = RT_MIN(pPAStrm->BufAttr.fragsize * 10, pPAStrm->BufAttr.maxlength) >> Props.cShift; 742 738 } 743 739 -
trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp
r63477 r63529 52 52 /** Pointer to audio VRDE object. */ 53 53 AudioVRDE *pAudioVRDE; 54 /** Pointer to the driver instance structure. */ 54 55 PPDMDRVINS pDrvIns; 55 /** Pointer to the driver instance structure. */56 /** Pointer to host audio interface. */ 56 57 PDMIHOSTAUDIO IHostAudio; 57 58 /** Pointer to the VRDP's console object. */ … … 59 60 /** Pointer to the DrvAudio port interface that is above us. */ 60 61 PPDMIAUDIOCONNECTOR pDrvAudio; 61 /** Whether this driver is enabled or not. */62 bool fEnabled;63 62 } DRVAUDIOVRDE, *PDRVAUDIOVRDE; 64 63 65 64 typedef struct VRDESTREAMIN 66 65 { 67 /** Associated host input stream. 68 * Note: Always must come first! */ 66 /** Note: Always must come first! */ 69 67 PDMAUDIOSTREAM Stream; 68 /** The PCM properties of this stream. */ 69 PDMAUDIOPCMPROPS Props; 70 70 /** Number of samples captured asynchronously in the 71 71 * onVRDEInputXXX callbacks. */ … … 77 77 typedef struct VRDESTREAMOUT 78 78 { 79 /** Associated host output stream. 80 * Note: Always must come first! */ 79 /** Note: Always must come first! */ 81 80 PDMAUDIOSTREAM Stream; 81 /** The PCM properties of this stream. */ 82 PDMAUDIOPCMPROPS Props; 82 83 uint64_t old_ticks; 83 84 uint64_t cSamplesSentPerSec; … … 94 95 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 95 96 96 if (pCfgAcq) 97 pCfgAcq->cSamples = _4K; /** @todo Make this configurable. */ 97 PVRDESTREAMIN pVRDEStrmIn = (PVRDESTREAMIN)pStream; 98 AssertPtrReturn(pVRDEStrmIn, VERR_INVALID_POINTER); 99 100 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pVRDEStrmIn->Props); 101 if (RT_SUCCESS(rc)) 102 { 103 if (pCfgAcq) 104 pCfgAcq->cSamples = _4K; /** @todo Make this configurable. */ 105 } 98 106 99 107 LogFlowFuncLeaveRC(VINF_SUCCESS); … … 110 118 AssertPtrReturn(pCfgAcq, VERR_INVALID_POINTER); 111 119 112 if (pCfgAcq) 113 pCfgAcq->cSamples = _4K; /** @todo Make this configurable. */ 120 PVRDESTREAMOUT pVRDEStrmOut = (PVRDESTREAMOUT)pStream; 121 AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER); 122 123 int rc = DrvAudioHlpStreamCfgToProps(pCfgReq, &pVRDEStrmOut->Props); 124 if (RT_SUCCESS(rc)) 125 { 126 if (pCfgAcq) 127 pCfgAcq->cSamples = _4K; /** @todo Make this configurable. */ 128 } 114 129 115 130 LogFlowFuncLeaveRC(VINF_SUCCESS); … … 157 172 { 158 173 rc = pDrv->pConsoleVRDPServer->SendAudioInputBegin(NULL, pVRDEStrmIn, AudioMixBufSize(&pStream->MixBuf), 159 p Stream->Props.uHz,160 p Stream->Props.cChannels, pStream->Props.cBits);174 pVRDEStrmIn->Props.uHz, 175 pVRDEStrmIn->Props.cChannels, pVRDEStrmIn->Props.cBits); 161 176 if (rc == VERR_NOT_SUPPORTED) 162 177 { … … 192 207 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 193 208 */ 194 static DECLCALLBACK(int) drvAudioVRDEStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 209 static DECLCALLBACK(int) drvAudioVRDEStreamCapture(PPDMIHOSTAUDIO pInterface, 210 PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) 195 211 { 196 212 RT_NOREF2(pvBuf, cbBuf); … … 232 248 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 233 249 */ 234 static DECLCALLBACK(int) drvAudioVRDEStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 250 static DECLCALLBACK(int) drvAudioVRDEStreamPlay(PPDMIHOSTAUDIO pInterface, 251 PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 235 252 { 236 253 RT_NOREF2(pvBuf, cbBuf); … … 250 267 251 268 /* Minimize the rounding error: samples = int((ticks * freq) / ticks_per_second + 0.5). */ 252 uint32_t cSamplesPlayed = (int)((2 * ticks * p Stream->Props.uHz + ticks_per_second) / ticks_per_second / 2);269 uint32_t cSamplesPlayed = (int)((2 * ticks * pVRDEStrmOut->Props.uHz + ticks_per_second) / ticks_per_second / 2); 253 270 254 271 /* Don't play more than available. */ … … 259 276 pVRDEStrmOut->old_ticks = now; 260 277 261 VRDEAUDIOFORMAT format = VRDE_AUDIO_FMT_MAKE(p Stream->Props.uHz,262 p Stream->Props.cChannels,263 p Stream->Props.cBits,264 p Stream->Props.fSigned);278 VRDEAUDIOFORMAT format = VRDE_AUDIO_FMT_MAKE(pVRDEStrmOut->Props.uHz, 279 pVRDEStrmOut->Props.cChannels, 280 pVRDEStrmOut->Props.cBits, 281 pVRDEStrmOut->Props.fSigned); 265 282 266 283 int cSamplesToSend = cSamplesPlayed; 267 284 268 285 LogFlowFunc(("uFreq=%RU32, cChan=%RU8, cBits=%RU8, fSigned=%RTbool, enmFormat=%ld, cSamplesToSend=%RU32\n", 269 p Stream->Props.uHz, pStream->Props.cChannels,270 p Stream->Props.cBits, pStream->Props.fSigned,286 pVRDEStrmOut->Props.uHz, pVRDEStrmOut->Props.cChannels, 287 pVRDEStrmOut->Props.cBits, pVRDEStrmOut->Props.fSigned, 271 288 format, cSamplesToSend)); 272 289 … … 381 398 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 382 399 */ 383 static DECLCALLBACK(int) drvAudioVRDEStreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 400 static DECLCALLBACK(int) drvAudioVRDEStreamCreate(PPDMIHOSTAUDIO pInterface, 401 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq) 384 402 { 385 403 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 419 437 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 420 438 */ 421 static DECLCALLBACK(int) drvAudioVRDEStreamControl(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 439 static DECLCALLBACK(int) drvAudioVRDEStreamControl(PPDMIHOSTAUDIO pInterface, 440 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 422 441 { 423 442 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 497 516 int AudioVRDE::onVRDEControl(bool fEnable, uint32_t uFlags) 498 517 { 499 RT_NOREF( uFlags);518 RT_NOREF(fEnable, uFlags); 500 519 LogFlowThisFunc(("fEnable=%RTbool, uFlags=0x%x\n", fEnable, uFlags)); 501 520 502 521 if (mpDrv == NULL) 503 522 return VERR_INVALID_STATE; 504 505 mpDrv->fEnabled = fEnable;506 523 507 524 return VINF_SUCCESS; /* Never veto. */ … … 607 624 /* IHostAudio */ 608 625 PDMAUDIO_IHOSTAUDIO_CALLBACKS(drvAudioVRDE); 609 610 /* Init defaults. */611 pThis->fEnabled = false;612 626 613 627 /*
Note:
See TracChangeset
for help on using the changeset viewer.