Changeset 91088 in vbox
- Timestamp:
- Sep 2, 2021 11:53:54 AM (3 years ago)
- Location:
- trunk/src/VBox/ValidationKit/utils/audio
- Files:
-
- 4 edited
-
vkat.cpp (modified) (4 diffs)
-
vkatCmdGeneric.cpp (modified) (6 diffs)
-
vkatDriverStack.cpp (modified) (1 diff)
-
vkatInternal.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r91087 r91088 70 70 *********************************************************************************************************************************/ 71 71 /** 72 * Backends .72 * Backends description table. 73 73 * 74 74 * @note The first backend in the array is the default one for the platform. 75 75 */ 76 struct 77 { 78 /** The driver registration structure. */ 79 PCPDMDRVREG pDrvReg; 80 /** The backend name. 81 * Aliases are implemented by having multiple entries for the same backend. */ 82 const char *pszName; 83 } const g_aBackends[] = 76 AUDIOTESTBACKENDDESC const g_aBackends[] = 84 77 { 85 78 #ifdef VBOX_WITH_AUDIO_PULSE … … 116 109 }; 117 110 AssertCompile(sizeof(g_aBackends) > 0 /* port me */); 111 /** Number of backends defined. */ 112 unsigned g_cBackends = RT_ELEMENTS(g_aBackends); 118 113 119 114 /** … … 206 201 static const RTGETOPTDEF g_aCmdVerifyOptions[] = 207 202 { 208 { "--tag", VKAT_VERIFY_OPT_TAG, RTGETOPT_REQ_STRING }203 { "--tag", VKAT_VERIFY_OPT_TAG, RTGETOPT_REQ_STRING } 209 204 }; 210 205 … … 926 921 927 922 AUDIOTESTDRVSTACK DrvStack; 928 for (size_t i = 0; i < RT_ELEMENTS(g_aBackends); i++) 929 { 930 if (fProbeBackends) 931 { 932 pDrvReg = g_aBackends[i].pDrvReg; 933 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Probing for backend '%s' ...\n", g_aBackends[i].pszName); 934 } 923 if (fProbeBackends) 924 rc = audioTestDriverStackProbe(&DrvStack, pDrvReg, 925 true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio); /** @todo Make in/out configurable, too. */ 926 else 935 927 rc = audioTestDriverStackInitEx(&DrvStack, pDrvReg, 936 928 true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio); /** @todo Make in/out configurable, too. */ 937 if (RT_SUCCESS(rc)) 938 { 939 if (fProbeBackends) 940 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Probing backend '%s' successful\n", g_aBackends[i].pszName); 941 break; 942 } 943 if (fProbeBackends) 944 { 945 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Probing backend '%s' failed with %Rrc, trying next one\n", 946 g_aBackends[i].pszName, rc); 947 continue; 948 } 929 if (RT_FAILURE(rc)) 949 930 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unable to init driver stack: %Rrc\n", rc); 950 }951 952 if (RT_FAILURE(rc))953 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Probing all backends failed, unable to continue\n");954 931 955 932 PPDMAUDIOHOSTDEV pDev; -
trunk/src/VBox/ValidationKit/utils/audio/vkatCmdGeneric.cpp
r90736 r91088 41 41 *********************************************************************************************************************************/ 42 42 43 44 45 /** 46 * Long option values for the 'enum' command. 47 */ 48 enum 49 { 50 VKAT_ENUM_OPT_PROBE_BACKENDS = 900 51 }; 52 43 53 /** 44 54 * Options for 'enum'. … … 46 56 static const RTGETOPTDEF g_aCmdEnumOptions[] = 47 57 { 48 { "--backend", 'b', RTGETOPT_REQ_STRING }, 58 { "--backend", 'b', RTGETOPT_REQ_STRING }, 59 { "--probe-backends", VKAT_ENUM_OPT_PROBE_BACKENDS, RTGETOPT_REQ_NOTHING } 49 60 }; 50 61 … … 55 66 switch (pOpt->iShort) 56 67 { 57 case 'b': return "The audio backend to use."; 68 case 'b': return "The audio backend to use."; 69 case VKAT_ENUM_OPT_PROBE_BACKENDS: return "Specifies whether to probe all (available) backends until a working one is found\n" 70 " Default: false"; 58 71 default: return NULL; 59 72 } 60 73 } 61 62 74 63 75 /** … … 73 85 */ 74 86 /* Option values: */ 75 PCPDMDRVREG pDrvReg = AudioTestGetDefaultBackend(); 87 PCPDMDRVREG pDrvReg = AudioTestGetDefaultBackend(); 88 bool fProbeBackends = false; 76 89 77 90 /* Argument processing loop: */ … … 88 101 break; 89 102 103 case VKAT_ENUM_OPT_PROBE_BACKENDS: 104 fProbeBackends = ValueUnion.f; 105 break; 106 90 107 AUDIO_TEST_COMMON_OPTION_CASES(ValueUnion); 91 108 … … 95 112 } 96 113 114 int rc; 115 116 AUDIOTESTDRVSTACK DrvStack; 117 if (fProbeBackends) 118 rc = audioTestDriverStackProbe(&DrvStack, pDrvReg, 119 true /* fEnabledIn */, true /* fEnabledOut */, false /* fWithDrvAudio */); 120 else 121 rc = audioTestDriverStackInitEx(&DrvStack, pDrvReg, 122 true /* fEnabledIn */, true /* fEnabledOut */, false /* fWithDrvAudio */); 123 if (RT_FAILURE(rc)) 124 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unable to init driver stack: %Rrc\n", rc); 125 97 126 /* 98 127 * Do the enumeration. 99 128 */ 100 RTEXITCODE rcExit = RTEXITCODE_FAILURE; 101 AUDIOTESTDRVSTACK DrvStack; 102 int rc = audioTestDriverStackInit(&DrvStack, pDrvReg, false /*fWithDrvAudio*/); 103 if (RT_SUCCESS(rc)) 104 { 105 if (DrvStack.pIHostAudio->pfnGetDevices) 129 RTEXITCODE rcExit = RTEXITCODE_FAILURE; 130 131 if (DrvStack.pIHostAudio->pfnGetDevices) 132 { 133 PDMAUDIOHOSTENUM Enum; 134 rc = DrvStack.pIHostAudio->pfnGetDevices(DrvStack.pIHostAudio, &Enum); 135 if (RT_SUCCESS(rc)) 106 136 { 107 PDMAUDIOHOSTENUM Enum; 108 rc = DrvStack.pIHostAudio->pfnGetDevices(DrvStack.pIHostAudio, &Enum); 109 if (RT_SUCCESS(rc)) 137 RTPrintf("Found %u device%s\n", Enum.cDevices, Enum.cDevices != 1 ? "s" : ""); 138 139 PPDMAUDIOHOSTDEV pHostDev; 140 RTListForEach(&Enum.LstDevices, pHostDev, PDMAUDIOHOSTDEV, ListEntry) 110 141 { 111 RTPrintf("Found %u device%s\n", Enum.cDevices, Enum.cDevices != 1 ? "s" : ""); 112 113 PPDMAUDIOHOSTDEV pHostDev; 114 RTListForEach(&Enum.LstDevices, pHostDev, PDMAUDIOHOSTDEV, ListEntry) 115 { 116 RTPrintf("\nDevice \"%s\":\n", pHostDev->pszName); 117 118 char szFlags[PDMAUDIOHOSTDEV_MAX_FLAGS_STRING_LEN]; 119 if (pHostDev->cMaxInputChannels && !pHostDev->cMaxOutputChannels && pHostDev->enmUsage == PDMAUDIODIR_IN) 120 RTPrintf(" Input: max %u channels (%s)\n", 121 pHostDev->cMaxInputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 122 else if (!pHostDev->cMaxInputChannels && pHostDev->cMaxOutputChannels && pHostDev->enmUsage == PDMAUDIODIR_OUT) 123 RTPrintf(" Output: max %u channels (%s)\n", 124 pHostDev->cMaxOutputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 125 else 126 RTPrintf(" %s: max %u output channels, max %u input channels (%s)\n", 127 PDMAudioDirGetName(pHostDev->enmUsage), pHostDev->cMaxOutputChannels, 128 pHostDev->cMaxInputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 129 130 if (pHostDev->pszId && *pHostDev->pszId) 131 RTPrintf(" ID: \"%s\"\n", pHostDev->pszId); 132 } 133 134 PDMAudioHostEnumDelete(&Enum); 142 RTPrintf("\nDevice \"%s\":\n", pHostDev->pszName); 143 144 char szFlags[PDMAUDIOHOSTDEV_MAX_FLAGS_STRING_LEN]; 145 if (pHostDev->cMaxInputChannels && !pHostDev->cMaxOutputChannels && pHostDev->enmUsage == PDMAUDIODIR_IN) 146 RTPrintf(" Input: max %u channels (%s)\n", 147 pHostDev->cMaxInputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 148 else if (!pHostDev->cMaxInputChannels && pHostDev->cMaxOutputChannels && pHostDev->enmUsage == PDMAUDIODIR_OUT) 149 RTPrintf(" Output: max %u channels (%s)\n", 150 pHostDev->cMaxOutputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 151 else 152 RTPrintf(" %s: max %u output channels, max %u input channels (%s)\n", 153 PDMAudioDirGetName(pHostDev->enmUsage), pHostDev->cMaxOutputChannels, 154 pHostDev->cMaxInputChannels, PDMAudioHostDevFlagsToString(szFlags, pHostDev->fFlags)); 155 156 if (pHostDev->pszId && *pHostDev->pszId) 157 RTPrintf(" ID: \"%s\"\n", pHostDev->pszId); 135 158 } 136 else 137 rcExit = RTMsgErrorExitFailure("Enumeration failed: %Rrc\n", rc);159 160 PDMAudioHostEnumDelete(&Enum); 138 161 } 139 162 else 140 rcExit = RTMsgErrorExitFailure("Enumeration not supported by backend '%s'\n", pDrvReg->szName); 141 audioTestDriverStackDelete(&DrvStack); 163 rcExit = RTMsgErrorExitFailure("Enumeration failed: %Rrc\n", rc); 142 164 } 143 165 else 144 rcExit = RTMsgErrorExitFailure("Driver stack construction failed: %Rrc", rc); 166 rcExit = RTMsgErrorExitFailure("Enumeration not supported by backend '%s'\n", pDrvReg->szName); 167 audioTestDriverStackDelete(&DrvStack); 168 145 169 return RTEXITCODE_SUCCESS; 146 170 } -
trunk/src/VBox/ValidationKit/utils/audio/vkatDriverStack.cpp
r90868 r91088 588 588 } 589 589 590 /** 591 * Initializes a driver stack by probing all backends in the order of appearance 592 * in the backends description table. 593 * 594 * @returns VBox status code. 595 * @param pDrvStack The driver stack to initialize. 596 * @param pDrvReg The backend driver to use. 597 * @param fEnabledIn Whether input is enabled or not on creation time. 598 * @param fEnabledOut Whether output is enabled or not on creation time. 599 * @param fWithDrvAudio Whether to include DrvAudio in the stack or not. 600 */ 601 int audioTestDriverStackProbe(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio) 602 { 603 int rc; 604 605 for (size_t i = 0; i < g_cBackends; i++) 606 { 607 pDrvReg = g_aBackends[i].pDrvReg; 608 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Probing for backend '%s' ...\n", g_aBackends[i].pszName); 609 610 rc = audioTestDriverStackInitEx(pDrvStack, pDrvReg, fEnabledIn, fEnabledOut, fWithDrvAudio); /** @todo Make in/out configurable, too. */ 611 if (RT_SUCCESS(rc)) 612 { 613 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Probing backend '%s' successful\n", g_aBackends[i].pszName); 614 return rc; 615 } 616 617 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Probing backend '%s' failed with %Rrc, trying next one\n", 618 g_aBackends[i].pszName, rc); 619 continue; 620 } 621 622 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Probing all backends failed\n"); 623 return rc; 624 } 590 625 591 626 /** -
trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h
r90918 r91088 292 292 293 293 /** 294 * Backend description. 295 */ 296 typedef struct AUDIOTESTBACKENDDESC 297 { 298 /** The driver registration structure. */ 299 PCPDMDRVREG pDrvReg; 300 /** The backend name. 301 * Aliases are implemented by having multiple entries for the same backend. */ 302 const char *pszName; 303 } AUDIOTESTBACKENDDESC; 304 305 /** 294 306 * VKAT command table entry. 295 307 */ … … 348 360 extern unsigned g_cTests; 349 361 362 extern AUDIOTESTBACKENDDESC const g_aBackends[]; 363 extern unsigned g_cBackends; 364 350 365 351 366 /********************************************************************************************************************************* … … 365 380 int audioTestDriverStackInitEx(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio); 366 381 int audioTestDriverStackInit(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio); 382 int audioTestDriverStackProbe(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio); 367 383 int audioTestDriverStackSetDevice(PAUDIOTESTDRVSTACK pDrvStack, PDMAUDIODIR enmDir, const char *pszDevId); 368 384 /** @} */
Note:
See TracChangeset
for help on using the changeset viewer.

