- Timestamp:
- Aug 16, 2016 10:31:42 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 110191
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r63536 r63537 515 515 AssertPtr(pGstStream); 516 516 517 LogFlowFunc(("[%s]\n", pStream->szName));518 519 517 /* 520 518 * Init host stream. … … 527 525 528 526 #ifdef DEBUG 529 530 527 LogFunc(("[%s] Requested host format:\n", pStream->szName)); 528 DrvAudioHlpStreamCfgPrint(pCfgHost); 531 529 #else 532 533 534 535 530 LogRel2(("Audio: Requested %s host format for '%s': %RU32Hz, %s, %RU8 %s\n", 531 pCfgGuest->enmDir == PDMAUDIODIR_IN ? "recording" : "playback", pStream->szName, 532 pCfgHost->uHz, DrvAudioHlpAudFmtToStr(pCfgHost->enmFormat), 533 pCfgHost->cChannels, pCfgHost->cChannels == 0 ? "Channel" : "Channels")); 536 534 #endif 537 535 538 536 int rc = pThis->pHostDrvAudio->pfnStreamCreate(pThis->pHostDrvAudio, pHstStream, 539 537 pCfgHost /* pCfgReq */, &CfgHostAcq /* pCfgAcq */); 540 if (RT_SUCCESS(rc)) 541 { 542 /* Only set the host's stream to initialized if we were able create the stream 543 * in the host backend. This is necessary for trying to re-initialize the stream 544 * at some later point in time. */ 545 pHstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_INITIALIZED; 546 } 547 else 538 if (RT_FAILURE(rc)) 548 539 { 549 540 LogFlowFunc(("[%s] Initializing stream in host backend failed with rc=%Rrc\n", pStream->szName, rc)); 550 } 541 return rc; 542 } 543 544 /* Only set the host's stream to initialized if we were able create the stream 545 * in the host backend. This is necessary for trying to re-initialize the stream 546 * at some later point in time. */ 547 pHstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_INITIALIZED; 551 548 552 549 #ifdef DEBUG 553 554 550 LogFunc(("[%s] Acquired host format:\n", pStream->szName)); 551 DrvAudioHlpStreamCfgPrint(&CfgHostAcq); 555 552 #else 556 557 558 559 553 LogRel2(("Audio: Acquired %s host format for '%s': %RU32Hz, %s, %RU8 %s\n", 554 pCfgGuest->enmDir == PDMAUDIODIR_IN ? "recording" : "playback", pStream->szName, 555 CfgHostAcq.uHz, DrvAudioHlpAudFmtToStr(CfgHostAcq.enmFormat), 556 CfgHostAcq.cChannels, CfgHostAcq.cChannels == 0 ? "Channel" : "Channels")); 560 557 #endif 558 559 /* No sample buffer size hint given by the backend? Default to some sane value. */ 560 if (!CfgHostAcq.cSampleBufferSize) 561 CfgHostAcq.cSampleBufferSize = _1K; /** @todo Make this configurable? */ 561 562 562 563 PDMAUDIOPCMPROPS PCMProps; … … 567 568 AudioMixBufDestroy(&pHstStream->MixBuf); 568 569 569 if (CfgHostAcq.cSampleBufferSize) 570 { 571 LogFlowFunc(("[%s] cSamples=%RU32\n", pHstStream->szName, CfgHostAcq.cSampleBufferSize * 4)); 572 573 rc2 = AudioMixBufInit(&pHstStream->MixBuf, pHstStream->szName, &PCMProps, CfgHostAcq.cSampleBufferSize * 4); 574 AssertRC(rc2); 575 } 570 LogFlowFunc(("[%s] cSamples=%RU32\n", pHstStream->szName, CfgHostAcq.cSampleBufferSize * 4)); 571 572 rc2 = AudioMixBufInit(&pHstStream->MixBuf, pHstStream->szName, &PCMProps, CfgHostAcq.cSampleBufferSize * 4); 573 AssertRC(rc2); 576 574 577 575 /* Make a copy of the host stream configuration. */ … … 589 587 AudioMixBufDestroy(&pGstStream->MixBuf); 590 588 591 if (CfgHostAcq.cSampleBufferSize) 592 { 593 LogFlowFunc(("[%s] cSamples=%RU32\n", pGstStream->szName, CfgHostAcq.cSampleBufferSize * 2)); 594 595 rc2 = AudioMixBufInit(&pGstStream->MixBuf, pGstStream->szName, &PCMProps, CfgHostAcq.cSampleBufferSize * 2); 596 AssertRC(rc2); 597 } 589 LogFlowFunc(("[%s] cSamples=%RU32\n", pGstStream->szName, CfgHostAcq.cSampleBufferSize * 2)); 590 591 rc2 = AudioMixBufInit(&pGstStream->MixBuf, pGstStream->szName, &PCMProps, CfgHostAcq.cSampleBufferSize * 2); 592 AssertRC(rc2); 598 593 599 594 #ifdef VBOX_WITH_STATISTICS … … 601 596 #endif 602 597 603 if (CfgHostAcq.cSampleBufferSize) 604 { 605 if (pCfgGuest->enmDir == PDMAUDIODIR_IN) 606 { 607 /* Host (Parent) -> Guest (Child). */ 608 rc2 = AudioMixBufLinkTo(&pHstStream->MixBuf, &pGstStream->MixBuf); 609 AssertRC(rc2); 598 if (pCfgGuest->enmDir == PDMAUDIODIR_IN) 599 { 600 /* Host (Parent) -> Guest (Child). */ 601 rc2 = AudioMixBufLinkTo(&pHstStream->MixBuf, &pGstStream->MixBuf); 602 AssertRC(rc2); 610 603 611 604 #ifdef VBOX_WITH_STATISTICS 612 613 614 615 616 617 618 619 620 621 622 605 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/BytesElapsed", pGstStream->szName); 606 PDMDrvHlpSTAMRegCounterEx(pThis->pDrvIns, &pGstStream->In.StatBytesElapsed, 607 szStatName, STAMUNIT_BYTES, "Elapsed bytes read."); 608 609 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/BytesRead", pGstStream->szName); 610 PDMDrvHlpSTAMRegCounterEx(pThis->pDrvIns, &pGstStream->In.StatBytesTotalRead, 611 szStatName, STAMUNIT_BYTES, "Total bytes read."); 612 613 RTStrPrintf(szStatName, sizeof(szStatName), "Host/%s/SamplesCaptured", pHstStream->szName); 614 PDMDrvHlpSTAMRegCounterEx(pThis->pDrvIns, &pHstStream->In.StatSamplesCaptured, 615 szStatName, STAMUNIT_COUNT, "Total samples captured."); 623 616 #endif 624 625 626 627 628 629 617 } 618 else 619 { 620 /* Guest (Parent) -> Host (Child). */ 621 rc2 = AudioMixBufLinkTo(&pGstStream->MixBuf, &pHstStream->MixBuf); 622 AssertRC(rc2); 630 623 631 624 #ifdef VBOX_WITH_STATISTICS 632 633 634 635 636 637 638 639 640 641 642 625 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/BytesElapsed", pGstStream->szName); 626 PDMDrvHlpSTAMRegCounterEx(pThis->pDrvIns, &pGstStream->Out.StatBytesElapsed, 627 szStatName, STAMUNIT_BYTES, "Elapsed bytes written."); 628 629 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/BytesRead", pGstStream->szName); 630 PDMDrvHlpSTAMRegCounterEx(pThis->pDrvIns, &pGstStream->Out.StatBytesTotalWritten, 631 szStatName, STAMUNIT_BYTES, "Total bytes written."); 632 633 RTStrPrintf(szStatName, sizeof(szStatName), "Host/%s/SamplesPlayed", pHstStream->szName); 634 PDMDrvHlpSTAMRegCounterEx(pThis->pDrvIns, &pHstStream->Out.StatSamplesPlayed, 635 szStatName, STAMUNIT_COUNT, "Total samples played."); 643 636 #endif 644 }645 637 } 646 638
Note:
See TracChangeset
for help on using the changeset viewer.