Changeset 58344 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Oct 20, 2015 3:54:04 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r58157 r58344 371 371 } 372 372 373 static int drvAudioControlHstIn(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMIN pHstStrmIn, PDMAUDIOSTREAMCMD enmStreamCmd, 374 uint32_t uFlags) 373 static int drvAudioControlHstIn(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMIN pHstStrmIn, PDMAUDIOSTREAMCMD enmStreamCmd) 375 374 { 376 375 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 383 382 case PDMAUDIOSTREAMCMD_ENABLE: 384 383 { 385 if (! pHstStrmIn->fEnabled)384 if (!(pHstStrmIn->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 386 385 { 387 386 rc = pThis->pHostDrvAudio->pfnControlIn(pThis->pHostDrvAudio, pHstStrmIn, PDMAUDIOSTREAMCMD_ENABLE); 388 387 if (RT_SUCCESS(rc)) 389 388 { 390 pHstStrmIn->f Enabled = true;389 pHstStrmIn->fStatus |= PDMAUDIOSTRMSTS_FLAG_ENABLED; 391 390 } 392 391 else … … 401 400 case PDMAUDIOSTREAMCMD_DISABLE: 402 401 { 403 if (pHstStrmIn->f Enabled)402 if (pHstStrmIn->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 404 403 { 405 404 rc = pThis->pHostDrvAudio->pfnControlIn(pThis->pHostDrvAudio, pHstStrmIn, PDMAUDIOSTREAMCMD_DISABLE); 406 405 if (RT_SUCCESS(rc)) 407 406 { 408 pHstStrmIn->f Enabled = false;407 pHstStrmIn->fStatus = PDMAUDIOSTRMSTS_FLAG_NONE; /* Clear all. */ 409 408 AudioMixBufClear(&pHstStrmIn->MixBuf); 410 409 } … … 427 426 } 428 427 429 static int drvAudioControlHstOut(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PDMAUDIOSTREAMCMD enmStreamCmd, 430 uint32_t uFlags) 428 static int drvAudioControlHstOut(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PDMAUDIOSTREAMCMD enmStreamCmd) 431 429 { 432 430 AssertPtrReturn(pThis, VERR_INVALID_POINTER); … … 439 437 case PDMAUDIOSTREAMCMD_ENABLE: 440 438 { 441 if (! pHstStrmOut->fEnabled)439 if (!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 442 440 { 443 441 rc = pThis->pHostDrvAudio->pfnControlOut(pThis->pHostDrvAudio, pHstStrmOut, PDMAUDIOSTREAMCMD_ENABLE); 444 442 if (RT_SUCCESS(rc)) 445 443 { 446 Assert(! pHstStrmOut->fPendingDisable);447 pHstStrmOut->f Enabled = true;444 Assert(!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE)); 445 pHstStrmOut->fStatus |= PDMAUDIOSTRMSTS_FLAG_ENABLED; 448 446 LogFunc(("[%s] Enabled stream\n", pHstStrmOut->MixBuf.pszName)); 449 447 } 450 448 else 451 LogFlowFunc(("[%s] Backend reported an error when opening output stream, rc=%Rrc\n",449 LogFlowFunc(("[%s] Backend reported an error when enabling output stream, rc=%Rrc\n", 452 450 pHstStrmOut->MixBuf.pszName, rc)); 453 451 } … … 460 458 case PDMAUDIOSTREAMCMD_DISABLE: 461 459 { 462 if (pHstStrmOut->f Enabled)460 if (pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 463 461 { 464 462 rc = pThis->pHostDrvAudio->pfnControlOut(pThis->pHostDrvAudio, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE); 465 463 if (RT_SUCCESS(rc)) 466 464 { 467 pHstStrmOut->fEnabled = false; 468 pHstStrmOut->fPendingDisable = false; 465 pHstStrmOut->fStatus = PDMAUDIOSTRMSTS_FLAG_NONE; /* Clear all. */ 469 466 AudioMixBufClear(&pHstStrmOut->MixBuf); 470 467 … … 472 469 } 473 470 else 474 LogFlowFunc(("[%s] Backend vetoed closing output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc)); 471 LogFlowFunc(("[%s] Backend vetoed disabling output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc)); 472 } 473 else 474 rc = VINF_SUCCESS; 475 476 break; 477 } 478 479 case PDMAUDIOSTREAMCMD_PAUSE: 480 { 481 if (!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED)) 482 { 483 Assert(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED); 484 rc = pThis->pHostDrvAudio->pfnControlOut(pThis->pHostDrvAudio, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE); 485 if (RT_SUCCESS(rc)) 486 { 487 pHstStrmOut->fStatus |= PDMAUDIOSTRMSTS_FLAG_PAUSED; 488 LogFunc(("[%s] Pausing stream\n", pHstStrmOut->MixBuf.pszName)); 489 } 490 else 491 LogFlowFunc(("[%s] Backend vetoed pausing output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc)); 492 } 493 else 494 rc = VINF_SUCCESS; 495 496 break; 497 } 498 499 case PDMAUDIOSTREAMCMD_RESUME: 500 { 501 if (pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PAUSED) 502 { 503 Assert(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED); 504 rc = pThis->pHostDrvAudio->pfnControlOut(pThis->pHostDrvAudio, pHstStrmOut, PDMAUDIOSTREAMCMD_ENABLE); 505 if (RT_SUCCESS(rc)) 506 { 507 pHstStrmOut->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PAUSED; 508 LogFunc(("[%s] Resumed stream\n", pHstStrmOut->MixBuf.pszName)); 509 } 510 else 511 LogFlowFunc(("[%s] Backend vetoed resuming output stream, rc=%Rrc\n", pHstStrmOut->MixBuf.pszName, rc)); 475 512 } 476 513 else … … 562 599 { 563 600 while ((pHstStrmIn = drvAudioFindNextHstIn(pThis, pHstStrmIn))) 564 if (pHstStrmIn->f Enabled)601 if (pHstStrmIn->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 565 602 return pHstStrmIn; 566 603 … … 995 1032 AssertPtrReturn(pHstStrmOut, VERR_INVALID_POINTER); 996 1033 997 AssertMsg(pGstStrmOut->pHstStrmOut->f Enabled,1034 AssertMsg(pGstStrmOut->pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED, 998 1035 ("Writing to disabled host output stream \"%s\" not possible\n", 999 1036 pHstStrmOut->MixBuf.pszName)); … … 1053 1090 while ((pHostStrmOut = drvAudioFindAnyHstOut(pThis, pHostStrmOut))) 1054 1091 { 1055 if (pHostStrmOut->f Enabled)1092 if (pHostStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 1056 1093 return pHostStrmOut; 1057 1094 } … … 1159 1196 /* Has this stream marked as disabled but there still were guest streams relying 1160 1197 * on it? Check if this stream now can be closed and do so, if possible. */ 1161 if ( pHstStrmOut->fPendingDisable1198 if ( (pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE) 1162 1199 && !cSamplesLive) 1163 1200 { 1164 1201 /* Stop playing the current (pending) stream. */ 1165 int rc2 = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE , 0 /* Flags */);1202 int rc2 = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE); 1166 1203 if (RT_SUCCESS(rc2)) 1167 1204 { 1168 pHstStrmOut->f PendingDisable = false;1205 pHstStrmOut->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE; 1169 1206 1170 1207 LogFunc(("[%s] Disabling stream\n", pHstStrmOut->MixBuf.pszName)); … … 1402 1439 static void drvAudioStateHandler(PPDMDRVINS pDrvIns, PDMAUDIOSTREAMCMD enmCmd) 1403 1440 { 1441 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 1404 1442 PDRVAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIO); 1405 1443 … … 1411 1449 PPDMAUDIOHSTSTRMOUT pHstStrmOut = NULL; 1412 1450 while ((pHstStrmOut = drvAudioHstFindAnyEnabledOut(pThis, pHstStrmOut))) 1413 drvAudioControlHstOut(pThis, pHstStrmOut, enmCmd , 0 /* Flags */);1451 drvAudioControlHstOut(pThis, pHstStrmOut, enmCmd); 1414 1452 1415 1453 PPDMAUDIOHSTSTRMIN pHstStrmIn = NULL; 1416 1454 while ((pHstStrmIn = drvAudioFindNextEnabledHstIn(pThis, pHstStrmIn))) 1417 drvAudioControlHstIn(pThis, pHstStrmIn, enmCmd , 0 /* Flags */);1455 drvAudioControlHstIn(pThis, pHstStrmIn, enmCmd); 1418 1456 } 1419 1457 … … 1537 1575 AssertPtrReturn(pHstStrmIn, VERR_INVALID_POINTER); 1538 1576 1539 AssertMsg(pGstStrmIn->pHstStrmIn->f Enabled,1577 AssertMsg(pGstStrmIn->pHstStrmIn->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED, 1540 1578 ("Reading from disabled host input stream \"%s\" not possible\n", pGstStrmIn->MixBuf.pszName)); 1541 1579 … … 1579 1617 if (fEnable) 1580 1618 { 1581 pHstStrmOut->f PendingDisable = false;1582 if (! pHstStrmOut->fEnabled)1583 rc = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_ENABLE , 0 /* Flags */);1619 pHstStrmOut->fStatus &= ~PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE; 1620 if (!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED)) 1621 rc = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_ENABLE); 1584 1622 } 1585 1623 else /* Disable */ 1586 1624 { 1587 if (pHstStrmOut->f Enabled)1625 if (pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_ENABLED) 1588 1626 { 1589 1627 uint32_t cGstStrmsActive = 0; … … 1607 1645 1608 1646 /* Do we need to defer closing the host stream? */ 1609 pHstStrmOut->fPendingDisable = cGstStrmsActive >= 1; 1647 if (cGstStrmsActive >= 1) 1648 pHstStrmOut->fStatus |= PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE; 1610 1649 1611 1650 /* Can we close the host stream now instead of deferring it? */ 1612 if (! pHstStrmOut->fPendingDisable)1613 rc = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE , 0 /* Flags */);1651 if (!(pHstStrmOut->fStatus & PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE)) 1652 rc = drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE); 1614 1653 } 1615 1654 } … … 1618 1657 pGstStrmOut->State.fActive = fEnable; 1619 1658 1620 LogFlowFunc(("%s: fEnable=%RTbool, f PendingDisable=%RTbool, rc=%Rrc\n",1621 pGstStrmOut->MixBuf.pszName, fEnable, pHstStrmOut->f PendingDisable, rc));1659 LogFlowFunc(("%s: fEnable=%RTbool, fStatus=0x%x, rc=%Rrc\n", 1660 pGstStrmOut->MixBuf.pszName, fEnable, pHstStrmOut->fStatus, rc)); 1622 1661 } 1623 1662 } … … 1646 1685 { 1647 1686 rc = drvAudioControlHstIn(pThis, pHstStrmIn, 1648 fEnable ? PDMAUDIOSTREAMCMD_ENABLE : PDMAUDIOSTREAMCMD_DISABLE , 0 /* Flags */);1687 fEnable ? PDMAUDIOSTREAMCMD_ENABLE : PDMAUDIOSTREAMCMD_DISABLE); 1649 1688 if (RT_SUCCESS(rc)) 1650 1689 pGstStrmIn->State.fActive = fEnable; … … 1891 1930 while ((pHstStrmOut = drvAudioFindAnyHstOut(pThis, pHstStrmOut))) 1892 1931 { 1893 drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE , 0 /* Flags */);1932 drvAudioControlHstOut(pThis, pHstStrmOut, PDMAUDIOSTREAMCMD_DISABLE); 1894 1933 pThis->pHostDrvAudio->pfnFiniOut(pThis->pHostDrvAudio, pHstStrmOut); 1895 1934 } … … 1899 1938 while ((pHstStrmIn = drvAudioFindNextHstIn(pThis, pHstStrmIn))) 1900 1939 { 1901 drvAudioControlHstIn(pThis, pHstStrmIn, PDMAUDIOSTREAMCMD_DISABLE , 0 /* Flags */);1940 drvAudioControlHstIn(pThis, pHstStrmIn, PDMAUDIOSTREAMCMD_DISABLE); 1902 1941 pThis->pHostDrvAudio->pfnFiniIn(pThis->pHostDrvAudio, pHstStrmIn); 1903 1942 } … … 1986 2025 static DECLCALLBACK(void) drvAudioSuspend(PPDMDRVINS pDrvIns) 1987 2026 { 1988 drvAudioStateHandler(pDrvIns, PDMAUDIOSTREAMCMD_ DISABLE);2027 drvAudioStateHandler(pDrvIns, PDMAUDIOSTREAMCMD_PAUSE); 1989 2028 } 1990 2029 … … 1996 2035 static DECLCALLBACK(void) drvAudioResume(PPDMDRVINS pDrvIns) 1997 2036 { 1998 drvAudioStateHandler(pDrvIns, PDMAUDIOSTREAMCMD_ ENABLE);2037 drvAudioStateHandler(pDrvIns, PDMAUDIOSTREAMCMD_RESUME); 1999 2038 } 2000 2039
Note:
See TracChangeset
for help on using the changeset viewer.