- Timestamp:
- Mar 26, 2021 9:18:42 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmaudioifs.h
r88300 r88307 1034 1034 * differ between parent and child. */ 1035 1035 uint32_t cMixed; 1036 /** How much audio frames are currently being used 1037 * in this buffer. 1038 * Note: This also is known as the distance in ring buffer terms. */ 1036 /** How much audio frames are currently being used in this buffer. 1037 * @note This also is known as the distance in ring buffer terms. */ 1039 1038 uint32_t cUsed; 1040 1039 /** Number of children mix buffers kept in lstChildren. */ … … 1240 1239 STAMCOUNTER AvgFramesWritten; 1241 1240 STAMCOUNTER TotalTimesWritten; 1241 uint32_t cbBackendWritableBefore; 1242 uint32_t cbBackendWritableAfter; 1242 1243 } Stats; 1243 1244 /** Hack alert: Max writable amount reported by the backend. … … 1524 1525 * @param pCfgGuest Stream configuration for guest side. 1525 1526 * @param ppStream Pointer where to return the created audio stream on success. 1527 * @todo r=bird: It is not documented how pCfgHost and pCfgGuest can be 1528 * modified the DrvAudio... 1526 1529 */ 1527 1530 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfgHost, -
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r88299 r88307 1964 1964 1965 1965 PDMAUDMIXBUFCONVOPTS convOpts; 1966 RT_ZERO(convOpts);1967 1968 1966 convOpts.From.Volume.fMuted = pMixBuf->Volume.fMuted; 1969 1967 convOpts.From.Volume.uLeft = pMixBuf->Volume.uLeft; 1970 1968 convOpts.From.Volume.uRight = pMixBuf->Volume.uRight; 1971 1972 1969 convOpts.cFrames = cToWrite; 1973 1970 -
trunk/src/VBox/Devices/Audio/AudioMixBuffer.h
r88269 r88307 54 54 55 55 56 inline uint32_t AudioMixBufBytesToSamples(PPDMAUDIOMIXBUF pMixBuf); 56 int AudioMixBufInit(PPDMAUDIOMIXBUF pMixBuf, const char *pszName, PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames); 57 void AudioMixBufDestroy(PPDMAUDIOMIXBUF pMixBuf); 57 58 void AudioMixBufClear(PPDMAUDIOMIXBUF pMixBuf); 58 void AudioMixBufDestroy(PPDMAUDIOMIXBUF pMixBuf);59 59 void AudioMixBufFinish(PPDMAUDIOMIXBUF pMixBuf, uint32_t cFramesToClear); 60 60 uint32_t AudioMixBufFree(PPDMAUDIOMIXBUF pMixBuf); 61 61 uint32_t AudioMixBufFreeBytes(PPDMAUDIOMIXBUF pMixBuf); 62 int AudioMixBufInit(PPDMAUDIOMIXBUF pMixBuf, const char *pszName, PCPDMAUDIOPCMPROPS pProps, uint32_t cFrames);63 62 bool AudioMixBufIsEmpty(PPDMAUDIOMIXBUF pMixBuf); 64 63 int AudioMixBufLinkTo(PPDMAUDIOMIXBUF pMixBuf, PPDMAUDIOMIXBUF pParent); -
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r88299 r88307 98 98 99 99 static int audioMixerSinkInit(PAUDMIXSINK pSink, PAUDIOMIXER pMixer, const char *pcszName, AUDMIXSINKDIR enmDir); 100 static void audioMixerSinkDestroyInternal(PAUDMIXSINK pSink );100 static void audioMixerSinkDestroyInternal(PAUDMIXSINK pSink, PPDMDEVINS pDevIns); 101 101 static int audioMixerSinkUpdateVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster); 102 102 static void audioMixerSinkRemoveAllStreamsInternal(PAUDMIXSINK pSink); … … 110 110 111 111 static int audioMixerStreamCtlInternal(PAUDMIXSTREAM pMixStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl); 112 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pStream );112 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pStream, PPDMDEVINS pDevIns); 113 113 static int audioMixerStreamUpdateStatus(PAUDMIXSTREAM pMixStream); 114 114 … … 161 161 * 162 162 * @returns VBox status code. 163 * @param pMixer Mixer to attach created sink to. 164 * @param pszName Name of the sink to create. 165 * @param enmDir Direction of the sink to create. 166 * @param ppSink Pointer which returns the created sink on success. 167 */ 168 int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PAUDMIXSINK *ppSink) 163 * @param pMixer Mixer to attach created sink to. 164 * @param pszName Name of the sink to create. 165 * @param enmDir Direction of the sink to create. 166 * @param pDevIns The device instance to register statistics under. 167 * @param ppSink Pointer which returns the created sink on success. 168 */ 169 int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PPDMDEVINS pDevIns, PAUDMIXSINK *ppSink) 169 170 { 170 171 AssertPtrReturn(pMixer, VERR_INVALID_POINTER); … … 173 174 174 175 int rc = RTCritSectEnter(&pMixer->CritSect); 175 if (RT_FAILURE(rc)) 176 return rc; 176 AssertRCReturn(rc, rc); 177 177 178 178 PAUDMIXSINK pSink = (PAUDMIXSINK)RTMemAllocZ(sizeof(AUDMIXSINK)); … … 185 185 if (RT_SUCCESS(rc)) 186 186 { 187 RTCritSectLeave(&pMixer->CritSect); 188 187 189 if (ppSink) 188 190 *ppSink = pSink; 191 return VINF_SUCCESS; 189 192 } 190 193 } 191 194 192 if (RT_FAILURE(rc)) 193 { 194 audioMixerSinkDestroyInternal(pSink); 195 196 RTMemFree(pSink); 197 pSink = NULL; 198 } 195 audioMixerSinkDestroyInternal(pSink, pDevIns); 196 197 RTMemFree(pSink); 198 pSink = NULL; 199 199 } 200 200 else 201 201 rc = VERR_NO_MEMORY; 202 202 203 int rc2 = RTCritSectLeave(&pMixer->CritSect); 204 AssertRC(rc2); 205 203 RTCritSectLeave(&pMixer->CritSect); 206 204 return rc; 207 205 } … … 297 295 * Destroys an audio mixer. 298 296 * 299 * @param pMixer Audio mixer to destroy. 300 */ 301 void AudioMixerDestroy(PAUDIOMIXER pMixer) 297 * @param pMixer Audio mixer to destroy. 298 * @param pDevIns The device instance the statistics are associated with. 299 */ 300 void AudioMixerDestroy(PAUDIOMIXER pMixer, PPDMDEVINS pDevIns) 302 301 { 303 302 if (!pMixer) … … 312 311 RTListForEachSafe(&pMixer->lstSinks, pSink, pSinkNext, AUDMIXSINK, Node) 313 312 { 314 /* Save a pointer to the sink to remove, as pSink 315 * will not be valid anymore after calling audioMixerRemoveSinkInternal(). */ 316 PAUDMIXSINK pSinkToRemove = pSink; 317 318 audioMixerSinkDestroyInternal(pSinkToRemove); 319 audioMixerRemoveSinkInternal(pMixer, pSinkToRemove); 320 321 RTMemFree(pSinkToRemove); 313 audioMixerSinkDestroyInternal(pSink, pDevIns); 314 audioMixerRemoveSinkInternal(pMixer, pSink); 315 RTMemFree(pSink); 322 316 } 323 317 324 318 Assert(pMixer->cSinks == 0); 325 319 326 if (pMixer->pszName) 327 { 328 RTStrFree(pMixer->pszName); 329 pMixer->pszName = NULL; 330 } 320 RTStrFree(pMixer->pszName); 321 pMixer->pszName = NULL; 331 322 332 323 rc2 = RTCritSectLeave(&pMixer->CritSect); … … 558 549 * 559 550 * @returns VBox status code. 560 * @param pSink Sink to use for creating the stream. 561 * @param pConn Audio connector interface to use. 562 * @param pCfg Audio stream configuration to use. 563 * @param fFlags Stream flags. Currently unused, set to 0. 564 * @param ppStream Pointer which receives the newly created audio stream. 565 */ 566 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, 567 PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg, AUDMIXSTREAMFLAGS fFlags, PAUDMIXSTREAM *ppStream) 551 * @param pSink Sink to use for creating the stream. 552 * @param pConn Audio connector interface to use. 553 * @param pCfg Audio stream configuration to use. This may be modified 554 * in some unspecified way (see 555 * PDMIAUDIOCONNECTOR::pfnStreamCreate). 556 * @param fFlags Stream flags. Currently unused, set to 0. 557 * @param pDevIns The device instance to register statistics with. 558 * @param ppStream Pointer which receives the newly created audio stream. 559 */ 560 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg, 561 AUDMIXSTREAMFLAGS fFlags, PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream) 568 562 { 569 563 AssertPtrReturn(pSink, VERR_INVALID_POINTER); … … 573 567 /* ppStream is optional. */ 574 568 569 /* 570 * Check status and get the host driver config. 571 */ 575 572 if (pConn->pfnGetStatus(pConn, PDMAUDIODIR_DUPLEX) == PDMAUDIOBACKENDSTS_NOT_ATTACHED) 576 573 return VERR_AUDIO_BACKEND_NOT_ATTACHED; 577 578 PAUDMIXSTREAM pMixStream = (PAUDMIXSTREAM)RTMemAllocZ(sizeof(AUDMIXSTREAM));579 if (!pMixStream)580 return VERR_NO_MEMORY;581 574 582 575 PDMAUDIOBACKENDCFG BackendCfg; 583 576 int rc = pConn->pfnGetConfig(pConn, &BackendCfg); 584 577 if (RT_FAILURE(rc)) 585 {586 RTMemFree(pMixStream);587 578 return rc; 588 } 579 580 /* 581 * Allocate the instance. 582 */ 583 PAUDMIXSTREAM pMixStream = (PAUDMIXSTREAM)RTMemAllocZ(sizeof(AUDMIXSTREAM)); 584 AssertReturn(pMixStream, VERR_NO_MEMORY); 585 586 pMixStream->fFlags = fFlags; 589 587 590 588 /* Assign the backend's name to the mixer stream's name for easier identification in the (release) log. */ 591 589 pMixStream->pszName = RTStrAPrintf2("[%s] %s", pCfg->szName, BackendCfg.szName); 592 if (!pMixStream->pszName) 593 { 594 RTMemFree(pMixStream); 595 return VERR_NO_MEMORY; 596 } 597 598 rc = RTCritSectEnter(&pSink->CritSect); 599 if (RT_FAILURE(rc)) 600 return rc; 601 602 LogFlowFunc(("[%s] fFlags=0x%x (enmDir=%ld, %u bits, %RU8 channels, %RU32Hz)\n", pSink->pszName, fFlags, pCfg->enmDir, 603 PDMAudioPropsSampleBits(&pCfg->Props), PDMAudioPropsChannels(&pCfg->Props), pCfg->Props.uHz)); 604 605 /* 606 * Initialize the host-side configuration for the stream to be created. 607 * Always use the sink's PCM audio format as the host side when creating a stream for it. 608 */ 609 AssertMsg(AudioHlpPcmPropsAreValid(&pSink->PCMProps), 610 ("%s: Does not (yet) have a format set when it must\n", pSink->pszName)); 611 612 PDMAUDIOSTREAMCFG CfgHost; 613 rc = PDMAudioStrmCfgInitWithProps(&CfgHost, &pSink->PCMProps); 614 AssertRCReturn(rc, rc); 615 616 /* Apply the sink's direction for the configuration to use to 617 * create the stream. */ 618 if (pSink->enmDir == AUDMIXSINKDIR_INPUT) 619 { 620 CfgHost.enmDir = PDMAUDIODIR_IN; 621 CfgHost.u.enmSrc = pCfg->u.enmSrc; 622 CfgHost.enmLayout = pCfg->enmLayout; 590 pMixStream->pszStatPrefix = RTStrAPrintf2("Mix-%s/[%s] %s/", pSink->pszName, pCfg->szName, BackendCfg.szName); 591 if (pMixStream->pszName && pMixStream->pszStatPrefix) 592 { 593 rc = RTCritSectInit(&pMixStream->CritSect); 594 if (RT_SUCCESS(rc)) 595 { 596 rc = RTCircBufCreate(&pMixStream->pCircBuf, PDMAudioPropsMilliToBytes(&pSink->PCMProps, 100 /*ms*/)); /** @todo Make this configurable. */ 597 if (RT_SUCCESS(rc)) 598 { 599 pMixStream->StatsCircBufSize = RTCircBufSize(pMixStream->pCircBuf); 600 pMixStream->StatsCircBufUsed = RTCircBufUsed(pMixStream->pCircBuf); 601 602 /* 603 * Lock the sink so we can safely get it's properties and call 604 * down into the audio driver to create that end of the stream. 605 */ 606 rc = RTCritSectEnter(&pSink->CritSect); 607 AssertRC(rc); 608 if (RT_SUCCESS(rc)) 609 { 610 LogFlowFunc(("[%s] fFlags=0x%x (enmDir=%ld, %u bits, %RU8 channels, %RU32Hz)\n", pSink->pszName, fFlags, pCfg->enmDir, 611 PDMAudioPropsSampleBits(&pCfg->Props), PDMAudioPropsChannels(&pCfg->Props), pCfg->Props.uHz)); 612 613 /* 614 * Initialize the host-side configuration for the stream to be created. 615 * Always use the sink's PCM audio format as the host side when creating a stream for it. 616 */ 617 AssertMsg(AudioHlpPcmPropsAreValid(&pSink->PCMProps), 618 ("%s: Does not (yet) have a format set when it must\n", pSink->pszName)); 619 620 PDMAUDIOSTREAMCFG CfgHost; 621 rc = PDMAudioStrmCfgInitWithProps(&CfgHost, &pSink->PCMProps); 622 AssertRC(rc); /* cannot fail */ 623 624 /* Apply the sink's direction for the configuration to use to create the stream. */ 625 if (pSink->enmDir == AUDMIXSINKDIR_INPUT) 626 { 627 CfgHost.enmDir = PDMAUDIODIR_IN; 628 CfgHost.u.enmSrc = pCfg->u.enmSrc; 629 CfgHost.enmLayout = pCfg->enmLayout; 630 } 631 else 632 { 633 CfgHost.enmDir = PDMAUDIODIR_OUT; 634 CfgHost.u.enmDst = pCfg->u.enmDst; 635 CfgHost.enmLayout = pCfg->enmLayout; 636 } 637 638 RTStrCopy(CfgHost.szName, sizeof(CfgHost.szName), pCfg->szName); 639 640 /* 641 * Create the stream. 642 */ 643 PPDMAUDIOSTREAM pStream; 644 rc = pConn->pfnStreamCreate(pConn, &CfgHost, pCfg, &pStream); 645 if (RT_SUCCESS(rc)) 646 { 647 /* Save the audio stream pointer to this mixing stream. */ 648 pMixStream->pStream = pStream; 649 650 /* Increase the stream's reference count to let others know 651 * we're reyling on it to be around now. */ 652 pConn->pfnStreamRetain(pConn, pStream); 653 pMixStream->pConn = pConn; 654 655 RTCritSectLeave(&pSink->CritSect); 656 657 /* 658 * Register statistics before we return. 659 */ 660 PDMDevHlpSTAMRegisterF(pDevIns, &pMixStream->StatsCircBufSize, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_BYTES, 661 "Circular buffer size", "%sCircBufSize", pMixStream->pszStatPrefix); 662 PDMDevHlpSTAMRegisterF(pDevIns, &pMixStream->StatsCircBufUsed, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_BYTES, 663 "Circular buffer fill size", "%sCircBufUsed", pMixStream->pszStatPrefix); 664 665 if (ppStream) 666 *ppStream = pMixStream; 667 return VINF_SUCCESS; 668 } 669 670 /* 671 * Failed. Tear down the stream. 672 */ 673 int rc2 = RTCritSectLeave(&pSink->CritSect); 674 AssertRC(rc2); 675 } 676 RTCircBufDestroy(pMixStream->pCircBuf); 677 } 678 RTCritSectDelete(&pMixStream->CritSect); 679 } 623 680 } 624 681 else 625 { 626 CfgHost.enmDir = PDMAUDIODIR_OUT; 627 CfgHost.u.enmDst = pCfg->u.enmDst; 628 CfgHost.enmLayout = pCfg->enmLayout; 629 } 630 631 RTStrPrintf(CfgHost.szName, sizeof(CfgHost.szName), "%s", pCfg->szName); 632 633 rc = RTCritSectInit(&pMixStream->CritSect); 634 if (RT_SUCCESS(rc)) 635 { 636 PPDMAUDIOSTREAM pStream; 637 rc = pConn->pfnStreamCreate(pConn, &CfgHost, pCfg, &pStream); 638 if (RT_SUCCESS(rc)) 639 { 640 /* Save the audio stream pointer to this mixing stream. */ 641 pMixStream->pStream = pStream; 642 643 /* Increase the stream's reference count to let others know 644 * we're reyling on it to be around now. */ 645 pConn->pfnStreamRetain(pConn, pStream); 646 } 647 } 648 649 if (RT_SUCCESS(rc)) 650 { 651 rc = RTCircBufCreate(&pMixStream->pCircBuf, PDMAudioPropsMilliToBytes(&pSink->PCMProps, 100 /*ms*/)); /** @todo Make this configurable. */ 652 AssertRC(rc); 653 } 654 655 if (RT_SUCCESS(rc)) 656 { 657 pMixStream->fFlags = fFlags; 658 pMixStream->pConn = pConn; 659 660 if (ppStream) 661 *ppStream = pMixStream; 662 } 663 else if (pMixStream) 664 { 665 int rc2 = RTCritSectDelete(&pMixStream->CritSect); 666 AssertRC(rc2); 667 668 if (pMixStream->pszName) 669 { 670 RTStrFree(pMixStream->pszName); 671 pMixStream->pszName = NULL; 672 } 673 674 RTMemFree(pMixStream); 675 pMixStream = NULL; 676 } 677 678 int rc2 = RTCritSectLeave(&pSink->CritSect); 679 AssertRC(rc2); 680 682 rc = VERR_NO_STR_MEMORY; 683 684 RTStrFree(pMixStream->pszStatPrefix); 685 pMixStream->pszStatPrefix = NULL; 686 RTStrFree(pMixStream->pszName); 687 pMixStream->pszName = NULL; 688 RTMemFree(pMixStream); 681 689 return rc; 682 690 } … … 859 867 * Destroys a mixer sink and removes it from the attached mixer (if any). 860 868 * 861 * @param pSink Mixer sink to destroy. 862 */ 863 void AudioMixerSinkDestroy(PAUDMIXSINK pSink) 869 * @param pSink Mixer sink to destroy. 870 * @param pDevIns The device instance that statistics are registered with. 871 */ 872 void AudioMixerSinkDestroy(PAUDMIXSINK pSink, PPDMDEVINS pDevIns) 864 873 { 865 874 if (!pSink) … … 882 891 AssertRC(rc2); 883 892 884 audioMixerSinkDestroyInternal(pSink );893 audioMixerSinkDestroyInternal(pSink, pDevIns); 885 894 886 895 RTMemFree(pSink); … … 891 900 * Destroys a mixer sink. 892 901 * 893 * @param pSink Mixer sink to destroy. 894 */ 895 static void audioMixerSinkDestroyInternal(PAUDMIXSINK pSink) 902 * @param pSink Mixer sink to destroy. 903 * @param pDevIns The device instance statistics are registered with. 904 */ 905 static void audioMixerSinkDestroyInternal(PAUDMIXSINK pSink, PPDMDEVINS pDevIns) 896 906 { 897 907 AssertPtrReturnVoid(pSink); … … 902 912 RTListForEachSafe(&pSink->lstStreams, pStream, pStreamNext, AUDMIXSTREAM, Node) 903 913 { 904 /* Save a pointer to the stream to remove, as pStream 905 * will not be valid anymore after calling audioMixerSinkRemoveStreamInternal(). */ 906 PAUDMIXSTREAM pStreamToRemove = pStream; 907 908 audioMixerSinkRemoveStreamInternal(pSink, pStreamToRemove); 909 audioMixerStreamDestroyInternal(pStreamToRemove); 914 audioMixerSinkRemoveStreamInternal(pSink, pStream); 915 audioMixerStreamDestroyInternal(pStream, pDevIns); 910 916 } 911 917 … … 917 923 } 918 924 919 if (pSink->pszName) 920 { 921 RTStrFree(pSink->pszName); 922 pSink->pszName = NULL; 923 } 924 925 if (pSink->pabScratchBuf) 926 { 927 Assert(pSink->cbScratchBuf); 928 929 RTMemFree(pSink->pabScratchBuf); 930 pSink->pabScratchBuf = NULL; 931 932 pSink->cbScratchBuf = 0; 933 } 925 RTStrFree(pSink->pszName); 926 pSink->pszName = NULL; 927 928 RTMemFree(pSink->pabScratchBuf); 929 pSink->pabScratchBuf = NULL; 930 pSink->cbScratchBuf = 0; 934 931 935 932 AudioMixBufDestroy(&pSink->MixBuf); … … 1973 1970 } 1974 1971 1972 pMixStream->StatsCircBufUsed = RTCircBufUsed(pCircBuf); 1975 1973 Log3Func(("[%s] cbWritten=%RU32\n", pMixStream->pszName, cbWritten)); 1976 1974 … … 2048 2046 2049 2047 pMixStream->tsLastReadWrittenNs = RTTimeNanoTS(); 2048 pMixStream->StatsCircBufUsed = RTCircBufUsed(pCircBuf); 2050 2049 Log3Func(("[%s] Mixer stream '%s' -> cbWrittenBuf=%RU32\n", pSink->pszName, pMixStream->pszName, cbToWrite)); 2051 2050 } … … 2078 2077 2079 2078 int rc = RTCritSectEnter(&pSink->CritSect); 2080 if (RT_FAILURE(rc)) 2081 return rc; 2079 AssertRCReturn(rc, rc); 2082 2080 2083 2081 AssertMsg(pSink->fStatus & AUDMIXSINK_STS_RUNNING, … … 2090 2088 while (cbToWrite) 2091 2089 { 2092 /* First, write the data to the mixer sink's own mixing buffer. 2093 * Here the audio data can be transformed into the mixer sink's format. */ 2094 uint32_t cfWritten = 0; 2095 rc = AudioMixBufWriteCirc(&pSink->MixBuf, (uint8_t *)pvBuf + cbWritten, cbToWrite, &cfWritten); 2096 if (RT_FAILURE(rc)) 2090 /* Write the data to the mixer sink's own mixing buffer. 2091 Here the audio data is transformed into the mixer sink's format. */ 2092 uint32_t cFramesWritten = 0; 2093 rc = AudioMixBufWriteCirc(&pSink->MixBuf, (uint8_t const*)pvBuf + cbWritten, cbToWrite, &cFramesWritten); 2094 if (RT_SUCCESS(rc)) 2095 { 2096 const uint32_t cbWrittenChunk = PDMAudioPropsFramesToBytes(&pSink->PCMProps, cFramesWritten); 2097 Assert(cbToWrite >= cbWrittenChunk); 2098 cbToWrite -= cbWrittenChunk; 2099 cbWritten += cbWrittenChunk; 2100 } 2101 else 2097 2102 break; 2098 2099 const uint32_t cbWrittenChunk = PDMAudioPropsFramesToBytes(&pSink->PCMProps, cfWritten);2100 2101 Assert(cbToWrite >= cbWrittenChunk);2102 cbToWrite -= cbWrittenChunk;2103 cbWritten += cbWrittenChunk;2104 2103 } 2105 2104 … … 2112 2111 *pcbWritten = cbWritten; 2113 2112 2114 int rc2 = RTCritSectLeave(&pSink->CritSect); 2115 AssertRC(rc2); 2116 2113 RTCritSectLeave(&pSink->CritSect); 2117 2114 return rc; 2118 2115 } … … 2214 2211 * Destroys a mixer stream, internal version. 2215 2212 * 2216 * @param pMixStream Mixer stream to destroy. 2217 */ 2218 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pMixStream) 2213 * @param pMixStream Mixer stream to destroy. 2214 * @param pDevIns The device instance the statistics are registered with. 2215 */ 2216 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pMixStream, PPDMDEVINS pDevIns) 2219 2217 { 2220 2218 AssertPtrReturnVoid(pMixStream); … … 2235 2233 } 2236 2234 2237 if (pMixStream->pszName) 2238 { 2239 RTStrFree(pMixStream->pszName); 2240 pMixStream->pszName = NULL; 2241 } 2235 if (pMixStream->pszStatPrefix) 2236 { 2237 PDMDevHlpSTAMDeregisterByPrefix(pDevIns, pMixStream->pszStatPrefix); 2238 RTStrFree(pMixStream->pszStatPrefix); 2239 pMixStream->pszStatPrefix = NULL; 2240 } 2241 2242 RTStrFree(pMixStream->pszName); 2243 pMixStream->pszName = NULL; 2242 2244 2243 2245 if (pMixStream->pCircBuf) … … 2257 2259 * Destroys a mixer stream. 2258 2260 * 2259 * @param pMixStream Mixer stream to destroy. 2260 */ 2261 void AudioMixerStreamDestroy(PAUDMIXSTREAM pMixStream) 2261 * @param pMixStream Mixer stream to destroy. 2262 * @param pDevIns The device instance statistics are registered with. 2263 */ 2264 void AudioMixerStreamDestroy(PAUDMIXSTREAM pMixStream, PPDMDEVINS pDevIns) 2262 2265 { 2263 2266 if (!pMixStream) … … 2290 2293 if (RT_SUCCESS(rc2)) 2291 2294 { 2292 audioMixerStreamDestroyInternal(pMixStream );2295 audioMixerStreamDestroyInternal(pMixStream, pDevIns); 2293 2296 pMixStream = NULL; 2294 2297 } -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r87852 r88307 86 86 /** Name of this stream. */ 87 87 char *pszName; 88 /** The statistics prefix. */ 89 char *pszStatPrefix; 88 90 /** The streams's critical section. */ 89 91 RTCRITSECT CritSect; … … 103 105 * holding (raw) device audio data. */ 104 106 PRTCIRCBUF pCircBuf; 107 /** Stats: Number of bytes used in the circular buffer. */ 108 uint32_t StatsCircBufUsed; 109 /** Stats: Size of circular buffer. */ 110 uint32_t StatsCircBufSize; 105 111 } AUDMIXSTREAM, *PAUDMIXSTREAM; 106 112 … … 259 265 260 266 int AudioMixerCreate(const char *pszName, uint32_t fFlags, PAUDIOMIXER *ppMixer); 261 int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, P AUDMIXSINK *ppSink);262 void AudioMixerDestroy(PAUDIOMIXER pMixer );267 int AudioMixerCreateSink(PAUDIOMIXER pMixer, const char *pszName, AUDMIXSINKDIR enmDir, PPDMDEVINS pDevIns, PAUDMIXSINK *ppSink); 268 void AudioMixerDestroy(PAUDIOMIXER pMixer, PPDMDEVINS pDevIns); 263 269 void AudioMixerInvalidate(PAUDIOMIXER pMixer); 264 270 void AudioMixerRemoveSink(PAUDIOMIXER pMixer, PAUDMIXSINK pSink); … … 267 273 268 274 int AudioMixerSinkAddStream(PAUDMIXSINK pSink, PAUDMIXSTREAM pStream); 269 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOSTREAMCFG pCfg, AUDMIXSTREAMFLAGS fFlags, PAUDMIXSTREAM *ppStream); 275 int AudioMixerSinkCreateStream(PAUDMIXSINK pSink, PPDMIAUDIOCONNECTOR pConnector, PPDMAUDIOSTREAMCFG pCfg, 276 AUDMIXSTREAMFLAGS fFlags, PPDMDEVINS pDevIns, PAUDMIXSTREAM *ppStream); 270 277 int AudioMixerSinkCtl(PAUDMIXSINK pSink, AUDMIXSINKCMD enmCmd); 271 void AudioMixerSinkDestroy(PAUDMIXSINK pSink );278 void AudioMixerSinkDestroy(PAUDMIXSINK pSink, PPDMDEVINS pDevIns); 272 279 uint32_t AudioMixerSinkGetReadable(PAUDMIXSINK pSink); 273 280 uint32_t AudioMixerSinkGetWritable(PAUDMIXSINK pSink); … … 291 298 292 299 int AudioMixerStreamCtl(PAUDMIXSTREAM pStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl); 293 void AudioMixerStreamDestroy(PAUDMIXSTREAM pStream );300 void AudioMixerStreamDestroy(PAUDMIXSTREAM pStream, PPDMDEVINS pDevIns); 294 301 bool AudioMixerStreamIsActive(PAUDMIXSTREAM pStream); 295 302 bool AudioMixerStreamIsValid(PAUDMIXSTREAM pStream); -
trunk/src/VBox/Devices/Audio/DevHda.cpp
r88300 r88307 360 360 */ 361 361 #ifdef IN_RING3 362 static int hdaR3MixerAddDrvStream(P AUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PHDADRIVER pDrv);362 static int hdaR3MixerAddDrvStream(PPDMDEVINS pDevIns, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PHDADRIVER pDrv); 363 363 #endif 364 364 /** @} */ … … 2185 2185 * 2186 2186 * @returns VBox status code. 2187 * @param pDevIns The HDA device instance. 2187 2188 * @param pThisCC The ring-3 HDA device state. 2188 2189 * @param pDrv HDA driver to add. 2189 2190 */ 2190 static int hdaR3MixerAddDrv(P HDASTATER3 pThisCC, PHDADRIVER pDrv)2191 static int hdaR3MixerAddDrv(PPDMDEVINS pDevIns, PHDASTATER3 pThisCC, PHDADRIVER pDrv) 2191 2192 { 2192 2193 int rc = VINF_SUCCESS; … … 2196 2197 && AudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 2197 2198 { 2198 int rc2 = hdaR3MixerAddDrvStream(p ThisCC->SinkLineIn.pMixSink, &pStream->State.Cfg, pDrv);2199 int rc2 = hdaR3MixerAddDrvStream(pDevIns, pThisCC->SinkLineIn.pMixSink, &pStream->State.Cfg, pDrv); 2199 2200 if (RT_SUCCESS(rc)) 2200 2201 rc = rc2; … … 2206 2207 && AudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 2207 2208 { 2208 int rc2 = hdaR3MixerAddDrvStream(p ThisCC->SinkMicIn.pMixSink, &pStream->State.Cfg, pDrv);2209 int rc2 = hdaR3MixerAddDrvStream(pDevIns, pThisCC->SinkMicIn.pMixSink, &pStream->State.Cfg, pDrv); 2209 2210 if (RT_SUCCESS(rc)) 2210 2211 rc = rc2; … … 2216 2217 && AudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 2217 2218 { 2218 int rc2 = hdaR3MixerAddDrvStream(p ThisCC->SinkFront.pMixSink, &pStream->State.Cfg, pDrv);2219 int rc2 = hdaR3MixerAddDrvStream(pDevIns, pThisCC->SinkFront.pMixSink, &pStream->State.Cfg, pDrv); 2219 2220 if (RT_SUCCESS(rc)) 2220 2221 rc = rc2; … … 2226 2227 && AudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 2227 2228 { 2228 int rc2 = hdaR3MixerAddDrvStream(p ThisCC->SinkCenterLFE.pMixSink, &pStream->State.Cfg, pDrv);2229 int rc2 = hdaR3MixerAddDrvStream(pDevIns, pThisCC->SinkCenterLFE.pMixSink, &pStream->State.Cfg, pDrv); 2229 2230 if (RT_SUCCESS(rc)) 2230 2231 rc = rc2; … … 2235 2236 && AudioHlpStreamCfgIsValid(&pStream->State.Cfg)) 2236 2237 { 2237 int rc2 = hdaR3MixerAddDrvStream(p ThisCC->SinkRear.pMixSink, &pStream->State.Cfg, pDrv);2238 int rc2 = hdaR3MixerAddDrvStream(pDevIns, pThisCC->SinkRear.pMixSink, &pStream->State.Cfg, pDrv); 2238 2239 if (RT_SUCCESS(rc)) 2239 2240 rc = rc2; … … 2248 2249 * associated streams. 2249 2250 * 2250 * @param pThisCC The ring-3 HDA device state. 2251 * @param pDrv HDA driver to remove. 2252 */ 2253 static void hdaR3MixerRemoveDrv(PHDASTATER3 pThisCC, PHDADRIVER pDrv) 2251 * @param pDevIns The device instance. 2252 * @param pThisCC The ring-3 HDA device state. 2253 * @param pDrv HDA driver to remove. 2254 */ 2255 static void hdaR3MixerRemoveDrv(PPDMDEVINS pDevIns, PHDASTATER3 pThisCC, PHDADRIVER pDrv) 2254 2256 { 2255 2257 AssertPtrReturnVoid(pDrv); … … 2261 2263 2262 2264 AudioMixerSinkRemoveStream(pThisCC->SinkLineIn.pMixSink, pDrv->LineIn.pMixStrm); 2263 AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm );2265 AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm, pDevIns); 2264 2266 pDrv->LineIn.pMixStrm = NULL; 2265 2267 } … … 2272 2274 2273 2275 AudioMixerSinkRemoveStream(pThisCC->SinkMicIn.pMixSink, pDrv->MicIn.pMixStrm); 2274 AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm );2276 AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm, pDevIns); 2275 2277 pDrv->MicIn.pMixStrm = NULL; 2276 2278 } … … 2280 2282 { 2281 2283 AudioMixerSinkRemoveStream(pThisCC->SinkFront.pMixSink, pDrv->Front.pMixStrm); 2282 AudioMixerStreamDestroy(pDrv->Front.pMixStrm );2284 AudioMixerStreamDestroy(pDrv->Front.pMixStrm, pDevIns); 2283 2285 pDrv->Front.pMixStrm = NULL; 2284 2286 } … … 2288 2290 { 2289 2291 AudioMixerSinkRemoveStream(pThisCC->SinkCenterLFE.pMixSink, pDrv->CenterLFE.pMixStrm); 2290 AudioMixerStreamDestroy(pDrv->CenterLFE.pMixStrm );2292 AudioMixerStreamDestroy(pDrv->CenterLFE.pMixStrm, pDevIns); 2291 2293 pDrv->CenterLFE.pMixStrm = NULL; 2292 2294 } … … 2295 2297 { 2296 2298 AudioMixerSinkRemoveStream(pThisCC->SinkRear.pMixSink, pDrv->Rear.pMixStrm); 2297 AudioMixerStreamDestroy(pDrv->Rear.pMixStrm );2299 AudioMixerStreamDestroy(pDrv->Rear.pMixStrm, pDevIns); 2298 2300 pDrv->Rear.pMixStrm = NULL; 2299 2301 } … … 2307 2309 * 2308 2310 * @returns VBox status code (ignored by caller). 2309 * @param pMixSink Audio mixer sink to add audio streams to. 2310 * @param pCfg Audio stream configuration to use for the audio streams to add. 2311 * @param pDrv Driver stream to add. 2312 */ 2313 static int hdaR3MixerAddDrvStream(PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PHDADRIVER pDrv) 2311 * @param pDevIns The HDA device instance. 2312 * @param pMixSink Audio mixer sink to add audio streams to. 2313 * @param pCfg Audio stream configuration to use for the audio 2314 * streams to add. 2315 * @param pDrv Driver stream to add. 2316 */ 2317 static int hdaR3MixerAddDrvStream(PPDMDEVINS pDevIns, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PHDADRIVER pDrv) 2314 2318 { 2315 2319 AssertPtrReturn(pMixSink, VERR_INVALID_POINTER); … … 2318 2322 LogFunc(("szSink=%s, szStream=%s, cChannels=%RU8\n", pMixSink->pszName, pCfg->szName, PDMAudioPropsChannels(&pCfg->Props))); 2319 2323 2320 PPDMAUDIOSTREAMCFG pStreamCfg = PDMAudioStrmCfgDup(pCfg); 2321 if (!pStreamCfg) 2322 return VERR_NO_MEMORY; 2323 2324 LogFunc(("[LUN#%RU8] %s\n", pDrv->uLUN, pStreamCfg->szName)); 2325 2326 int rc = VINF_SUCCESS; 2327 2324 /* 2325 * Get the matching stream driver. 2326 */ 2328 2327 PHDADRIVERSTREAM pDrvStream = NULL; 2329 2330 if (pStreamCfg->enmDir == PDMAUDIODIR_IN) 2331 { 2332 LogFunc(("enmRecSource=%d\n", pStreamCfg->u.enmSrc)); 2333 2334 switch (pStreamCfg->u.enmSrc) 2328 if (pCfg->enmDir == PDMAUDIODIR_IN) 2329 { 2330 LogFunc(("enmSrc=%d\n", pCfg->u.enmSrc)); 2331 switch (pCfg->u.enmSrc) 2335 2332 { 2336 2333 case PDMAUDIORECSRC_LINE: … … 2343 2340 # endif 2344 2341 default: 2345 rc = VERR_NOT_SUPPORTED; 2346 break; 2347 } 2348 } 2349 else if (pStreamCfg->enmDir == PDMAUDIODIR_OUT) 2350 { 2351 LogFunc(("enmPlaybackDest=%d\n", pStreamCfg->u.enmDst)); 2352 2353 switch (pStreamCfg->u.enmDst) 2342 LogFunc(("returns VERR_NOT_SUPPORTED - enmSrc=%d\n", pCfg->u.enmSrc)); 2343 return VERR_NOT_SUPPORTED; 2344 } 2345 } 2346 else if (pCfg->enmDir == PDMAUDIODIR_OUT) 2347 { 2348 LogFunc(("enmDst=%d %s\n", pCfg->u.enmDst, PDMAudioPlaybackDstGetName(pCfg->u.enmDst))); 2349 switch (pCfg->u.enmDst) 2354 2350 { 2355 2351 case PDMAUDIOPLAYBACKDST_FRONT: … … 2365 2361 # endif 2366 2362 default: 2367 rc = VERR_NOT_SUPPORTED;2368 break;2363 LogFunc(("returns VERR_NOT_SUPPORTED - enmDst=%d %s\n", pCfg->u.enmDst, PDMAudioPlaybackDstGetName(pCfg->u.enmDst))); 2364 return VERR_NOT_SUPPORTED; 2369 2365 } 2370 2366 } 2371 2367 else 2372 rc = VERR_NOT_SUPPORTED; 2373 2368 AssertFailedReturn(VERR_NOT_SUPPORTED); 2369 2370 PDMAUDIOSTREAMCFG StreamCfg; /** @todo r=bird: Why do we need to copy this? (We used to duplicate it originally.) */ 2371 PDMAudioStrmCfgCopy(&StreamCfg, pCfg); 2372 2373 LogFunc(("[LUN#%RU8] %s\n", pDrv->uLUN, StreamCfg.szName)); 2374 2375 AssertPtr(pDrvStream); 2376 AssertMsg(pDrvStream->pMixStrm == NULL, ("[LUN#%RU8] Driver stream already present when it must not\n", pDrv->uLUN)); 2377 2378 PAUDMIXSTREAM pMixStrm = NULL; 2379 int rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, &StreamCfg, 0 /* fFlags */, pDevIns, &pMixStrm); 2380 LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, StreamCfg.szName, rc)); 2374 2381 if (RT_SUCCESS(rc)) 2375 2382 { 2376 AssertPtr(pDrvStream); 2377 AssertMsg(pDrvStream->pMixStrm == NULL, ("[LUN#%RU8] Driver stream already present when it must not\n", pDrv->uLUN)); 2378 2379 PAUDMIXSTREAM pMixStrm; 2380 rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */, &pMixStrm); 2381 LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); 2383 rc = AudioMixerSinkAddStream(pMixSink, pMixStrm); 2384 LogFlowFunc(("LUN#%RU8: Added stream \"%s\" to sink, rc=%Rrc\n", pDrv->uLUN, StreamCfg.szName, rc)); 2382 2385 if (RT_SUCCESS(rc)) 2383 2386 { 2384 rc = AudioMixerSinkAddStream(pMixSink, pMixStrm); 2385 LogFlowFunc(("LUN#%RU8: Added stream \"%s\" to sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); 2386 if (RT_SUCCESS(rc)) 2387 /* If this is an input stream, always set the latest (added) stream 2388 * as the recording source. */ 2389 /** @todo Make the recording source dynamic (CFGM?). */ 2390 if (StreamCfg.enmDir == PDMAUDIODIR_IN) 2387 2391 { 2388 /* If this is an input stream, always set the latest (added) stream 2389 * as the recording source. */ 2390 /** @todo Make the recording source dynamic (CFGM?). */ 2391 if (pStreamCfg->enmDir == PDMAUDIODIR_IN) 2392 PDMAUDIOBACKENDCFG Cfg; 2393 rc = pDrv->pConnector->pfnGetConfig(pDrv->pConnector, &Cfg); 2394 if (RT_SUCCESS(rc)) 2392 2395 { 2393 PDMAUDIOBACKENDCFG Cfg; 2394 rc = pDrv->pConnector->pfnGetConfig(pDrv->pConnector, &Cfg); 2395 if (RT_SUCCESS(rc)) 2396 if (Cfg.cMaxStreamsIn) /* At least one input source available? */ 2396 2397 { 2397 if (Cfg.cMaxStreamsIn) /* At least one input source available? */ 2398 { 2399 rc = AudioMixerSinkSetRecordingSource(pMixSink, pMixStrm); 2400 LogFlowFunc(("LUN#%RU8: Recording source for '%s' -> '%s', rc=%Rrc\n", 2401 pDrv->uLUN, pStreamCfg->szName, Cfg.szName, rc)); 2402 2403 if (RT_SUCCESS(rc)) 2404 LogRel(("HDA: Set recording source for '%s' to '%s'\n", 2405 pStreamCfg->szName, Cfg.szName)); 2406 } 2407 else 2408 LogRel(("HDA: Backend '%s' currently is not offering any recording source for '%s'\n", 2409 Cfg.szName, pStreamCfg->szName)); 2398 rc = AudioMixerSinkSetRecordingSource(pMixSink, pMixStrm); 2399 LogFlowFunc(("LUN#%RU8: Recording source for '%s' -> '%s', rc=%Rrc\n", 2400 pDrv->uLUN, StreamCfg.szName, Cfg.szName, rc)); 2401 2402 if (RT_SUCCESS(rc)) 2403 LogRel(("HDA: Set recording source for '%s' to '%s'\n", 2404 StreamCfg.szName, Cfg.szName)); 2410 2405 } 2411 else if (RT_FAILURE(rc))2412 Log Func(("LUN#%RU8: Unable to retrieve backend configuration for '%s', rc=%Rrc\n",2413 pDrv->uLUN, pStreamCfg->szName, rc));2406 else 2407 LogRel(("HDA: Backend '%s' currently is not offering any recording source for '%s'\n", 2408 Cfg.szName, StreamCfg.szName)); 2414 2409 } 2410 else if (RT_FAILURE(rc)) 2411 LogFunc(("LUN#%RU8: Unable to retrieve backend configuration for '%s', rc=%Rrc\n", 2412 pDrv->uLUN, StreamCfg.szName, rc)); 2415 2413 } 2416 2414 } 2417 2418 if (RT_SUCCESS(rc)) 2419 pDrvStream->pMixStrm = pMixStrm; 2420 } 2421 2422 PDMAudioStrmCfgFree(pStreamCfg); 2415 /** @todo r=bird: We are missing cleanup code here! */ 2416 } 2417 2418 if (RT_SUCCESS(rc)) 2419 pDrvStream->pMixStrm = pMixStrm; 2423 2420 2424 2421 LogFlowFuncLeaveRC(rc); … … 2430 2427 * 2431 2428 * @returns VBox status code. 2432 * @param pThisCC The ring-3 HDA device state. 2433 * @param pMixSink Audio mixer sink to add stream to. 2434 * @param pCfg Audio stream configuration to use for the audio streams to add. 2435 */ 2436 static int hdaR3MixerAddDrvStreams(PHDASTATER3 pThisCC, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg) 2429 * @param pDevIns The HDA device instance. 2430 * @param pThisCC The ring-3 HDA device state. 2431 * @param pMixSink Audio mixer sink to add stream to. 2432 * @param pCfg Audio stream configuration to use for the audio streams 2433 * to add. 2434 */ 2435 static int hdaR3MixerAddDrvStreams(PPDMDEVINS pDevIns, PHDASTATER3 pThisCC, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg) 2437 2436 { 2438 2437 AssertPtrReturn(pMixSink, VERR_INVALID_POINTER); … … 2445 2444 2446 2445 int rc = AudioMixerSinkSetFormat(pMixSink, &pCfg->Props); 2447 if (RT_FAILURE(rc)) 2448 return rc; 2449 2450 PHDADRIVER pDrv; 2451 RTListForEach(&pThisCC->lstDrv, pDrv, HDADRIVER, Node) 2452 { 2453 int rc2 = hdaR3MixerAddDrvStream(pMixSink, pCfg, pDrv); 2454 if (RT_FAILURE(rc2)) 2455 LogFunc(("Attaching stream failed with %Rrc\n", rc2)); 2456 2457 /* Do not pass failure to rc here, as there might be drivers which aren't 2458 * configured / ready yet. */ 2459 } 2460 2446 if (RT_SUCCESS(rc)) 2447 { 2448 PHDADRIVER pDrv; 2449 RTListForEach(&pThisCC->lstDrv, pDrv, HDADRIVER, Node) 2450 { 2451 int rc2 = hdaR3MixerAddDrvStream(pDevIns, pMixSink, pCfg, pDrv); 2452 if (RT_FAILURE(rc2)) 2453 LogFunc(("Attaching stream failed with %Rrc\n", rc2)); 2454 2455 /* Do not pass failure to rc here, as there might be drivers which aren't 2456 * configured / ready yet. */ 2457 } 2458 } 2461 2459 return rc; 2462 2460 } … … 2474 2472 if (pSink) 2475 2473 { 2476 rc = hdaR3MixerAddDrvStreams(p ThisCC, pSink->pMixSink, pCfg);2474 rc = hdaR3MixerAddDrvStreams(pDevIns, pThisCC, pSink->pMixSink, pCfg); 2477 2475 2478 2476 AssertPtr(pSink->pMixSink); … … 2541 2539 { 2542 2540 AudioMixerSinkRemoveStream(pSink->pMixSink, pMixStream); 2543 AudioMixerStreamDestroy(pMixStream );2541 AudioMixerStreamDestroy(pMixStream, pDevIns); 2544 2542 2545 2543 pMixStream = NULL; … … 3453 3451 AssertRCReturn(rc, rc); 3454 3452 3455 uint32_t cbCircBuf Size= 0;3453 uint32_t cbCircBuf = 0; 3456 3454 uint32_t cbCircBufUsed = 0; 3457 3455 3458 3456 if (pStreamR3->State.pCircBuf) 3459 3457 { 3460 cbCircBuf Size= (uint32_t)RTCircBufSize(pStreamR3->State.pCircBuf);3458 cbCircBuf = (uint32_t)RTCircBufSize(pStreamR3->State.pCircBuf); 3461 3459 cbCircBufUsed = (uint32_t)RTCircBufUsed(pStreamR3->State.pCircBuf); 3462 3460 } 3463 3461 3464 rc = pHlp->pfnSSMPutU32(pSSM, cbCircBufSize); 3465 AssertRCReturn(rc, rc); 3466 3462 pHlp->pfnSSMPutU32(pSSM, cbCircBuf); 3467 3463 rc = pHlp->pfnSSMPutU32(pSSM, cbCircBufUsed); 3468 3464 AssertRCReturn(rc, rc); … … 4045 4041 * Load internal (FIFO) buffer. 4046 4042 */ 4047 uint32_t cbCircBuf Size= 0;4048 pHlp->pfnSSMGetU32(pSSM, &cbCircBuf Size); /* cbCircBuf */4043 uint32_t cbCircBuf = 0; 4044 pHlp->pfnSSMGetU32(pSSM, &cbCircBuf); /* cbCircBuf */ 4049 4045 uint32_t cbCircBufUsed = 0; 4050 4046 rc = pHlp->pfnSSMGetU32(pSSM, &cbCircBufUsed); /* cbCircBuf */ 4051 4047 AssertRCReturn(rc, rc); 4052 4048 4053 if (cbCircBuf Size) /* If 0, skip the buffer. */4049 if (cbCircBuf) /* If 0, skip the buffer. */ 4054 4050 { 4055 4051 /* Paranoia. */ 4056 AssertLogRelMsgReturn(cbCircBuf Size<= _32M,4052 AssertLogRelMsgReturn(cbCircBuf <= _32M, 4057 4053 ("HDA: Saved state contains bogus DMA buffer size (%RU32) for stream #%RU8", 4058 cbCircBuf Size, idStream),4054 cbCircBuf, idStream), 4059 4055 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 4060 AssertLogRelMsgReturn(cbCircBufUsed <= cbCircBuf Size,4056 AssertLogRelMsgReturn(cbCircBufUsed <= cbCircBuf, 4061 4057 ("HDA: Saved state contains invalid DMA buffer usage (%RU32/%RU32) for stream #%RU8", 4062 cbCircBufUsed, cbCircBuf Size, idStream),4058 cbCircBufUsed, cbCircBuf, idStream), 4063 4059 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 4064 4060 4065 4061 /* Do we need to cre-create the circular buffer do fit the data size? */ 4066 4062 if ( pStreamR3->State.pCircBuf 4067 && cbCircBuf Size!= (uint32_t)RTCircBufSize(pStreamR3->State.pCircBuf))4063 && cbCircBuf != (uint32_t)RTCircBufSize(pStreamR3->State.pCircBuf)) 4068 4064 { 4069 4065 RTCircBufDestroy(pStreamR3->State.pCircBuf); … … 4071 4067 } 4072 4068 4073 rc = RTCircBufCreate(&pStreamR3->State.pCircBuf, cbCircBuf Size);4069 rc = RTCircBufCreate(&pStreamR3->State.pCircBuf, cbCircBuf); 4074 4070 AssertRCReturn(rc, rc); 4071 pStreamR3->State.StatDmaBufSize = cbCircBuf; 4075 4072 4076 4073 if (cbCircBufUsed) … … 4524 4521 * 4525 4522 * @returns VBox status code. 4523 * @param pDevIns The device instance. 4526 4524 * @param pThisCC The ring-3 HDA device state. 4527 4525 * @param pDrv Driver to detach from device. 4528 4526 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 4529 4527 */ 4530 static int hdaR3DetachInternal(P HDASTATER3 pThisCC, PHDADRIVER pDrv, uint32_t fFlags)4528 static int hdaR3DetachInternal(PPDMDEVINS pDevIns, PHDASTATER3 pThisCC, PHDADRIVER pDrv, uint32_t fFlags) 4531 4529 { 4532 4530 RT_NOREF(fFlags); … … 4534 4532 /* First, remove the driver from our list and destory it's associated streams. 4535 4533 * This also will un-set the driver as a recording source (if associated). */ 4536 hdaR3MixerRemoveDrv(p ThisCC, pDrv);4534 hdaR3MixerRemoveDrv(pDevIns, pThisCC, pDrv); 4537 4535 4538 4536 /* Next, search backwards for a capable (attached) driver which now will be the … … 4589 4587 int rc2 = hdaR3AttachInternal(pDevIns, pThis, pThisCC, uLUN, fFlags, &pDrv); 4590 4588 if (RT_SUCCESS(rc2)) 4591 rc2 = hdaR3MixerAddDrv(p ThisCC, pDrv);4589 rc2 = hdaR3MixerAddDrv(pDevIns, pThisCC, pDrv); 4592 4590 4593 4591 if (RT_FAILURE(rc2)) … … 4616 4614 if (pDrv->uLUN == uLUN) 4617 4615 { 4618 int rc2 = hdaR3DetachInternal(p ThisCC, pDrv, fFlags);4616 int rc2 = hdaR3DetachInternal(pDevIns, pThisCC, pDrv, fFlags); 4619 4617 if (RT_SUCCESS(rc2)) 4620 4618 { … … 4622 4620 pDrv = NULL; 4623 4621 } 4624 4625 4622 break; 4626 4623 } … … 4654 4651 if (pThisCC->pMixer) 4655 4652 { 4656 AudioMixerDestroy(pThisCC->pMixer );4653 AudioMixerDestroy(pThisCC->pMixer, pDevIns); 4657 4654 pThisCC->pMixer = NULL; 4658 4655 } … … 5022 5019 */ 5023 5020 # ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND 5024 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Playback] Front", AUDMIXSINKDIR_OUTPUT, &pThisCC->SinkFront.pMixSink); 5021 rc = AudioMixerCreateSink(pThisCC->pMixer, "Front", 5022 AUDMIXSINKDIR_OUTPUT, pDevIns, &pThisCC->SinkFront.pMixSink); 5025 5023 AssertRCReturn(rc, rc); 5026 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Playback] Center / Subwoofer", AUDMIXSINKDIR_OUTPUT, &pThisCC->SinkCenterLFE.pMixSink); 5024 rc = AudioMixerCreateSink(pThisCC->pMixer, "Center+Subwoofer", 5025 AUDMIXSINKDIR_OUTPUT, pDevIns, &pThisCC->SinkCenterLFE.pMixSink); 5027 5026 AssertRCReturn(rc, rc); 5028 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Playback] Rear", AUDMIXSINKDIR_OUTPUT, &pThisCC->SinkRear.pMixSink); 5027 rc = AudioMixerCreateSink(pThisCC->pMixer, "Rear", 5028 AUDMIXSINKDIR_OUTPUT, pDevIns, &pThisCC->SinkRear.pMixSink); 5029 5029 AssertRCReturn(rc, rc); 5030 5030 # else 5031 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThisCC->SinkFront.pMixSink); 5031 rc = AudioMixerCreateSink(pThisCC->pMixer, "PCM Output", 5032 AUDMIXSINKDIR_OUTPUT, pDevIns, &pThisCC->SinkFront.pMixSink); 5032 5033 AssertRCReturn(rc, rc); 5033 5034 # endif /* VBOX_WITH_AUDIO_HDA_51_SURROUND */ … … 5036 5037 * Add mixer input sinks. 5037 5038 */ 5038 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Recording] Line In", AUDMIXSINKDIR_INPUT, &pThisCC->SinkLineIn.pMixSink); 5039 rc = AudioMixerCreateSink(pThisCC->pMixer, "Line In", 5040 AUDMIXSINKDIR_INPUT, pDevIns, &pThisCC->SinkLineIn.pMixSink); 5039 5041 AssertRCReturn(rc, rc); 5040 5042 # ifdef VBOX_WITH_AUDIO_HDA_MIC_IN 5041 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Recording] Microphone In", AUDMIXSINKDIR_INPUT, &pThisCC->SinkMicIn.pMixSink); 5043 rc = AudioMixerCreateSink(pThisCC->pMixer, "Microphone In", 5044 AUDMIXSINKDIR_INPUT, pDevIns, &pThisCC->SinkMicIn.pMixSink); 5042 5045 AssertRCReturn(rc, rc); 5043 5046 # endif … … 5357 5360 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->aStreams[idxStream].State.Mapping.GuestProps.cbFrame, STAMTYPE_U8, STAMVISIBILITY_USED, STAMUNIT_BYTES, 5358 5361 "The number of channels.", "Stream%u/Cfg/FrameSize-Guest", idxStream); 5359 #if 0 /** @todo this would require some callback */5362 #if 0 /** @todo this would require some callback or expansion. */ 5360 5363 PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aStreams[idxStream].State.Cfg.Props.cChannelsX, STAMTYPE_U8, STAMVISIBILITY_USED, STAMUNIT_BYTES, 5361 5364 "The number of channels.", "Stream%u/Cfg/Channels-Host", idxStream); … … 5365 5368 "The size of a sample (per channel).", "Stream%u/Cfg/cbSample", idxStream); 5366 5369 #endif 5370 5371 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->aStreams[idxStream].State.StatDmaBufSize, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_BYTES, 5372 "Size of the internal DMA buffer.", "Stream%u/DMABufSize", idxStream); 5373 PDMDevHlpSTAMRegisterF(pDevIns, &pThisCC->aStreams[idxStream].State.StatDmaBufUsed, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_BYTES, 5374 "Number of bytes used in the internal DMA buffer.", "Stream%u/DMABufUsed", idxStream); 5367 5375 } 5368 5376 -
trunk/src/VBox/Devices/Audio/DevHdaStream.cpp
r88300 r88307 191 191 RTCircBufDestroy(pStreamR3->State.pCircBuf); 192 192 pStreamR3->State.pCircBuf = NULL; 193 pStreamR3->State.StatDmaBufSize = 0; 194 pStreamR3->State.StatDmaBufUsed = 0; 193 195 } 194 196 … … 692 694 RTCircBufDestroy(pStreamR3->State.pCircBuf); 693 695 pStreamR3->State.pCircBuf = NULL; 696 pStreamR3->State.StatDmaBufSize = 0; 697 pStreamR3->State.StatDmaBufUsed = 0; 694 698 } 695 699 pStreamR3->State.offWrite = 0; … … 750 754 if (RT_SUCCESS(rc)) 751 755 { 756 pStreamR3->State.StatDmaBufSize = cbCircBuf; 757 752 758 /* 753 759 * Forward the timer frequency hint to TM as well for better accuracy on … … 1216 1222 * @param pDevIns The device instance. 1217 1223 * @param pThis The shared HDA device state. 1218 * @param pStreamShared HDA stream to update (shared). 1219 */ 1220 DECLINLINE(void) hdaR3StreamDoDmaEpilogue(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStreamShared) 1224 * @param pStreamShared The HDA stream (shared). 1225 * @param pStreamR3 The HDA stream (ring-3). 1226 */ 1227 DECLINLINE(void) hdaR3StreamDoDmaEpilogue(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3) 1221 1228 { 1222 1229 /* … … 1232 1239 */ 1233 1240 pStreamShared->State.tsTransferLast = PDMDevHlpTimerGet(pDevIns, pStreamShared->hTimer); 1241 1242 /* 1243 * Update the buffer statistics. 1244 */ 1245 pStreamR3->State.StatDmaBufUsed = RTCircBufUsed(pStreamR3->State.pCircBuf); 1234 1246 } 1235 1247 … … 1513 1525 * Common epilogue. 1514 1526 */ 1515 hdaR3StreamDoDmaEpilogue(pDevIns, pThis, pStreamShared );1527 hdaR3StreamDoDmaEpilogue(pDevIns, pThis, pStreamShared, pStreamR3); 1516 1528 1517 1529 /* … … 1596 1608 cbSinkReadable -= cbRead; 1597 1609 } 1610 1611 /* Update buffer stats. */ 1612 pStreamR3->State.StatDmaBufUsed = RTCircBufUsed(pStreamR3->State.pCircBuf); 1598 1613 } 1599 1614 … … 1797 1812 * Common epilogue. 1798 1813 */ 1799 hdaR3StreamDoDmaEpilogue(pDevIns, pThis, pStreamShared );1814 hdaR3StreamDoDmaEpilogue(pDevIns, pThis, pStreamShared, pStreamR3); 1800 1815 1801 1816 /* … … 1863 1878 } 1864 1879 1880 /* Update buffer stats. */ 1881 pStreamR3->State.StatDmaBufUsed = RTCircBufUsed(pStreamR3->State.pCircBuf); 1882 1883 /* 1884 * Push the stuff thru the mixer jungle and down the host audio driver (backend). 1885 */ 1865 1886 int rc2 = AudioMixerSinkUpdate(pSink); 1866 1887 AssertRC(rc2); -
trunk/src/VBox/Devices/Audio/DevHdaStream.h
r88235 r88307 316 316 HDASTREAMSTATEAIO AIO; 317 317 #endif 318 /** Size of the DMA buffer (pCircBuf) in bytes. */ 319 uint32_t StatDmaBufSize; 320 /** Number of used bytes in the DMA buffer (pCircBuf). */ 321 uint32_t StatDmaBufUsed; 318 322 /** Counter for all under/overflows problems. */ 319 323 STAMCOUNTER StatDmaFlowProblems; … … 325 329 /** Debug bits. */ 326 330 HDASTREAMDEBUG Dbg; 327 uint64_t au64Alignment[ 2];331 uint64_t au64Alignment[1]; 328 332 } HDASTREAMR3; 329 333 AssertCompileSizeAlignment(HDASTREAMR3, 64); -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r88300 r88307 682 682 *********************************************************************************************************************************/ 683 683 #ifdef IN_RING3 684 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fForce); 684 static int ichac97R3StreamOpen(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, 685 PAC97STREAMR3 pStreamCC, bool fForce); 685 686 static int ichac97R3StreamClose(PAC97STREAM pStream); 686 687 static void ichac97R3StreamLock(PAC97STREAMR3 pStreamCC); … … 695 696 static DECLCALLBACK(void) ichac97R3Reset(PPDMDEVINS pDevIns); 696 697 697 static void ichac97R3MixerRemoveDrvStreams(P AC97STATER3 pThisCC, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir,698 PDMAUDIOD STSRCUNION dstSrc);698 static void ichac97R3MixerRemoveDrvStreams(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAUDMIXSINK pMixSink, 699 PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc); 699 700 700 701 # ifdef VBOX_WITH_AUDIO_AC97_ASYNC_IO … … 968 969 * 969 970 * @returns VBox status code. 970 * @param pThis The shared AC'97 state. 971 * @param pThisCC The ring-3 AC'97 state. 972 * @param pStream The AC'97 stream to enable or disable (shared 973 * state). 974 * @param pStreamCC The ring-3 stream state (matching to @a pStream). 975 * @param fEnable Whether to enable or disable the stream. 976 * 977 */ 978 static int ichac97R3StreamEnable(PAC97STATE pThis, PAC97STATER3 pThisCC, 971 * @param pDevIns The device instance. 972 * @param pThis The shared AC'97 state. 973 * @param pThisCC The ring-3 AC'97 state. 974 * @param pStream The AC'97 stream to enable or disable (shared 975 * state). 976 * @param pStreamCC The ring-3 stream state (matching to @a pStream). 977 * @param fEnable Whether to enable or disable the stream. 978 * 979 */ 980 static int ichac97R3StreamEnable(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STATER3 pThisCC, 979 981 PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fEnable) 980 982 { … … 995 997 RTCircBufReset(pStreamCC->State.pCircBuf); 996 998 997 rc = ichac97R3StreamOpen(p This, pThisCC, pStream, pStreamCC, false /* fForce */);999 rc = ichac97R3StreamOpen(pDevIns, pThis, pThisCC, pStream, pStreamCC, false /* fForce */); 998 1000 999 1001 if (RT_LIKELY(!pStreamCC->Dbg.Runtime.fEnabled)) … … 1176 1178 * Destroys all AC'97 audio streams of the device. 1177 1179 * 1178 * @param pThis The shared AC'97 state. 1179 * @param pThisCC The ring-3 AC'97 state. 1180 */ 1181 static void ichac97R3StreamsDestroy(PAC97STATE pThis, PAC97STATER3 pThisCC) 1180 * @param pDevIns The device AC'97 instance. 1181 * @param pThis The shared AC'97 state. 1182 * @param pThisCC The ring-3 AC'97 state. 1183 */ 1184 static void ichac97R3StreamsDestroy(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STATER3 pThisCC) 1182 1185 { 1183 1186 LogFlowFuncEnter(); … … 1197 1200 { 1198 1201 dstSrc.enmSrc = PDMAUDIORECSRC_LINE; 1199 ichac97R3MixerRemoveDrvStreams(p ThisCC, pThisCC->pSinkLineIn, PDMAUDIODIR_IN, dstSrc);1200 1201 AudioMixerSinkDestroy(pThisCC->pSinkLineIn );1202 ichac97R3MixerRemoveDrvStreams(pDevIns, pThisCC, pThisCC->pSinkLineIn, PDMAUDIODIR_IN, dstSrc); 1203 1204 AudioMixerSinkDestroy(pThisCC->pSinkLineIn, pDevIns); 1202 1205 pThisCC->pSinkLineIn = NULL; 1203 1206 } … … 1206 1209 { 1207 1210 dstSrc.enmSrc = PDMAUDIORECSRC_MIC; 1208 ichac97R3MixerRemoveDrvStreams(p ThisCC, pThisCC->pSinkMicIn, PDMAUDIODIR_IN, dstSrc);1209 1210 AudioMixerSinkDestroy(pThisCC->pSinkMicIn );1211 ichac97R3MixerRemoveDrvStreams(pDevIns, pThisCC, pThisCC->pSinkMicIn, PDMAUDIODIR_IN, dstSrc); 1212 1213 AudioMixerSinkDestroy(pThisCC->pSinkMicIn, pDevIns); 1211 1214 pThisCC->pSinkMicIn = NULL; 1212 1215 } … … 1215 1218 { 1216 1219 dstSrc.enmDst = PDMAUDIOPLAYBACKDST_FRONT; 1217 ichac97R3MixerRemoveDrvStreams(p ThisCC, pThisCC->pSinkOut, PDMAUDIODIR_OUT, dstSrc);1218 1219 AudioMixerSinkDestroy(pThisCC->pSinkOut );1220 ichac97R3MixerRemoveDrvStreams(pDevIns, pThisCC, pThisCC->pSinkOut, PDMAUDIODIR_OUT, dstSrc); 1221 1222 AudioMixerSinkDestroy(pThisCC->pSinkOut, pDevIns); 1220 1223 pThisCC->pSinkOut = NULL; 1221 1224 } … … 1839 1842 * 1840 1843 * @returns VBox status code. 1841 * @param pMixSink Mixer sink to add driver stream to. 1842 * @param pCfg Stream configuration to use. 1843 * @param pDrv Driver stream to add. 1844 */ 1845 static int ichac97R3MixerAddDrvStream(PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv) 1844 * @param pDevIns The device instance. 1845 * @param pMixSink Mixer sink to add driver stream to. 1846 * @param pCfg Stream configuration to use. 1847 * @param pDrv Driver stream to add. 1848 */ 1849 static int ichac97R3MixerAddDrvStream(PPDMDEVINS pDevIns, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg, PAC97DRIVER pDrv) 1846 1850 { 1847 1851 AssertPtrReturn(pMixSink, VERR_INVALID_POINTER); … … 1867 1871 1868 1872 PAUDMIXSTREAM pMixStrm; 1869 rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */, &pMixStrm);1873 rc = AudioMixerSinkCreateStream(pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */, pDevIns, &pMixStrm); 1870 1874 LogFlowFunc(("LUN#%RU8: Created stream \"%s\" for sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName, rc)); 1871 1875 if (RT_SUCCESS(rc)) … … 1913 1917 * STAM when 48000Hz is configured right afterwards. */ 1914 1918 if (RT_FAILURE(rc)) 1915 AudioMixerStreamDestroy(pMixStrm );1919 AudioMixerStreamDestroy(pMixStrm, pDevIns); 1916 1920 } 1917 1921 … … 1932 1936 * 1933 1937 * @returns VBox status code. 1934 * @param pThisCC The ring-3 AC'97 state. 1935 * @param pMixSink Mixer sink to add stream to. 1936 * @param pCfg Stream configuration to use. 1937 */ 1938 static int ichac97R3MixerAddDrvStreams(PAC97STATER3 pThisCC, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg) 1938 * @param pDevIns The device instance. 1939 * @param pThisCC The ring-3 AC'97 state. 1940 * @param pMixSink Mixer sink to add stream to. 1941 * @param pCfg Stream configuration to use. 1942 */ 1943 static int ichac97R3MixerAddDrvStreams(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAUDMIXSINK pMixSink, PPDMAUDIOSTREAMCFG pCfg) 1939 1944 { 1940 1945 AssertPtrReturn(pMixSink, VERR_INVALID_POINTER); … … 1950 1955 RTListForEach(&pThisCC->lstDrv, pDrv, AC97DRIVER, Node) 1951 1956 { 1952 int rc2 = ichac97R3MixerAddDrvStream(p MixSink, pCfg, pDrv);1957 int rc2 = ichac97R3MixerAddDrvStream(pDevIns, pMixSink, pCfg, pDrv); 1953 1958 if (RT_FAILURE(rc2)) 1954 1959 LogFunc(("Attaching stream failed with %Rrc\n", rc2)); … … 1966 1971 * 1967 1972 * @returns VBox status code. 1973 * @param pDevIns The device instance. 1968 1974 * @param pThisCC The ring-3 AC'97 device state. 1969 1975 * @param pDrv The AC'97 driver to add. 1970 1976 */ 1971 static int ichac97R3MixerAddDrv(P AC97STATER3 pThisCC, PAC97DRIVER pDrv)1977 static int ichac97R3MixerAddDrv(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAC97DRIVER pDrv) 1972 1978 { 1973 1979 int rc = VINF_SUCCESS; 1974 1980 1975 1981 if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg)) 1976 rc = ichac97R3MixerAddDrvStream(pThisCC->pSinkLineIn, &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg, pDrv); 1982 rc = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkLineIn, 1983 &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX].State.Cfg, pDrv); 1977 1984 1978 1985 if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg)) 1979 1986 { 1980 int rc2 = ichac97R3MixerAddDrvStream(pThisCC->pSinkOut, &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg, pDrv); 1987 int rc2 = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkOut, 1988 &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX].State.Cfg, pDrv); 1981 1989 if (RT_SUCCESS(rc)) 1982 1990 rc = rc2; … … 1985 1993 if (AudioHlpStreamCfgIsValid(&pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg)) 1986 1994 { 1987 int rc2 = ichac97R3MixerAddDrvStream(pThisCC->pSinkMicIn, &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg, pDrv); 1995 int rc2 = ichac97R3MixerAddDrvStream(pDevIns, pThisCC->pSinkMicIn, 1996 &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX].State.Cfg, pDrv); 1988 1997 if (RT_SUCCESS(rc)) 1989 1998 rc = rc2; … … 1997 2006 * associated streams. 1998 2007 * 1999 * @param pThisCC The ring-3 AC'97 device state. 2000 * @param pDrv AC'97 driver to remove. 2001 */ 2002 static void ichac97R3MixerRemoveDrv(PAC97STATER3 pThisCC, PAC97DRIVER pDrv) 2008 * @param pDevIns The device instance. 2009 * @param pThisCC The ring-3 AC'97 device state. 2010 * @param pDrv AC'97 driver to remove. 2011 */ 2012 static void ichac97R3MixerRemoveDrv(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAC97DRIVER pDrv) 2003 2013 { 2004 2014 if (pDrv->MicIn.pMixStrm) … … 2008 2018 2009 2019 AudioMixerSinkRemoveStream(pThisCC->pSinkMicIn, pDrv->MicIn.pMixStrm); 2010 AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm );2020 AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm, pDevIns); 2011 2021 pDrv->MicIn.pMixStrm = NULL; 2012 2022 } … … 2018 2028 2019 2029 AudioMixerSinkRemoveStream(pThisCC->pSinkLineIn, pDrv->LineIn.pMixStrm); 2020 AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm );2030 AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm, pDevIns); 2021 2031 pDrv->LineIn.pMixStrm = NULL; 2022 2032 } … … 2025 2035 { 2026 2036 AudioMixerSinkRemoveStream(pThisCC->pSinkOut, pDrv->Out.pMixStrm); 2027 AudioMixerStreamDestroy(pDrv->Out.pMixStrm );2037 AudioMixerStreamDestroy(pDrv->Out.pMixStrm, pDevIns); 2028 2038 pDrv->Out.pMixStrm = NULL; 2029 2039 } … … 2035 2045 * Removes a driver stream from a specific mixer sink. 2036 2046 * 2037 * @param pMixSink Mixer sink to remove audio streams from. 2038 * @param enmDir Stream direction to remove. 2039 * @param dstSrc Stream destination / source to remove. 2040 * @param pDrv Driver stream to remove. 2041 */ 2042 static void ichac97R3MixerRemoveDrvStream(PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc, PAC97DRIVER pDrv) 2047 * @param pDevIns The device instance. 2048 * @param pMixSink Mixer sink to remove audio streams from. 2049 * @param enmDir Stream direction to remove. 2050 * @param dstSrc Stream destination / source to remove. 2051 * @param pDrv Driver stream to remove. 2052 */ 2053 static void ichac97R3MixerRemoveDrvStream(PPDMDEVINS pDevIns, PAUDMIXSINK pMixSink, PDMAUDIODIR enmDir, 2054 PDMAUDIODSTSRCUNION dstSrc, PAC97DRIVER pDrv) 2043 2055 { 2044 2056 PAC97DRIVERSTREAM pDrvStream = ichac97R3MixerGetDrvStream(pDrv, enmDir, dstSrc); … … 2049 2061 AudioMixerSinkRemoveStream(pMixSink, pDrvStream->pMixStrm); 2050 2062 2051 AudioMixerStreamDestroy(pDrvStream->pMixStrm );2063 AudioMixerStreamDestroy(pDrvStream->pMixStrm, pDevIns); 2052 2064 pDrvStream->pMixStrm = NULL; 2053 2065 } … … 2058 2070 * Removes all driver streams from a specific mixer sink. 2059 2071 * 2060 * @param pThisCC The ring-3 AC'97 state. 2061 * @param pMixSink Mixer sink to remove audio streams from. 2062 * @param enmDir Stream direction to remove. 2063 * @param dstSrc Stream destination / source to remove. 2064 */ 2065 static void ichac97R3MixerRemoveDrvStreams(PAC97STATER3 pThisCC, PAUDMIXSINK pMixSink, 2072 * @param pDevIns The device instance. 2073 * @param pThisCC The ring-3 AC'97 state. 2074 * @param pMixSink Mixer sink to remove audio streams from. 2075 * @param enmDir Stream direction to remove. 2076 * @param dstSrc Stream destination / source to remove. 2077 */ 2078 static void ichac97R3MixerRemoveDrvStreams(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAUDMIXSINK pMixSink, 2066 2079 PDMAUDIODIR enmDir, PDMAUDIODSTSRCUNION dstSrc) 2067 2080 { … … 2071 2084 RTListForEach(&pThisCC->lstDrv, pDrv, AC97DRIVER, Node) 2072 2085 { 2073 ichac97R3MixerRemoveDrvStream(p MixSink, enmDir, dstSrc, pDrv);2086 ichac97R3MixerRemoveDrvStream(pDevIns, pMixSink, enmDir, dstSrc, pDrv); 2074 2087 } 2075 2088 } … … 2128 2141 * 2129 2142 * @returns VBox status code. 2130 * @param pThis The shared AC'97 device state (shared). 2131 * @param pThisCC The shared AC'97 device state (ring-3). 2132 * @param pStream The AC'97 stream to open (shared). 2133 * @param pStreamCC The AC'97 stream to open (ring-3). 2134 * @param fForce Whether to force re-opening the stream or not. 2135 * Otherwise re-opening only will happen if the PCM properties have changed. 2136 */ 2137 static int ichac97R3StreamOpen(PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fForce) 2143 * @param pDevIns The device instance. 2144 * @param pThis The shared AC'97 device state (shared). 2145 * @param pThisCC The shared AC'97 device state (ring-3). 2146 * @param pStream The AC'97 stream to open (shared). 2147 * @param pStreamCC The AC'97 stream to open (ring-3). 2148 * @param fForce Whether to force re-opening the stream or not. 2149 * Otherwise re-opening only will happen if the PCM properties have changed. 2150 */ 2151 static int ichac97R3StreamOpen(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, 2152 PAC97STREAMR3 pStreamCC, bool fForce) 2138 2153 { 2139 2154 int rc = VINF_SUCCESS; … … 2230 2245 if (RT_SUCCESS(rc)) 2231 2246 { 2232 ichac97R3MixerRemoveDrvStreams(p ThisCC, pMixSink, Cfg.enmDir, Cfg.u);2233 2234 rc = ichac97R3MixerAddDrvStreams(p ThisCC, pMixSink, &Cfg);2247 ichac97R3MixerRemoveDrvStreams(pDevIns, pThisCC, pMixSink, Cfg.enmDir, Cfg.u); 2248 2249 rc = ichac97R3MixerAddDrvStreams(pDevIns, pThisCC, pMixSink, &Cfg); 2235 2250 if (RT_SUCCESS(rc)) 2236 2251 rc = PDMAudioStrmCfgCopy(&pStreamCC->State.Cfg, &Cfg); … … 2264 2279 * 2265 2280 * @returns VBox status code. 2266 * @param pThis The shared AC'97 device state. 2267 * @param pThisCC The ring-3 AC'97 device state. 2268 * @param pStream The AC'97 stream to re-open (shared). 2269 * @param pStreamCC The AC'97 stream to re-open (ring-3). 2270 * @param fForce Whether to force re-opening the stream or not. 2271 * Otherwise re-opening only will happen if the PCM properties have changed. 2272 */ 2273 static int ichac97R3StreamReOpen(PAC97STATE pThis, PAC97STATER3 pThisCC, 2281 * @param pDevIns The device instance. 2282 * @param pThis The shared AC'97 device state. 2283 * @param pThisCC The ring-3 AC'97 device state. 2284 * @param pStream The AC'97 stream to re-open (shared). 2285 * @param pStreamCC The AC'97 stream to re-open (ring-3). 2286 * @param fForce Whether to force re-opening the stream or not. 2287 * Otherwise re-opening only will happen if the PCM properties have changed. 2288 */ 2289 static int ichac97R3StreamReOpen(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STATER3 pThisCC, 2274 2290 PAC97STREAM pStream, PAC97STREAMR3 pStreamCC, bool fForce) 2275 2291 { … … 2281 2297 int rc = ichac97R3StreamClose(pStream); 2282 2298 if (RT_SUCCESS(rc)) 2283 rc = ichac97R3StreamOpen(p This, pThisCC, pStream, pStreamCC, fForce);2299 rc = ichac97R3StreamOpen(pDevIns, pThis, pThisCC, pStream, pStreamCC, fForce); 2284 2300 2285 2301 return rc; … … 3244 3260 Assert((pRegs->cr & AC97_CR_RPBM) == 0); 3245 3261 3246 ichac97R3StreamEnable(p This, pThisCC, pStream, pStreamCC, false /* fEnable */);3262 ichac97R3StreamEnable(pDevIns, pThis, pThisCC, pStream, pStreamCC, false /* fEnable */); 3247 3263 ichac97R3StreamReset(pThis, pStream, pStreamCC); 3248 3264 … … 3257 3273 Log3Func(("[SD%RU8] Disable\n", pStream->u8SD)); 3258 3274 3259 ichac97R3StreamEnable(p This, pThisCC, pStream, pStreamCC, false /* fEnable */);3275 ichac97R3StreamEnable(pDevIns, pThis, pThisCC, pStream, pStreamCC, false /* fEnable */); 3260 3276 3261 3277 pRegs->sr |= AC97_SR_DCH; … … 3275 3291 ichac97R3BDLEDumpAll(pDevIns, pStream->Regs.bdbar, pStream->Regs.lvi + 1); 3276 3292 # endif 3277 ichac97R3StreamEnable(p This, pThisCC, pStream, pStreamCC, true /* fEnable */);3293 ichac97R3StreamEnable(pDevIns, pThis, pThisCC, pStream, pStreamCC, true /* fEnable */); 3278 3294 3279 3295 /* Arm the timer for this stream. */ … … 3557 3573 { 3558 3574 ichac97MixerSet(pThis, AC97_PCM_Front_DAC_Rate, 0xbb80); /* Set default (48000 Hz). */ 3559 ichac97R3StreamReOpen(p This, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX],3575 ichac97R3StreamReOpen(pDevIns, pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], 3560 3576 &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */); 3561 3577 3562 3578 ichac97MixerSet(pThis, AC97_PCM_LR_ADC_Rate, 0xbb80); /* Set default (48000 Hz). */ 3563 ichac97R3StreamReOpen(p This, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX],3579 ichac97R3StreamReOpen(pDevIns, pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], 3564 3580 &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */); 3565 3581 } … … 3573 3589 { 3574 3590 ichac97MixerSet(pThis, AC97_MIC_ADC_Rate, 0xbb80); /* Set default (48000 Hz). */ 3575 ichac97R3StreamReOpen(p This, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX],3591 ichac97R3StreamReOpen(pDevIns, pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], 3576 3592 &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */); 3577 3593 } … … 3591 3607 LogRel2(("AC97: Setting front DAC rate to 0x%x\n", u32)); 3592 3608 ichac97MixerSet(pThis, offPort, u32); 3593 ichac97R3StreamReOpen(p This, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX],3609 ichac97R3StreamReOpen(pDevIns, pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PO_INDEX], 3594 3610 &pThisCC->aStreams[AC97SOUNDSOURCE_PO_INDEX], true /* fForce */); 3595 3611 } … … 3606 3622 LogRel2(("AC97: Setting microphone ADC rate to 0x%x\n", u32)); 3607 3623 ichac97MixerSet(pThis, offPort, u32); 3608 ichac97R3StreamReOpen(p This, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX],3624 ichac97R3StreamReOpen(pDevIns, pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_MC_INDEX], 3609 3625 &pThisCC->aStreams[AC97SOUNDSOURCE_MC_INDEX], true /* fForce */); 3610 3626 } … … 3621 3637 LogRel2(("AC97: Setting line-in ADC rate to 0x%x\n", u32)); 3622 3638 ichac97MixerSet(pThis, offPort, u32); 3623 ichac97R3StreamReOpen(p This, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX],3639 ichac97R3StreamReOpen(pDevIns, pThis, pThisCC, &pThis->aStreams[AC97SOUNDSOURCE_PI_INDEX], 3624 3640 &pThisCC->aStreams[AC97SOUNDSOURCE_PI_INDEX], true /* fForce */); 3625 3641 } … … 3801 3817 const PAC97STREAMR3 pStreamCC = &pThisCC->aStreams[i]; 3802 3818 3803 rc2 = ichac97R3StreamEnable(p This, pThisCC, pStream, pStreamCC, fEnable);3819 rc2 = ichac97R3StreamEnable(pDevIns, pThis, pThisCC, pStream, pStreamCC, fEnable); 3804 3820 AssertRC(rc2); 3805 3821 if ( fEnable … … 3851 3867 /* Note: Involves mixer stream / sink destruction, so also do this here 3852 3868 * instead of in ichac97R3Destruct(). */ 3853 ichac97R3StreamsDestroy(p This, pThisCC);3869 ichac97R3StreamsDestroy(pDevIns, pThis, pThisCC); 3854 3870 3855 3871 /* … … 3860 3876 if (pThisCC->pMixer) 3861 3877 { 3862 AudioMixerDestroy(pThisCC->pMixer );3878 AudioMixerDestroy(pThisCC->pMixer, pDevIns); 3863 3879 pThisCC->pMixer = NULL; 3864 3880 } … … 3891 3907 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++) 3892 3908 { 3893 ichac97R3StreamEnable(p This, pThisCC, &pThis->aStreams[i], &pThisCC->aStreams[i], false /* fEnable */);3909 ichac97R3StreamEnable(pDevIns, pThis, pThisCC, &pThis->aStreams[i], &pThisCC->aStreams[i], false /* fEnable */); 3894 3910 ichac97R3StreamReset(pThis, &pThis->aStreams[i], &pThisCC->aStreams[i]); 3895 3911 } … … 3988 4004 * 3989 4005 * @returns VBox status code. 4006 * @param pDevIns The device instance. 3990 4007 * @param pThisCC The ring-3 AC'97 device state. 3991 4008 * @param pDrv Driver to detach from device. 3992 4009 * @param fFlags Flags, combination of the PDMDEVATT_FLAGS_* \#defines. 3993 4010 */ 3994 static int ichac97R3DetachInternal(P AC97STATER3 pThisCC, PAC97DRIVER pDrv, uint32_t fFlags)4011 static int ichac97R3DetachInternal(PPDMDEVINS pDevIns, PAC97STATER3 pThisCC, PAC97DRIVER pDrv, uint32_t fFlags) 3995 4012 { 3996 4013 RT_NOREF(fFlags); … … 3998 4015 /* First, remove the driver from our list and destory it's associated streams. 3999 4016 * This also will un-set the driver as a recording source (if associated). */ 4000 ichac97R3MixerRemoveDrv(p ThisCC, pDrv);4017 ichac97R3MixerRemoveDrv(pDevIns, pThisCC, pDrv); 4001 4018 4002 4019 /* Next, search backwards for a capable (attached) driver which now will be the … … 4054 4071 int rc2 = ichac97R3AttachInternal(pDevIns, pThisCC, iLUN, fFlags, &pDrv); 4055 4072 if (RT_SUCCESS(rc2)) 4056 rc2 = ichac97R3MixerAddDrv(p ThisCC, pDrv);4073 rc2 = ichac97R3MixerAddDrv(pDevIns, pThisCC, pDrv); 4057 4074 4058 4075 if (RT_FAILURE(rc2)) … … 4081 4098 if (pDrv->uLUN == iLUN) 4082 4099 { 4083 int rc2 = ichac97R3DetachInternal(p ThisCC, pDrv, fFlags);4100 int rc2 = ichac97R3DetachInternal(pDevIns, pThisCC, pDrv, fFlags); 4084 4101 if (RT_SUCCESS(rc2)) 4085 4102 { … … 4312 4329 AssertRCReturn(rc, rc); 4313 4330 4314 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Recording] Line In", AUDMIXSINKDIR_INPUT, &pThisCC->pSinkLineIn); 4331 rc = AudioMixerCreateSink(pThisCC->pMixer, "Line In", 4332 AUDMIXSINKDIR_INPUT, pDevIns, &pThisCC->pSinkLineIn); 4315 4333 AssertRCReturn(rc, rc); 4316 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Recording] Microphone In", AUDMIXSINKDIR_INPUT, &pThisCC->pSinkMicIn); 4334 rc = AudioMixerCreateSink(pThisCC->pMixer, "Microphone In", 4335 AUDMIXSINKDIR_INPUT, pDevIns, &pThisCC->pSinkMicIn); 4317 4336 AssertRCReturn(rc, rc); 4318 rc = AudioMixerCreateSink(pThisCC->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThisCC->pSinkOut); 4337 rc = AudioMixerCreateSink(pThisCC->pMixer, "PCM Output", 4338 AUDMIXSINKDIR_OUTPUT, pDevIns, &pThisCC->pSinkOut); 4319 4339 AssertRCReturn(rc, rc); 4320 4340 -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88300 r88307 1428 1428 pStream->Out.cbBackendMaxWritable = cbWritable; 1429 1429 } 1430 pStream->Out.Stats.cbBackendWritableBefore = cbWritable; 1430 1431 1431 1432 /* … … 1458 1459 1459 1460 pStream->tsLastPlayedCapturedNs = RTTimeNanoTS(); 1461 pStream->Out.Stats.cbBackendWritableAfter = pThis->pHostDrvAudio->pfnStreamGetWritable(pThis->pHostDrvAudio, 1462 pStream->pvBackend); 1460 1463 } 1461 1464 else … … 2646 2649 * Register statistics. 2647 2650 */ 2651 PPDMDRVINS const pDrvIns = pThis->pDrvIns; 2652 /** @todo expose config and more. */ 2653 if (pCfgGuest->enmDir == PDMAUDIODIR_OUT) 2654 { 2655 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStream->Out.Stats.cbBackendWritableBefore, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 2656 "Host side: Free space in backend buffer before play", "%s/HostBackedBufFreeBefore", pStream->szName); 2657 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStream->Out.Stats.cbBackendWritableAfter, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 2658 "Host side: Free space in backend buffer after play", "%s/HostBackedBufFreeAfter", pStream->szName); 2659 } 2660 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStream->Host.Cfg.Backend.cFramesBufferSize, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 2661 "Host side: The size of the backend buffer (in frames)", "%s/HostBackedBufSize", pStream->szName); 2662 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStream->Host.MixBuf.cFrames, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 2663 "Host side: The size of the mixer buffer (in frames)", "%s/HostMixBufSize", pStream->szName); 2664 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStream->Host.MixBuf.cUsed, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 2665 "Host side: Number of frames in the mixer buffer", "%s/HostMixBufUsed", pStream->szName); 2666 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStream->Guest.MixBuf.cFrames, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 2667 "Guest side: The size of the mixer buffer (in frames)", "%s/GuestMixBufSize", pStream->szName); 2668 PDMDrvHlpSTAMRegisterF(pDrvIns, &pStream->Guest.MixBuf.cUsed, STAMTYPE_U32, STAMVISIBILITY_USED, STAMUNIT_NONE, 2669 "Guest side: Number of frames in the mixer buffer", "%s/GuestMixBufUsed", pStream->szName); 2670 2648 2671 #ifdef VBOX_WITH_STATISTICS 2649 2672 char szStatName[255]; … … 2651 2674 { 2652 2675 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/TotalFramesCaptured", pStream->szName); 2653 PDMDrvHlpSTAMRegCounterEx(p This->pDrvIns, &pStream->In.Stats.TotalFramesCaptured,2676 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pStream->In.Stats.TotalFramesCaptured, 2654 2677 szStatName, STAMUNIT_COUNT, "Total frames played."); 2655 2678 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/TotalTimesCaptured", pStream->szName); 2656 PDMDrvHlpSTAMRegCounterEx(p This->pDrvIns, &pStream->In.Stats.TotalTimesCaptured,2679 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pStream->In.Stats.TotalTimesCaptured, 2657 2680 szStatName, STAMUNIT_COUNT, "Total number of playbacks."); 2658 2681 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/TotalFramesRead", pStream->szName); 2659 PDMDrvHlpSTAMRegCounterEx(p This->pDrvIns, &pStream->In.Stats.TotalFramesRead,2682 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pStream->In.Stats.TotalFramesRead, 2660 2683 szStatName, STAMUNIT_COUNT, "Total frames read."); 2661 2684 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/TotalTimesRead", pStream->szName); 2662 PDMDrvHlpSTAMRegCounterEx(p This->pDrvIns, &pStream->In.Stats.TotalTimesRead,2685 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pStream->In.Stats.TotalTimesRead, 2663 2686 szStatName, STAMUNIT_COUNT, "Total number of reads."); 2664 2687 } … … 2667 2690 Assert(pCfgGuest->enmDir == PDMAUDIODIR_OUT); 2668 2691 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/TotalFramesPlayed", pStream->szName); 2669 PDMDrvHlpSTAMRegCounterEx(p This->pDrvIns, &pStream->Out.Stats.TotalFramesPlayed,2692 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pStream->Out.Stats.TotalFramesPlayed, 2670 2693 szStatName, STAMUNIT_COUNT, "Total frames played."); 2671 2694 2672 2695 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/TotalTimesPlayed", pStream->szName); 2673 PDMDrvHlpSTAMRegCounterEx(p This->pDrvIns, &pStream->Out.Stats.TotalTimesPlayed,2696 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pStream->Out.Stats.TotalTimesPlayed, 2674 2697 szStatName, STAMUNIT_COUNT, "Total number of playbacks."); 2675 2698 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/TotalFramesWritten", pStream->szName); 2676 PDMDrvHlpSTAMRegCounterEx(p This->pDrvIns, &pStream->Out.Stats.TotalFramesWritten,2699 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pStream->Out.Stats.TotalFramesWritten, 2677 2700 szStatName, STAMUNIT_COUNT, "Total frames written."); 2678 2701 2679 2702 RTStrPrintf(szStatName, sizeof(szStatName), "Guest/%s/TotalTimesWritten", pStream->szName); 2680 PDMDrvHlpSTAMRegCounterEx(p This->pDrvIns, &pStream->Out.Stats.TotalTimesWritten,2703 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pStream->Out.Stats.TotalTimesWritten, 2681 2704 szStatName, STAMUNIT_COUNT, "Total number of writes."); 2682 2705 } … … 3203 3226 } 3204 3227 3228 PPDMDRVINS const pDrvIns = pThis->pDrvIns; 3205 3229 if (pStream->enmDir == PDMAUDIODIR_IN) 3206 3230 { 3207 3231 #ifdef VBOX_WITH_STATISTICS 3208 PDMDrvHlpSTAMDeregister(p This->pDrvIns, &pStream->In.Stats.TotalFramesCaptured);3209 PDMDrvHlpSTAMDeregister(p This->pDrvIns, &pStream->In.Stats.TotalTimesCaptured);3210 PDMDrvHlpSTAMDeregister(p This->pDrvIns, &pStream->In.Stats.TotalFramesRead);3211 PDMDrvHlpSTAMDeregister(p This->pDrvIns, &pStream->In.Stats.TotalTimesRead);3232 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->In.Stats.TotalFramesCaptured); 3233 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->In.Stats.TotalTimesCaptured); 3234 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->In.Stats.TotalFramesRead); 3235 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->In.Stats.TotalTimesRead); 3212 3236 #endif 3213 3237 if (pThis->In.Cfg.Dbg.fEnabled) … … 3224 3248 Assert(pStream->enmDir == PDMAUDIODIR_OUT); 3225 3249 #ifdef VBOX_WITH_STATISTICS 3226 PDMDrvHlpSTAMDeregister(p This->pDrvIns, &pStream->Out.Stats.TotalFramesPlayed);3227 PDMDrvHlpSTAMDeregister(p This->pDrvIns, &pStream->Out.Stats.TotalTimesPlayed);3228 PDMDrvHlpSTAMDeregister(p This->pDrvIns, &pStream->Out.Stats.TotalFramesWritten);3229 PDMDrvHlpSTAMDeregister(p This->pDrvIns, &pStream->Out.Stats.TotalTimesWritten);3250 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Out.Stats.TotalFramesPlayed); 3251 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Out.Stats.TotalTimesPlayed); 3252 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Out.Stats.TotalFramesWritten); 3253 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Out.Stats.TotalTimesWritten); 3230 3254 #endif 3231 3255 if (pThis->Out.Cfg.Dbg.fEnabled) … … 3237 3261 pStream->Out.Dbg.pFileStreamWrite = NULL; 3238 3262 } 3239 } 3263 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Out.Stats.cbBackendWritableAfter); 3264 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Out.Stats.cbBackendWritableBefore); 3265 } 3266 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Host.Cfg.Backend.cFramesBufferSize); 3267 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Host.MixBuf.cFrames); 3268 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Host.MixBuf.cUsed); 3269 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Guest.MixBuf.cFrames); 3270 PDMDrvHlpSTAMDeregister(pDrvIns, &pStream->Guest.MixBuf.cUsed); 3240 3271 3241 3272 LogFlowFunc(("Returning %Rrc\n", rc));
Note:
See TracChangeset
for help on using the changeset viewer.