Changeset 64050 in vbox
- Timestamp:
- Sep 27, 2016 2:41:59 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 110977
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r64044 r64050 329 329 } 330 330 331 pGstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_ENABLED; 331 if (RT_SUCCESS(rc)) 332 pGstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_ENABLED; 332 333 } 333 334 break; … … 335 336 336 337 case PDMAUDIOSTREAMCMD_DISABLE: 337 case PDMAUDIOSTREAMCMD_PAUSE:338 338 { 339 339 if (pGstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 340 340 { 341 /* Is the guest side stream still active?342 * Mark the host stream as pending disable and bail out. */343 341 if (pHstStream) 344 342 { 345 LogFunc(("[%s] Pending disable/pause\n", pHstStream->szName)); 346 pHstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE; 343 /* 344 * For playback (output) streams first mark the host stream as pending disable, 345 * so that the rest of the remaining audio data will be played first before 346 * closing the stream. 347 */ 348 if (pHstStream->enmDir == PDMAUDIODIR_OUT) 349 { 350 LogFunc(("[%s] Pending disable/pause\n", pHstStream->szName)); 351 pHstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE; 352 } 353 354 /* Can we close the host stream as well (not in pending disable mode)? */ 355 if (!(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE)) 356 rc = drvAudioStreamControlInternalBackend(pThis, pHstStream, PDMAUDIOSTREAMCMD_DISABLE); 347 357 } 348 358 349 if (enmStreamCmd == PDMAUDIOSTREAMCMD_DISABLE) 350 { 359 if (RT_SUCCESS(rc)) 351 360 pGstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_ENABLED; 352 } 353 else if (enmStreamCmd == PDMAUDIOSTREAMCMD_PAUSE) 361 } 362 break; 363 } 364 365 case PDMAUDIOSTREAMCMD_PAUSE: 366 { 367 if (!(pGstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED)) 368 { 369 if (pHstStream) 370 rc = drvAudioStreamControlInternalBackend(pThis, pHstStream, PDMAUDIOSTREAMCMD_PAUSE); 371 372 if (RT_SUCCESS(rc)) 354 373 pGstStream->fStatus |= PDMAUDIOSTRMSTS_FLAG_PAUSED; 355 else356 AssertFailedBreakStmt(rc = VERR_NOT_IMPLEMENTED);357 }358 359 if ( pHstStream360 && !(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE))361 {362 rc = drvAudioStreamControlInternalBackend(pThis, pHstStream, enmStreamCmd);363 if (RT_SUCCESS(rc))364 pHstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE;365 374 } 366 375 break; … … 374 383 rc = drvAudioStreamControlInternalBackend(pThis, pHstStream, PDMAUDIOSTREAMCMD_RESUME); 375 384 376 pGstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PAUSED; 385 if (RT_SUCCESS(rc)) 386 pGstStream->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PAUSED; 377 387 } 378 388 break; … … 900 910 * @param pThis Pointer to driver instance. 901 911 * @param pStream Stream to iterate. 902 *903 * @remark904 912 */ 905 913 static int drvAudioStreamIterateInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream) … … 912 920 PPDMAUDIOSTREAM pHstStream = drvAudioGetHostStream(pStream); 913 921 AssertPtr(pHstStream); 914 PPDMAUDIOSTREAM pGstStream = pHstStream ->pPair;922 PPDMAUDIOSTREAM pGstStream = pHstStream ? pHstStream->pPair : NULL; 915 923 AssertPtr(pGstStream); 916 924 … … 937 945 } 938 946 947 Log3Func(("[%s] fStatus=0x%x\n", pHstStream->szName, pHstStream->fStatus)); 948 949 /* Not enabled or paused? Skip iteration. */ 950 if ( !(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 951 || (pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED)) 952 { 953 return VINF_SUCCESS; 954 } 955 939 956 /* Whether to try closing a pending to close stream. */ 940 957 bool fTryClosePending = false; … … 952 969 /* Has the host captured any samples which were not mixed to the guest side yet? */ 953 970 uint32_t cSamplesCaptured = AudioMixBufUsed(&pHstStream->MixBuf); 954 955 Log3Func(("[%s] %RU32 samples captured\n", pHstStream->szName, cSamplesCaptured));956 957 971 if (cSamplesCaptured) 958 972 { … … 960 974 * So try mixing not yet mixed host-side samples to the guest-side buffer. */ 961 975 rc = AudioMixBufMixToParent(&pHstStream->MixBuf, cSamplesCaptured, &cSamplesMixed); 962 if ( RT_SUCCESS(rc) 963 && cSamplesMixed) 964 { 965 Log3Func(("[%s] %RU32 captured samples mixed\n", pHstStream->szName, cSamplesMixed)); 966 } 967 else if (RT_FAILURE(rc)) 976 if (RT_FAILURE(rc)) 968 977 { 969 978 if (rc == VERR_BUFFER_OVERFLOW) … … 972 981 LogRel2(("Audio: Mixing to guest input stream '%s' failed: %Rrc\n", pGstStream->szName, rc)); 973 982 } 983 984 Log3Func(("[%s] %RU32/%RU32 input samples mixed, rc=%Rrc\n", pHstStream->szName, cSamplesMixed, cSamplesCaptured, rc)); 974 985 } 975 986 else … … 986 997 && cSamplesMixed) 987 998 { 988 Log3Func(("[%s] %RU32 samples mixed, guest has %RU32 samples left (%RU32 live)\n",999 Log3Func(("[%s] %RU32 output samples mixed, guest has %RU32 samples left (%RU32 live)\n", 989 1000 pHstStream->szName, cSamplesMixed, 990 1001 AudioMixBufUsed(&pGstStream->MixBuf), AudioMixBufLive(&pGstStream->MixBuf))); … … 1020 1031 } 1021 1032 else 1022 LogFunc((" %s: Backend vetoed against closing output stream, rc=%Rrc\n", pHstStream->szName, rc));1033 LogFunc(("[%s] Backend vetoed against closing pending output stream, rc=%Rrc\n", pHstStream->szName, rc)); 1023 1034 } 1024 1035 } … … 1031 1042 1032 1043 if (RT_FAILURE(rc)) 1033 LogFunc((" Failed with %Rrc\n", rc));1044 LogFunc(("[%s] Failed with %Rrc\n", pHstStream->szName, rc)); 1034 1045 1035 1046 return rc; … … 1193 1204 pStream->szName, pStream->enmDir)); 1194 1205 1195 Log3Func(("[%s]\n", pStream->szName));1196 1197 1206 uint32_t cSamplesCaptured = 0; 1198 1207 … … 1232 1241 { 1233 1242 #ifdef VBOX_WITH_STATISTICS 1243 STAM_COUNTER_ADD(&pThis->Stats.TotalSamplesCaptured, cSamplesCaptured); 1234 1244 STAM_COUNTER_ADD(&pHstStream->In.StatSamplesCaptured, cSamplesCaptured); 1235 1245 #endif 1236 1246 } 1237 1247 } 1238 1239 Log3Func(("[%s] strmSts=0x%x, cSamplesCaptured=%RU32, rc=%Rrc\n", pHstStream->szName, stsBackend, cSamplesCaptured, rc)); 1240 } 1248 } 1249 1250 Log3Func(("[%s] stsBackend=0x%x, cSamplesLive=%RU32, cSamplesCaptured=%RU32, rc=%Rrc\n", 1251 pHstStream->szName, stsBackend, cSamplesLive, cSamplesCaptured, rc)); 1241 1252 1242 1253 } while (0); … … 1649 1660 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 1650 1661 1651 if (!pStream) 1652 { 1653 if (pcbRead) 1654 *pcbRead = 0; 1655 return VINF_SUCCESS; 1656 } 1657 1658 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 1659 AssertReturn(cbBuf, VERR_INVALID_PARAMETER); 1662 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1663 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 1664 AssertReturn(cbBuf, VERR_INVALID_PARAMETER); 1660 1665 /* pcbWritten is optional. */ 1661 1666 … … 1688 1693 1689 1694 PPDMAUDIOSTREAM pGstStream = pHstStream->pPair; 1690 1691 AssertMsg(pHstStream->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED, 1692 ("Reading from disabled host input stream '%s' not possible\n", pHstStream->szName)); 1695 AssertPtr(pGstStream); 1693 1696 1694 1697 pGstStream->In.tsLastReadMS = RTTimeMilliTS(); 1695 1696 Log3Func(("%s\n", pStream->szName));1697 1698 1698 1699 /* … … 1716 1717 } 1717 1718 1718 Log3Func(("cRead=%RU32 (%RU32 bytes), rc=%Rrc\n", cRead, AUDIOMIXBUF_S2B(&pGstStream->MixBuf, cRead), rc));1719 1720 1719 } while (0); 1720 1721 Log3Func(("[%s] cbRead=%RU32, rc=%Rrc\n", pStream->szName, cbRead, rc)); 1721 1722 1722 1723 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 2515 2516 #ifdef VBOX_WITH_STATISTICS 2516 2517 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsActive, "TotalStreamsActive", 2517 STAMUNIT_COUNT, " Active inputstreams.");2518 STAMUNIT_COUNT, "Total active audio streams."); 2518 2519 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsCreated, "TotalStreamsCreated", 2519 STAMUNIT_COUNT, "Total created inputstreams.");2520 STAMUNIT_COUNT, "Total created audio streams."); 2520 2521 PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalSamplesPlayed, "TotalSamplesPlayed", 2521 2522 STAMUNIT_COUNT, "Total samples played.");
Note:
See TracChangeset
for help on using the changeset viewer.