Changeset 89459 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Jun 2, 2021 9:45:11 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r89458 r89459 406 406 407 407 408 409 /** 410 * Helper for handling --backend options. 411 * 412 * @returns Pointer to the specified backend, NULL if not found (error 413 * displayed). 414 * @param pszBackend The backend option value. 415 */ 416 static PCPDMDRVREG audioTestFindBackendOpt(const char *pszBackend) 417 { 418 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++) 419 if ( strcmp(pszBackend, g_aBackends[i].pszName) == 0 420 || strcmp(pszBackend, g_aBackends[i].pDrvReg->szName) == 0) 421 return g_aBackends[i].pDrvReg; 422 RTMsgError("Unknown backend: '%s'", pszBackend); 423 return NULL; 424 } 425 426 408 427 /********************************************************************************************************************************* 409 428 * Test Primitives * … … 1379 1398 1380 1399 case 'b': 1381 pDrvReg = NULL; 1382 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++) 1383 if ( strcmp(ValueUnion.psz, g_aBackends[i].pszName) == 0 1384 || strcmp(ValueUnion.psz, g_aBackends[i].pDrvReg->szName) == 0) 1385 { 1386 pDrvReg = g_aBackends[i].pDrvReg; 1387 break; 1388 } 1400 pDrvReg = audioTestFindBackendOpt(ValueUnion.psz); 1389 1401 if (pDrvReg == NULL) 1390 return RT MsgErrorExit(RTEXITCODE_SYNTAX, "Unknown backend: '%s'", ValueUnion.psz);1402 return RTEXITCODE_SYNTAX; 1391 1403 break; 1392 1404 … … 1696 1708 */ 1697 1709 return RTTestSummaryAndDestroy(g_hTest); 1710 } 1711 1712 1713 /********************************************************************************************************************************* 1714 * Command: enum * 1715 *********************************************************************************************************************************/ 1716 1717 /** 1718 * Options for 'enum'. 1719 */ 1720 static const RTGETOPTDEF g_aCmdEnumOptions[] = 1721 { 1722 { "--backend", 'b', RTGETOPT_REQ_STRING }, 1723 }; 1724 1725 /** The 'enum' command option help. */ 1726 static DECLCALLBACK(const char *) audioTestCmdEnumHelp(PCRTGETOPTDEF pOpt) 1727 { 1728 switch (pOpt->iShort) 1729 { 1730 case 'b': return "The audio backend to use."; 1731 default: return NULL; 1732 } 1733 } 1734 1735 /** 1736 * The 'enum' command handler. 1737 * 1738 * @returns Program exit code. 1739 * @param pGetState RTGetOpt state. 1740 */ 1741 static DECLCALLBACK(RTEXITCODE) audioTestCmdEnumHandler(PRTGETOPTSTATE pGetState) 1742 { 1743 /* 1744 * Parse options. 1745 */ 1746 /* Option values: */ 1747 PCPDMDRVREG pDrvReg = g_aBackends[0].pDrvReg; 1748 1749 /* Argument processing loop: */ 1750 int rc; 1751 RTGETOPTUNION ValueUnion; 1752 while ((rc = RTGetOpt(pGetState, &ValueUnion)) != 0) 1753 { 1754 switch (rc) 1755 { 1756 case 'b': 1757 pDrvReg = audioTestFindBackendOpt(ValueUnion.psz); 1758 if (pDrvReg == NULL) 1759 return RTEXITCODE_SYNTAX; 1760 break; 1761 1762 AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion); 1763 1764 default: 1765 return RTGetOptPrintError(rc, &ValueUnion); 1766 } 1767 } 1768 1769 /* 1770 * Do the enumeration. 1771 */ 1772 RTEXITCODE rcExit = RTEXITCODE_FAILURE; 1773 AUDIOTESTDRVSTACK DrvStack; 1774 rc = audioTestDriverStackInit(&DrvStack, pDrvReg, false /*fWithDrvAudio*/); 1775 if (RT_SUCCESS(rc)) 1776 { 1777 if (DrvStack.pIHostAudio->pfnGetDevices) 1778 { 1779 PDMAUDIOHOSTENUM Enum; 1780 rc = DrvStack.pIHostAudio->pfnGetDevices(DrvStack.pIHostAudio, &Enum); 1781 if (RT_SUCCESS(rc)) 1782 { 1783 RTPrintf("Found %u device%s\n", Enum.cDevices, Enum.cDevices != 1 ? "s" : ""); 1784 1785 PPDMAUDIOHOSTDEV pHostDev; 1786 RTListForEach(&Enum.LstDevices, pHostDev, PDMAUDIOHOSTDEV, ListEntry) 1787 { 1788 RTPrintf("\nDevice \"%s\":\n", pHostDev->szName); 1789 1790 char szFlags[PDMAUDIOHOSTDEV_MAX_FLAGS_STRING_LEN]; 1791 if (pHostDev->cMaxInputChannels && !pHostDev->cMaxOutputChannels && pHostDev->enmUsage == PDMAUDIODIR_IN) 1792 RTPrintf(" Input: max %u channels (%s)\n", 1793 pHostDev->cMaxInputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 1794 else if (!pHostDev->cMaxInputChannels && pHostDev->cMaxOutputChannels && pHostDev->enmUsage == PDMAUDIODIR_OUT) 1795 RTPrintf(" Output: max %u channels (%s)\n", 1796 pHostDev->cMaxOutputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 1797 else 1798 RTPrintf(" %s: max %u output channels, max %u input channels (%s)\n", 1799 PDMAudioDirGetName(pHostDev->enmUsage), pHostDev->cMaxOutputChannels, 1800 pHostDev->cMaxInputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 1801 1802 if (pHostDev->pszId && *pHostDev->pszId) 1803 RTPrintf(" ID: \"%s\"\n", pHostDev->pszId); 1804 } 1805 1806 PDMAudioHostEnumDelete(&Enum); 1807 } 1808 else 1809 rcExit = RTMsgErrorExitFailure("Enumeration failed: %Rrc\n", rc); 1810 } 1811 else 1812 rcExit = RTMsgErrorExitFailure("Enumeration not supported by backend '%s'\n", pDrvReg->szName); 1813 audioTestDriverStackDelete(&DrvStack); 1814 } 1815 else 1816 rcExit = RTMsgErrorExitFailure("Driver stack construction failed: %Rrc", rc); 1817 return RTEXITCODE_SUCCESS; 1698 1818 } 1699 1819 … … 1889 2009 1890 2010 /** 1891 * Command line parameters for test mode.2011 * Options for 'play'. 1892 2012 */ 1893 2013 static const RTGETOPTDEF g_aCmdPlayOptions[] = … … 1903 2023 }; 1904 2024 1905 /** the 'play' command option help. */2025 /** The 'play' command option help. */ 1906 2026 static DECLCALLBACK(const char *) audioTestCmdPlayHelp(PCRTGETOPTDEF pOpt) 1907 2027 { … … 1947 2067 { 1948 2068 case 'b': 1949 pDrvReg = NULL; 1950 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++) 1951 if ( strcmp(ValueUnion.psz, g_aBackends[i].pszName) == 0 1952 || strcmp(ValueUnion.psz, g_aBackends[i].pDrvReg->szName) == 0) 1953 { 1954 pDrvReg = g_aBackends[i].pDrvReg; 1955 break; 1956 } 2069 pDrvReg = audioTestFindBackendOpt(ValueUnion.psz); 1957 2070 if (pDrvReg == NULL) 1958 return RT MsgErrorExit(RTEXITCODE_SYNTAX, "Unknown backend: '%s'", ValueUnion.psz);2071 return RTEXITCODE_SYNTAX; 1959 2072 break; 1960 2073 … … 2150 2263 PCPDMDRVREG pDrvReg = g_aBackends[0].pDrvReg; 2151 2264 bool fWithDrvAudio = false; 2152 c har*pszAtsAddr = NULL;2265 const char *pszAtsAddr = NULL; 2153 2266 2154 2267 /* Argument processing loop: */ … … 2160 2273 { 2161 2274 case VKAT_SELFTEST_OPT_ATS_HOST: 2162 {2163 2275 pszAtsAddr = RTStrDup(ValueUnion.psz); 2164 2276 break; 2165 }2166 2277 2167 2278 case 'b': 2168 { 2169 pDrvReg = NULL; 2170 for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++) 2171 if ( strcmp(ValueUnion.psz, g_aBackends[i].pszName) == 0 2172 || strcmp(ValueUnion.psz, g_aBackends[i].pDrvReg->szName) == 0) 2173 { 2174 pDrvReg = g_aBackends[i].pDrvReg; 2175 break; 2176 } 2279 pDrvReg = audioTestFindBackendOpt(ValueUnion.psz); 2177 2280 if (pDrvReg == NULL) 2178 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unknown backend: '%s'", ValueUnion.psz); 2179 break; 2180 } 2281 return RTEXITCODE_SYNTAX; 2282 break; 2181 2283 2182 2284 case 'd': 2183 {2184 2285 fWithDrvAudio = true; 2185 2286 break; 2186 }2187 2188 case VINF_GETOPT_NOT_OPTION:2189 {2190 break;2191 }2192 2287 2193 2288 AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion); … … 2238 2333 "Verifies a formerly created audio test set.", 2239 2334 g_aCmdVerifyOptions, RT_ELEMENTS(g_aCmdVerifyOptions), NULL, 2335 }, 2336 { 2337 "enum", audioTestCmdEnumHandler, 2338 "Enumerates audio devices.", 2339 g_aCmdEnumOptions, RT_ELEMENTS(g_aCmdEnumOptions), audioTestCmdEnumHelp, 2240 2340 }, 2241 2341 {
Note:
See TracChangeset
for help on using the changeset viewer.