Changeset 88555 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Apr 15, 2021 10:46:33 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143850
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioDSound.cpp
r88554 r88555 220 220 DrvHostAudioDSoundMMNotifClient *m_pNotificationClient; 221 221 #endif 222 /** Pointer to the input stream. */223 PDSOUNDSTREAM pDSStrmIn;224 /** Pointer to the output stream. */225 PDSOUNDSTREAM pDSStrmOut;226 222 } DRVHOSTDSOUND, *PDRVHOSTDSOUND; 227 223 … … 1363 1359 pCfgAcq->Backend.cFramesBufferSize = PDMAudioPropsBytesToFrames(&pCfgAcq->Props, BufferCaps.dwBufferBytes); 1364 1360 1365 /** @todo r=bird: WTF is this for? */1366 pThis->pDSStrmIn = pStreamDS;1367 1368 1361 #if 0 /** @todo r=bird: uAlign isn't set anywhere, so this hasn't been checking anything for a while... */ 1369 1362 if (bc.dwBufferBytes & pStreamDS->uAlign) … … 1489 1482 / RT_MAX(pCfgReq->Backend.cFramesBufferSize, 1); 1490 1483 1491 /** @todo r=bird: WTF is this for? */1492 pThis->pDSStrmOut = pStreamDS;1493 1494 1484 #if 0 /** @todo r=bird: uAlign isn't set anywhere, so this hasn't been checking anything for a while... */ 1495 1485 if (bc.dwBufferBytes & pStreamDS->uAlign) … … 1592 1582 1593 1583 1594 static HRESULT directSoundPlayClose(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS)1595 {1596 AssertPtrReturn(pThis, E_POINTER);1597 AssertPtrReturn(pStreamDS, E_POINTER);1598 1599 LogFlowFuncEnter();1600 1601 HRESULT hr = directSoundPlayStop(pThis, pStreamDS, true /* fFlush */);1602 if (SUCCEEDED(hr))1603 {1604 DSLOG(("DSound: Closing playback stream\n"));1605 RTCritSectEnter(&pThis->CritSect);1606 1607 if (pStreamDS->Out.pDSB)1608 {1609 IDirectSoundBuffer8_Release(pStreamDS->Out.pDSB);1610 pStreamDS->Out.pDSB = NULL;1611 }1612 1613 pThis->pDSStrmOut = NULL;1614 1615 RTCritSectLeave(&pThis->CritSect);1616 }1617 1618 if (FAILED(hr))1619 DSLOGREL(("DSound: Stopping playback stream %p failed with %Rhrc\n", pStreamDS, hr));1620 1621 return hr;1622 }1623 1624 1625 static int dsoundDestroyStreamOut(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS)1626 {1627 LogFlowFuncEnter();1628 1629 HRESULT hr = directSoundPlayStop(pThis, pStreamDS, true /* fFlush */);1630 if (SUCCEEDED(hr))1631 {1632 hr = directSoundPlayClose(pThis, pStreamDS);1633 if (FAILED(hr))1634 return VERR_GENERAL_FAILURE; /** @todo Fix. */1635 }1636 1637 return VINF_SUCCESS;1638 }1639 1640 1641 static HRESULT directSoundCaptureClose(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS)1642 {1643 AssertPtrReturn(pThis, E_POINTER);1644 AssertPtrReturn(pStreamDS, E_POINTER);1645 1646 LogFlowFuncEnter();1647 1648 HRESULT hr = directSoundCaptureStop(pThis, pStreamDS, true /* fFlush */);1649 if (FAILED(hr))1650 return hr;1651 1652 if ( pStreamDS1653 && pStreamDS->In.pDSCB)1654 {1655 DSLOG(("DSound: Closing capturing stream\n"));1656 1657 IDirectSoundCaptureBuffer8_Release(pStreamDS->In.pDSCB);1658 pStreamDS->In.pDSCB = NULL;1659 }1660 1661 LogFlowFunc(("Returning %Rhrc\n", hr));1662 return hr;1663 }1664 1665 1666 static int dsoundDestroyStreamIn(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS)1667 {1668 LogFlowFuncEnter();1669 1670 directSoundCaptureClose(pThis, pStreamDS);1671 1672 return VINF_SUCCESS;1673 }1674 1675 1676 1584 /** 1677 1585 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} … … 1683 1591 AssertPtrReturn(pStreamDS, VERR_INVALID_POINTER); 1684 1592 1685 int rc;1686 1593 if (pStreamDS->Cfg.enmDir == PDMAUDIODIR_IN) 1687 rc = dsoundDestroyStreamIn(pThis, pStreamDS); 1594 { 1595 /* 1596 * Input. 1597 */ 1598 if (pStreamDS->In.pDSCB) 1599 { 1600 directSoundCaptureStop(pThis, pStreamDS, true /* fFlush */); 1601 1602 IDirectSoundCaptureBuffer8_Release(pStreamDS->In.pDSCB); 1603 pStreamDS->In.pDSCB = NULL; 1604 } 1605 } 1688 1606 else 1689 rc = dsoundDestroyStreamOut(pThis, pStreamDS); 1690 1691 if (RT_SUCCESS(rc)) 1692 { 1693 if (RTCritSectIsInitialized(&pStreamDS->CritSect)) 1694 rc = RTCritSectDelete(&pStreamDS->CritSect); 1695 } 1696 1697 return rc; 1607 { 1608 /* 1609 * Output. 1610 */ 1611 if (pStreamDS->Out.pDSB) 1612 { 1613 directSoundPlayStop(pThis, pStreamDS, true /* fFlush */); 1614 1615 IDirectSoundBuffer8_Release(pStreamDS->Out.pDSB); 1616 pStreamDS->Out.pDSB = NULL; 1617 } 1618 } 1619 1620 if (RTCritSectIsInitialized(&pStreamDS->CritSect)) 1621 RTCritSectDelete(&pStreamDS->CritSect); 1622 1623 return VINF_SUCCESS; 1698 1624 } 1699 1625 … … 1754 1680 static HRESULT directSoundPlayStop(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS, bool fFlush) 1755 1681 { 1756 AssertPtrReturn(pThis, E_POINTER); 1757 AssertPtrReturn(pStreamDS, E_POINTER); 1758 1759 HRESULT hr = S_OK; 1760 1761 if (pStreamDS->Out.pDSB) 1762 { 1763 DSLOG(("DSound: Stopping playback\n")); 1764 hr = IDirectSoundBuffer8_Stop(pStreamDS->Out.pDSB); 1765 if (FAILED(hr)) 1766 { 1767 hr = directSoundPlayRestore(pThis, pStreamDS->Out.pDSB); 1768 if (FAILED(hr)) /** @todo shouldn't this be a SUCCEEDED? */ 1769 hr = IDirectSoundBuffer8_Stop(pStreamDS->Out.pDSB); 1770 } 1771 } 1772 1773 if (SUCCEEDED(hr)) 1774 { 1775 if (fFlush) 1776 drvHostDSoundStreamReset(pThis, pStreamDS); 1777 } 1778 1779 if (FAILED(hr)) 1780 DSLOGREL(("DSound: %s playback failed with %Rhrc\n", fFlush ? "Stopping" : "Pausing", hr)); 1781 1782 return hr; 1682 if (!pStreamDS->Out.pDSB) 1683 return S_OK; 1684 1685 LogRel2(("DSound: Stopping playback of '%s'...\n", pStreamDS->Cfg.szName)); 1686 HRESULT hrc = IDirectSoundBuffer8_Stop(pStreamDS->Out.pDSB); 1687 if (FAILED(hrc)) 1688 { 1689 LogFunc(("IDirectSoundBuffer8_Stop -> %Rhrc; will attempt restoring the stream...\n", hrc)); 1690 directSoundPlayRestore(pThis, pStreamDS->Out.pDSB); 1691 hrc = IDirectSoundBuffer8_Stop(pStreamDS->Out.pDSB); 1692 if (FAILED(hrc)) 1693 LogRelMax(64, ("DSound: %s playback of '%s' failed: %Rhrc\n", fFlush ? "Stopping" : "Pausing", 1694 pStreamDS->Cfg.szName, hrc)); 1695 } 1696 LogRel2(("DSound: Stopped playback of '%s': %Rhrc\n", pStreamDS->Cfg.szName, hrc)); 1697 1698 if (fFlush) 1699 drvHostDSoundStreamReset(pThis, pStreamDS); 1700 return hrc; 1783 1701 } 1784 1702 … … 1919 1837 static HRESULT directSoundCaptureStop(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS, bool fFlush) 1920 1838 { 1839 if (!pStreamDS->In.pDSCB) 1840 return S_OK; 1841 1842 LogRel2(("DSound: Stopping capture (%s)\n", pStreamDS->Cfg.szName)); 1843 HRESULT hrc = IDirectSoundCaptureBuffer_Stop(pStreamDS->In.pDSCB); 1844 if (FAILED(hrc)) 1845 LogRelMax(64, ("DSound: Stopping capture of stream '%s' failed: %Rhrc\n", pStreamDS->Cfg.szName, hrc)); 1846 1847 if (fFlush) 1848 drvHostDSoundStreamReset(pThis, pStreamDS); 1849 return hrc; 1850 } 1851 1852 1853 static HRESULT directSoundCaptureClose(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS) 1854 { 1921 1855 AssertPtrReturn(pThis, E_POINTER); 1922 1856 AssertPtrReturn(pStreamDS, E_POINTER); 1923 1857 1924 RT_NOREF(pThis); 1925 1926 HRESULT hr = S_OK; 1927 1928 if (pStreamDS->In.pDSCB) 1929 { 1930 DSLOG(("DSound: Stopping capture\n")); 1931 hr = IDirectSoundCaptureBuffer_Stop(pStreamDS->In.pDSCB); 1932 } 1933 1934 if (SUCCEEDED(hr)) 1935 { 1936 if (fFlush) 1937 drvHostDSoundStreamReset(pThis, pStreamDS); 1938 } 1939 1858 LogFlowFuncEnter(); 1859 1860 HRESULT hr = directSoundCaptureStop(pThis, pStreamDS, true /* fFlush */); 1940 1861 if (FAILED(hr)) 1941 DSLOGREL(("DSound: Stopping capture buffer failed with %Rhrc\n", hr)); 1942 1862 return hr; 1863 1864 if ( pStreamDS 1865 && pStreamDS->In.pDSCB) 1866 { 1867 DSLOG(("DSound: Closing capturing stream\n")); 1868 1869 IDirectSoundCaptureBuffer8_Release(pStreamDS->In.pDSCB); 1870 pStreamDS->In.pDSCB = NULL; 1871 } 1872 1873 LogFlowFunc(("Returning %Rhrc\n", hr)); 1943 1874 return hr; 1944 1875 } … … 1992 1923 case PDMAUDIOSTREAMCMD_PAUSE: 1993 1924 { 1994 directSoundCaptureStop(pThis, pStreamDS, 1995 enmStreamCmd == PDMAUDIOSTREAMCMD_DISABLE /* fFlush */); 1925 directSoundCaptureStop(pThis, pStreamDS, enmStreamCmd == PDMAUDIOSTREAMCMD_DISABLE /* fFlush */); 1996 1926 1997 1927 /* Return success in any case, as stopping the capture can fail if
Note:
See TracChangeset
for help on using the changeset viewer.