- Timestamp:
- May 24, 2016 3:26:06 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r61157 r61166 637 637 * @returns VBox status code. 638 638 * @param pInterface Pointer to the interface structure containing the called function pointer. 639 * @param pszName Friendly name of this input stream. 640 * @param ppGstStrmIn Pointer where to return the guest guest input stream on success. 641 */ 642 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOSTREAM *ppStream)); 639 * @param pCfgHost Stream configuration for host side. 640 * @param pCfgGuest Stream configuration for guest side. 641 * @param ppStream Pointer where to return the created audio stream on success. 642 */ 643 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream)); 643 644 644 645 /** … … 694 695 695 696 /** PDMIAUDIOCONNECTOR interface ID. */ 696 #define PDMIAUDIOCONNECTOR_IID " 45620608-5014-4322-8593-A15ACFDA2B12"697 #define PDMIAUDIOCONNECTOR_IID "9CDE2581-41B1-838E-24A5-448B2D0C822E" 697 698 698 699 -
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r61157 r61166 105 105 } 106 106 107 int AudioMixerCreateStream(PAUDIOMIXER pMixer,108 PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg, uint32_t fFlags, PAUDMIXSTREAM *ppStream)109 {110 AssertPtrReturn(pMixer, VERR_INVALID_POINTER);111 AssertPtrReturn(pConn, VERR_INVALID_POINTER);112 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);113 /** @todo Validate fFlags. */114 /* ppStream is optional. */115 116 PAUDMIXSTREAM pMixStream = (PAUDMIXSTREAM)RTMemAllocZ(sizeof(AUDMIXSTREAM));117 if (!pMixStream)118 return VERR_NO_MEMORY;119 120 pMixStream->pszName = RTStrDup(pCfg->szName);121 if (!pMixStream->pszName)122 {123 RTMemFree(pMixStream);124 return VERR_NO_MEMORY;125 }126 127 LogFlowFunc(("[%s]: fFlags=0x%x (enmDir=%ld, %s, %RU8 channels, %RU32Hz)\n",128 pMixer->pszName, fFlags, pCfg->enmDir, DrvAudioAudFmtToStr(pCfg->enmFormat), pCfg->cChannels, pCfg->uHz));129 130 PPDMAUDIOSTREAM pStream;131 int rc = pConn->pfnStreamCreate(pConn, pCfg, &pStream);132 if (RT_SUCCESS(rc))133 {134 /* Save the audio stream pointer to this mixing stream. */135 pMixStream->pStream = pStream;136 137 /* Increase the stream's reference count to let others know138 * we're reyling on it to be around now. */139 pConn->pfnStreamAddRef(pConn, pStream);140 }141 142 if (RT_SUCCESS(rc))143 {144 pMixStream->fFlags = fFlags;145 pMixStream->pConn = pConn;146 147 if (ppStream)148 *ppStream = pMixStream;149 }150 else if (pMixStream)151 {152 RTStrFree(pMixStream->pszName);153 pMixStream->pszName = NULL;154 155 RTMemFree(pMixStream);156 pMixStream = NULL;157 }158 159 return rc;160 }161 162 107 int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer) 163 108 { … … 417 362 418 363 LogFlowFunc(("[%s]: cStreams=%RU8, rc=%Rrc\n", pSink->pszName, pSink->cStreams, rc)); 364 return rc; 365 } 366 367 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, 368 PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg, uint32_t fFlags, PAUDMIXSTREAM *ppStream) 369 { 370 AssertPtrReturn(pSink, VERR_INVALID_POINTER); 371 AssertPtrReturn(pConn, VERR_INVALID_POINTER); 372 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 373 /** @todo Validate fFlags. */ 374 /* ppStream is optional. */ 375 376 PAUDMIXSTREAM pMixStream = (PAUDMIXSTREAM)RTMemAllocZ(sizeof(AUDMIXSTREAM)); 377 if (!pMixStream) 378 return VERR_NO_MEMORY; 379 380 pMixStream->pszName = RTStrDup(pCfg->szName); 381 if (!pMixStream->pszName) 382 { 383 RTMemFree(pMixStream); 384 return VERR_NO_MEMORY; 385 } 386 387 LogFlowFunc(("[%s]: fFlags=0x%x (enmDir=%ld, %s, %RU8 channels, %RU32Hz)\n", 388 pSink->pszName, fFlags, pCfg->enmDir, DrvAudioAudFmtToStr(pCfg->enmFormat), pCfg->cChannels, pCfg->uHz)); 389 390 PDMAUDIOSTREAMCFG CfgSink; 391 int rc = DrvAudioPCMPropsToStreamCfg(&pSink->PCMProps, &CfgSink); 392 AssertRCReturn(rc, rc); 393 394 /* Always use the sink's PCM audio format as the host side when creating a stream for it. */ 395 PPDMAUDIOSTREAM pStream; 396 rc = pConn->pfnStreamCreate(pConn, &CfgSink, pCfg, &pStream); 397 if (RT_SUCCESS(rc)) 398 { 399 /* Save the audio stream pointer to this mixing stream. */ 400 pMixStream->pStream = pStream; 401 402 /* Increase the stream's reference count to let others know 403 * we're reyling on it to be around now. */ 404 pConn->pfnStreamAddRef(pConn, pStream); 405 } 406 407 if (RT_SUCCESS(rc)) 408 { 409 pMixStream->fFlags = fFlags; 410 pMixStream->pConn = pConn; 411 412 if (ppStream) 413 *ppStream = pMixStream; 414 } 415 else if (pMixStream) 416 { 417 RTStrFree(pMixStream->pszName); 418 pMixStream->pszName = NULL; 419 420 RTMemFree(pMixStream); 421 pMixStream = NULL; 422 } 423 419 424 return rc; 420 425 } -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r61157 r61166 156 156 int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer); 157 157 int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink); 158 int AudioMixerCreateStream(PAUDIOMIXER pMixer, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOSTREAMCFG pCfg, uint32_t fFlags, PAUDMIXSTREAM *ppStream);159 158 void AudioMixerDestroy(PAUDIOMIXER pMixer); 160 159 int AudioMixerGetDeviceFormat(PAUDIOMIXER pMixer, PPDMAUDIOSTREAMCFG pCfg); … … 166 165 167 166 int AudioMixerSinkAddStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream); 167 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOSTREAMCFG pCfg, uint32_t fFlags, PAUDMIXSTREAM *ppStream); 168 168 int AudioMixerSinkCtl(PAUDMIXSINK pSink, AUDMIXSINKCMD enmCmd); 169 169 void AudioMixerSinkDestroy(PAUDMIXSINK pSink); -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r61157 r61166 760 760 pStream->pMixStrm = NULL; 761 761 762 int rc2 = AudioMixer CreateStream(pThis->pMixer, pDrv->pConnector, pCfg, 0 /* fFlags */ , &pStream->pMixStrm);762 int rc2 = AudioMixerSinkCreateStream(pSink, pDrv->pConnector, pCfg, 0 /* fFlags */ , &pStream->pMixStrm); 763 763 if (RT_SUCCESS(rc2)) 764 764 { … … 805 805 pDrv->Out.pMixStrm = NULL; 806 806 807 int rc2 = AudioMixer CreateStream(pThis->pMixer, pDrv->pConnector, pCfg, 0 /* fFlags */, &pDrv->Out.pMixStrm);807 int rc2 = AudioMixerSinkCreateStream(pThis->pSinkOutput, pDrv->pConnector, pCfg, 0 /* fFlags */, &pDrv->Out.pMixStrm); 808 808 if (RT_SUCCESS(rc2)) 809 809 { -
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r61158 r61166 3775 3775 3776 3776 PAUDMIXSTREAM pMixStrm; 3777 rc2 = AudioMixer CreateStream(pThis->pMixer, pDrv->pConnector, pCfg, 0 /* fFlags */, &pMixStrm);3777 rc2 = AudioMixerSinkCreateStream(pSink->pMixSink, pDrv->pConnector, pCfg, 0 /* fFlags */, &pMixStrm); 3778 3778 if (RT_SUCCESS(rc2)) 3779 3779 { -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r61157 r61166 2054 2054 pDrv->Out.pMixStrm = NULL; 2055 2055 2056 int rc2 = AudioMixer CreateStream(pThis->pMixer, pDrv->pConnector, pCfg, 0 /* fFlags */, &pDrv->Out.pMixStrm);2056 int rc2 = AudioMixerSinkCreateStream(pThis->pSinkOutput, pDrv->pConnector, pCfg, 0 /* fFlags */, &pDrv->Out.pMixStrm); 2057 2057 if (RT_SUCCESS(rc2)) 2058 2058 { -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r61161 r61166 1455 1455 #endif 1456 1456 1457 static DECLCALLBACK(int) drvAudioStreamCreate(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfg, 1457 static DECLCALLBACK(int) drvAudioStreamCreate(PPDMIAUDIOCONNECTOR pInterface, 1458 PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest, 1458 1459 PPDMAUDIOSTREAM *ppStream) 1459 1460 { 1460 1461 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1461 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1462 AssertPtrReturn(pCfgHost, VERR_INVALID_POINTER); 1463 AssertPtrReturn(pCfgGuest, VERR_INVALID_POINTER); 1462 1464 AssertPtrReturn(ppStream, VERR_INVALID_POINTER); 1463 1465 … … 1468 1470 return rc; 1469 1471 1470 LogFlowFunc((" szName=%s\n", pCfg->szName));1472 LogFlowFunc(("Host=%s, Guest=%s\n", pCfgHost->szName, pCfgGuest->szName)); 1471 1473 #ifdef DEBUG 1472 DrvAudioStreamCfgPrint(pCfg); 1474 DrvAudioStreamCfgPrint(pCfgHost); 1475 DrvAudioStreamCfgPrint(pCfgGuest); 1473 1476 #endif 1474 1477 … … 1486 1489 do 1487 1490 { 1488 if (!DrvAudioStreamCfgIsValid(pCfg)) 1491 if ( !DrvAudioStreamCfgIsValid(pCfgHost) 1492 || !DrvAudioStreamCfgIsValid(pCfgGuest)) 1493 { 1494 RC_BREAK(VERR_INVALID_PARAMETER); 1495 } 1496 1497 /* Make sure that both configurations actually intend the same thing. */ 1498 if (pCfgHost->enmDir != pCfgGuest->enmDir) 1489 1499 RC_BREAK(VERR_INVALID_PARAMETER); 1490 1500 … … 1492 1502 * which the host backend will need. */ 1493 1503 size_t cbHstStrm; 1494 if (pCfg ->enmDir == PDMAUDIODIR_IN)1504 if (pCfgHost->enmDir == PDMAUDIODIR_IN) 1495 1505 { 1496 1506 if (!pThis->cStreamsFreeIn) … … 1542 1552 1543 1553 RTStrPrintf(pHstStrm->szName, RT_ELEMENTS(pHstStrm->szName), "%s (Host)", 1544 strlen(pCfg ->szName) ? pCfg->szName : "<Untitled>");1554 strlen(pCfgHost->szName) ? pCfgHost->szName : "<Untitled>"); 1545 1555 1546 1556 /* Note: Direction is always from child -> parent. */ 1547 1557 uint32_t cSamples = 0; 1548 rc = pThis->pHostDrvAudio->pfnStreamCreate(pThis->pHostDrvAudio, pHstStrm, pCfg , &cSamples);1558 rc = pThis->pHostDrvAudio->pfnStreamCreate(pThis->pHostDrvAudio, pHstStrm, pCfgHost, &cSamples); 1549 1559 if (RT_FAILURE(rc)) 1550 1560 { … … 1554 1564 1555 1565 pHstStrm->enmCtx = PDMAUDIOSTREAMCTX_HOST; 1556 pHstStrm->enmDir = pCfg ->enmDir;1566 pHstStrm->enmDir = pCfgHost->enmDir; 1557 1567 pHstStrm->fStatus |= PDMAUDIOSTRMSTS_FLAG_INITIALIZED; 1558 1568 pHstStrm->pPair = pGstStrm; 1559 1569 1560 rc = DrvAudioStreamCfgToProps(pCfg , &pHstStrm->Props);1570 rc = DrvAudioStreamCfgToProps(pCfgHost, &pHstStrm->Props); 1561 1571 AssertRCBreak(rc); 1562 1572 … … 1569 1579 1570 1580 RTStrPrintf(pGstStrm->szName, RT_ELEMENTS(pGstStrm->szName), "%s (Guest)", 1571 strlen(pCfg ->szName) ? pCfg->szName : "<Untitled>");1572 1573 rc = DrvAudioStreamCfgToProps(pCfg , &pGstStrm->Props);1581 strlen(pCfgGuest->szName) ? pCfgGuest->szName : "<Untitled>"); 1582 1583 rc = DrvAudioStreamCfgToProps(pCfgGuest, &pGstStrm->Props); 1574 1584 AssertRCBreak(rc); 1575 1585 … … 1577 1587 if (RT_SUCCESS(rc)) 1578 1588 { 1579 if (pCfg ->enmDir == PDMAUDIODIR_IN)1589 if (pCfgGuest->enmDir == PDMAUDIODIR_IN) 1580 1590 { 1581 1591 rc = AudioMixBufLinkTo(&pHstStrm->MixBuf, &pGstStrm->MixBuf); … … 1588 1598 1589 1599 pGstStrm->enmCtx = PDMAUDIOSTREAMCTX_GUEST; 1590 pGstStrm->enmDir = pCfg ->enmDir;1600 pGstStrm->enmDir = pCfgGuest->enmDir; 1591 1601 pGstStrm->fStatus |= PDMAUDIOSTRMSTS_FLAG_INITIALIZED; 1592 1602 pGstStrm->pPair = pHstStrm; … … 1628 1638 pHstStrm->cRefs = 1; 1629 1639 1630 if (pCfg ->enmDir == PDMAUDIODIR_IN)1640 if (pCfgHost->enmDir == PDMAUDIODIR_IN) 1631 1641 { 1632 1642 Assert(pThis->cStreamsFreeIn); -
trunk/src/VBox/Devices/Audio/DrvAudio.h
r61157 r61166 111 111 ( (PDRVAUDIO)((uintptr_t)pInterface - RT_OFFSETOF(DRVAUDIO, IAudioConnector)) ) 112 112 113 114 bool DrvAudioAudFmtIsSigned(PDMAUDIOFMT enmFmt); 115 uint8_t DrvAudioAudFmtToBits(PDMAUDIOFMT enmFmt); 113 116 const char *DrvAudioAudFmtToStr(PDMAUDIOFMT enmFmt); 114 117 void DrvAudioClearBuf(PPDMPCMPROPS pPCMInfo, void *pvBuf, size_t cbBuf, uint32_t cSamples); 115 bool DrvAudioPCMPropsAreEqual(PPDMPCMPROPS pProps1, PPDMPCMPROPS pProps2); 116 bool DrvAudioPCMPropsAreEqual(PPDMPCMPROPS pPCMInfo, PPDMAUDIOSTREAMCFG pCfg); 118 bool DrvAudioPCMPropsAreEqual(PPDMPCMPROPS pPCMProps1, PPDMPCMPROPS pPCMProps2); 119 bool DrvAudioPCMPropsAreEqual(PPDMPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg); 120 int DrvAudioPCMPropsToStreamCfg(PPDMPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg); 117 121 const char *DrvAudRecSrcToStr(PDMAUDIORECSOURCE enmRecSource); 118 122 void DrvAudioStreamCfgPrint(PPDMAUDIOSTREAMCFG pCfg); -
trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp
r61157 r61166 61 61 #include "AudioMixBuffer.h" 62 62 63 64 /** 65 * Retrieves the matching PDMAUDIOFMT for given bits + signing flag. 66 * 67 * @return IPRT status code. 68 * @return PDMAUDIOFMT Resulting audio format or PDMAUDIOFMT_INVALID if invalid. 69 * @param cBits Bits to retrieve audio format for. 70 * @param fSigned Signed flag for bits to retrieve audio format for. 71 */ 72 PDMAUDIOFMT DrvAudioAudFmtBitsToAudFmt(uint8_t cBits, bool fSigned) 73 { 74 if (fSigned) 75 { 76 switch (cBits) 77 { 78 case 8: return PDMAUDIOFMT_S8; 79 case 16: return PDMAUDIOFMT_S16; 80 case 32: return PDMAUDIOFMT_S32; 81 default: break; 82 } 83 } 84 else 85 { 86 switch (cBits) 87 { 88 case 8: return PDMAUDIOFMT_U8; 89 case 16: return PDMAUDIOFMT_U16; 90 case 32: return PDMAUDIOFMT_U32; 91 default: break; 92 } 93 } 94 95 AssertMsgFailed(("Bogus audio bits %RU8\n", cBits)); 96 return PDMAUDIOFMT_INVALID; 97 } 98 63 99 /** 64 100 * Clears a sample buffer by the given amount of audio samples. … … 150 186 AssertMsgFailed(("Invalid recording source %ld\n", enmRecSrc)); 151 187 return "Unknown"; 188 } 189 190 /** 191 * Returns wether the given audio format has signed bits or not. 192 * 193 * @return IPRT status code. 194 * @return bool @true for signed bits, @false for unsigned. 195 * @param enmFmt Audio format to retrieve value for. 196 */ 197 bool DrvAudioAudFmtIsSigned(PDMAUDIOFMT enmFmt) 198 { 199 switch (enmFmt) 200 { 201 case PDMAUDIOFMT_S8: 202 case PDMAUDIOFMT_S16: 203 case PDMAUDIOFMT_S32: 204 return true; 205 206 case PDMAUDIOFMT_U8: 207 case PDMAUDIOFMT_U16: 208 case PDMAUDIOFMT_U32: 209 return false; 210 211 default: 212 break; 213 } 214 215 AssertMsgFailed(("Bogus audio format %ld\n", enmFmt)); 216 return false; 217 } 218 219 /** 220 * Returns the bits of a given audio format. 221 * 222 * @return IPRT status code. 223 * @return uint8_t Bits of audio format. 224 * @param enmFmt Audio format to retrieve value for. 225 */ 226 uint8_t DrvAudioAudFmtToBits(PDMAUDIOFMT enmFmt) 227 { 228 switch (enmFmt) 229 { 230 case PDMAUDIOFMT_S8: 231 case PDMAUDIOFMT_U8: 232 return 8; 233 234 case PDMAUDIOFMT_U16: 235 case PDMAUDIOFMT_S16: 236 return 16; 237 238 case PDMAUDIOFMT_U32: 239 case PDMAUDIOFMT_S32: 240 return 32; 241 242 default: 243 break; 244 } 245 246 AssertMsgFailed(("Bogus audio format %ld\n", enmFmt)); 247 return 0; 152 248 } 153 249 … … 253 349 && pProps1->cBits == pProps2->cBits 254 350 && pProps1->fSwapEndian == pProps2->fSwapEndian; 351 } 352 353 /** 354 * Converts PCM properties to a audio stream configuration. 355 * 356 * @return IPRT status code. 357 * @param pPCMProps Pointer to PCM properties to convert. 358 * @param pCfg Pointer to audio stream configuration to store result into. 359 */ 360 int DrvAudioPCMPropsToStreamCfg(PPDMPCMPROPS pPCMProps, PPDMAUDIOSTREAMCFG pCfg) 361 { 362 AssertPtrReturn(pPCMProps, VERR_INVALID_POINTER); 363 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 364 365 pCfg->uHz = pPCMProps->uHz; 366 pCfg->cChannels = pPCMProps->cChannels; 367 pCfg->enmFormat = DrvAudioAudFmtBitsToAudFmt(pPCMProps->cBits, pPCMProps->fSigned); 368 369 /** @todo We assume little endian is the default for now. */ 370 pCfg->enmEndianness = pPCMProps->fSwapEndian == false ? PDMAUDIOENDIANNESS_LITTLE : PDMAUDIOENDIANNESS_BIG; 371 return VINF_SUCCESS; 255 372 } 256 373
Note:
See TracChangeset
for help on using the changeset viewer.