- Timestamp:
- Aug 3, 2016 12:28:51 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r62909 r62910 263 263 PDSOUNDSTREAMOUT pDSoundStream, DWORD *pdwBuffer, DWORD *pdwFree, DWORD *pdwPlayPos) 264 264 { 265 AssertPtr Return(pThis, VERR_INVALID_POINTER);265 AssertPtr(pThis); 266 266 AssertPtrReturn(pDSoundStream, VERR_INVALID_POINTER); 267 267 AssertPtrNull(pdwBuffer); … … 755 755 static HRESULT directSoundPlayGetStatus(PDRVHOSTDSOUND pThis, LPDIRECTSOUNDBUFFER8 pDSB, DWORD *pdwStatus) 756 756 { 757 AssertPtr Return(pThis, E_POINTER);757 AssertPtr(pThis); 758 758 AssertPtrReturn(pDSB, E_POINTER); 759 759 AssertPtrNull(pdwStatus); … … 1415 1415 } 1416 1416 1417 static int dsoundCreateStreamOut(PPDMIHOSTAUDIO pInterface, 1418 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1419 { 1420 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1421 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1422 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1423 /* pcSamples is optional. */ 1424 1417 static int dsoundCreateStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1418 { 1425 1419 LogFlowFunc(("pStream=%p, pCfg=%p\n", pStream, pCfg)); 1426 1427 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);1428 1420 PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream; 1429 1421 … … 1447 1439 } 1448 1440 else 1449 {1450 1441 RT_ZERO(pDSoundStream->streamCfg); 1451 }1452 1442 1453 1443 LogFlowFuncLeaveRC(rc); … … 1455 1445 } 1456 1446 1457 static int dsoundControlStreamOut(PPDMIHOSTAUDIO pInterface, 1458 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 1459 { 1460 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1461 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1462 1447 static int dsoundControlStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 1448 { 1463 1449 LogFlowFunc(("pStream=%p, cmd=%d\n", pStream, enmStreamCmd)); 1464 1465 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);1466 1450 PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream; 1467 1451 … … 1513 1497 } 1514 1498 1515 static DECLCALLBACK(int) drvHostDSoundStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 1516 uint32_t *pcSamplesPlayed) 1499 1500 /** 1501 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamPlay} 1502 */ 1503 static DECLCALLBACK(int) drvHostDSoundStreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed) 1517 1504 { 1518 1505 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); … … 1658 1645 } 1659 1646 1660 static int dsoundDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1661 { 1662 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 1647 static int dsoundDestroyStreamOut(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream) 1648 { 1663 1649 PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream; 1664 1650 … … 1674 1660 } 1675 1661 1676 static int dsoundCreateStreamIn(PPDMIHOSTAUDIO pInterface, 1677 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1678 { 1679 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1680 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1681 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 1682 1683 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 1662 static int dsoundCreateStreamIn(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 1663 { 1684 1664 PDSOUNDSTREAMIN pDSoundStream = (PDSOUNDSTREAMIN)pStream; 1685 1665 … … 1715 1695 } 1716 1696 1717 static int dsoundControlStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 1718 PDMAUDIOSTREAMCMD enmStreamCmd) 1719 { 1720 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 1721 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 1722 1697 static int dsoundControlStreamIn(PDRVHOSTDSOUND pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 1698 { 1723 1699 LogFlowFunc(("pStream=%p, enmStreamCmd=%ld\n", pStream, enmStreamCmd)); 1724 1725 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);1726 1700 PDSOUNDSTREAMIN pDSoundStream = (PDSOUNDSTREAMIN)pStream; 1727 1701 … … 1772 1746 } 1773 1747 1748 1749 /** 1750 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCapture} 1751 */ 1774 1752 static DECLCALLBACK(int) drvHostDSoundStreamCapture(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, 1775 1753 uint32_t *pcSamplesCaptured) … … 1897 1875 } 1898 1876 1899 static int dsoundDestroyStreamIn(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 1900 { 1901 RT_NOREF(pInterface); 1877 static int dsoundDestroyStreamIn(PPDMAUDIOSTREAM pStream) 1878 { 1902 1879 PDSOUNDSTREAMIN pDSoundStream = (PDSOUNDSTREAMIN)pStream; 1903 1880 … … 1911 1888 } 1912 1889 1890 1891 /** 1892 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetConfig} 1893 */ 1913 1894 static DECLCALLBACK(int) drvHostDSoundGetConfig(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pCfg) 1914 1895 { … … 1924 1905 1925 1906 #ifdef VBOX_WITH_AUDIO_CALLBACKS 1907 1926 1908 static int dsoundNotifyThread(PDRVHOSTDSOUND pThis, bool fShutdown) 1927 1909 { … … 1940 1922 return VINF_SUCCESS; 1941 1923 } 1924 1942 1925 1943 1926 static DECLCALLBACK(int) dsoundNotificationThread(RTTHREAD hThreadSelf, void *pvUser) … … 2029 2012 return rc; 2030 2013 } 2014 2031 2015 #endif /* VBOX_WITH_AUDIO_CALLBACKS */ 2032 2016 2017 2018 /** 2019 * @interface_method_impl{PDMIHOSTAUDIO,pfnShutdown} 2020 */ 2033 2021 static DECLCALLBACK(void) drvHostDSoundShutdown(PPDMIHOSTAUDIO pInterface) 2034 2022 { … … 2059 2047 } 2060 2048 2049 2050 /** 2051 * @interface_method_impl{PDMIHOSTAUDIO,pfnInit} 2052 */ 2061 2053 static DECLCALLBACK(int) drvHostDSoundInit(PPDMIHOSTAUDIO pInterface) 2062 2054 { 2063 2055 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 2064 2065 2056 LogFlowFuncEnter(); 2066 2057 … … 2069 2060 /* Verify that IDirectSound is available. */ 2070 2061 LPDIRECTSOUND pDirectSound = NULL; 2071 HRESULT hr = CoCreateInstance(CLSID_DirectSound, NULL, CLSCTX_ALL, 2072 IID_IDirectSound, (void **)&pDirectSound); 2062 HRESULT hr = CoCreateInstance(CLSID_DirectSound, NULL, CLSCTX_ALL, IID_IDirectSound, (void **)&pDirectSound); 2073 2063 if (SUCCEEDED(hr)) 2074 2064 { … … 2111 2101 } 2112 2102 2113 static DECLCALLBACK(void *) drvHostDSoundQueryInterface(PPDMIBASE pInterface, const char *pszIID)2114 {2115 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);2116 PDRVHOSTDSOUND pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTDSOUND);2117 2118 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);2119 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTAUDIO, &pThis->IHostAudio);2120 return NULL;2121 }2122 2103 2123 2104 static LPCGUID dsoundConfigQueryGUID(PCFGMNODE pCfg, const char *pszName, RTUUID *pUuid) … … 2141 2122 } 2142 2123 2124 2143 2125 static void dsoundConfigInit(PDRVHOSTDSOUND pThis, PCFGMNODE pCfg) 2144 2126 { … … 2160 2142 } 2161 2143 2162 /* 2163 * PDMIHOSTAUDIO 2144 2145 /** 2146 * @interface_method_impl{PDMIHOSTAUDIO,pfnGetStatus} 2164 2147 */ 2165 2166 2148 static DECLCALLBACK(PDMAUDIOBACKENDSTS) drvHostDSoundGetStatus(PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir) 2167 2149 { … … 2172 2154 } 2173 2155 2174 static DECLCALLBACK(int) drvHostDSoundStreamCreate(PPDMIHOSTAUDIO pInterface, 2175 PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 2156 2157 /** 2158 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamCreate} 2159 */ 2160 static DECLCALLBACK(int) 2161 drvHostDSoundStreamCreate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples) 2162 { 2163 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2164 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2165 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 2166 AssertPtrNullReturn(pcSamples, VERR_INVALID_POINTER); 2167 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 2168 2169 int rc; 2170 if (pCfg->enmDir == PDMAUDIODIR_IN) 2171 rc = dsoundCreateStreamIn(pThis, pStream, pCfg, pcSamples); 2172 else 2173 rc = dsoundCreateStreamOut(pThis, pStream, pCfg, pcSamples); 2174 2175 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); 2176 return rc; 2177 } 2178 2179 2180 /** 2181 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy} 2182 */ 2183 static DECLCALLBACK(int) drvHostDSoundStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 2176 2184 { 2177 2185 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2178 2186 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2179 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);2187 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 2180 2188 2181 2189 int rc; 2182 if (p Cfg->enmDir == PDMAUDIODIR_IN)2183 rc = dsound CreateStreamIn(pInterface, pStream, pCfg, pcSamples);2190 if (pStream->enmDir == PDMAUDIODIR_IN) 2191 rc = dsoundDestroyStreamIn(pStream); 2184 2192 else 2185 rc = dsoundCreateStreamOut(pInterface, pStream, pCfg, pcSamples); 2186 2187 LogFlowFunc(("%s: rc=%Rrc\n", pStream->szName, rc)); 2193 rc = dsoundDestroyStreamOut(pThis, pStream); 2194 2188 2195 return rc; 2189 2196 } 2190 2197 2191 static DECLCALLBACK(int) drvHostDSoundStreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 2198 2199 /** 2200 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamControl} 2201 */ 2202 static DECLCALLBACK(int) 2203 drvHostDSoundStreamControl(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 2192 2204 { 2193 2205 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2194 2206 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2207 PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface); 2208 2209 Assert(pStream->enmCtx == PDMAUDIOSTREAMCTX_HOST); 2195 2210 2196 2211 int rc; 2197 2212 if (pStream->enmDir == PDMAUDIODIR_IN) 2198 rc = dsound DestroyStreamIn(pInterface, pStream);2213 rc = dsoundControlStreamIn(pThis, pStream, enmStreamCmd); 2199 2214 else 2200 rc = dsound DestroyStreamOut(pInterface, pStream);2215 rc = dsoundControlStreamOut(pThis, pStream, enmStreamCmd); 2201 2216 2202 2217 return rc; 2203 2218 } 2204 2219 2205 static DECLCALLBACK(int) drvHostDSoundStreamControl(PPDMIHOSTAUDIO pInterface, 2206 PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd) 2207 { 2208 AssertPtrReturn(pInterface, VERR_INVALID_POINTER); 2209 AssertPtrReturn(pStream, VERR_INVALID_POINTER); 2210 2211 Assert(pStream->enmCtx == PDMAUDIOSTREAMCTX_HOST); 2212 2213 int rc; 2214 if (pStream->enmDir == PDMAUDIODIR_IN) 2215 rc = dsoundControlStreamIn(pInterface, pStream, enmStreamCmd); 2216 else 2217 rc = dsoundControlStreamOut(pInterface, pStream, enmStreamCmd); 2218 2219 return rc; 2220 } 2221 2220 2221 /** 2222 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamGetStatus} 2223 */ 2222 2224 static DECLCALLBACK(PDMAUDIOSTRMSTS) drvHostDSoundStreamGetStatus(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 2223 2225 { … … 2256 2258 2257 2259 2260 /** 2261 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamIterate} 2262 */ 2258 2263 static DECLCALLBACK(int) drvHostDSoundStreamIterate(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream) 2259 2264 { … … 2267 2272 } 2268 2273 2274 2275 /********************************************************************************************************************************* 2276 * PDMDRVINS::IBase Interface * 2277 *********************************************************************************************************************************/ 2278 2279 /** 2280 * @callback_method_impl{PDMIBASE,pfnQueryInterface} 2281 */ 2282 static DECLCALLBACK(void *) drvHostDSoundQueryInterface(PPDMIBASE pInterface, const char *pszIID) 2283 { 2284 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface); 2285 PDRVHOSTDSOUND pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTDSOUND); 2286 2287 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase); 2288 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHOSTAUDIO, &pThis->IHostAudio); 2289 return NULL; 2290 } 2291 2292 2293 /********************************************************************************************************************************* 2294 * PDMDRVREG Interface * 2295 *********************************************************************************************************************************/ 2269 2296 2270 2297 /**
Note:
See TracChangeset
for help on using the changeset viewer.