Changeset 89117 in vbox for trunk/src/VBox/ValidationKit/utils/audio
- Timestamp:
- May 17, 2021 5:33:27 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r89115 r89117 127 127 typedef FNAUDIOTESTDESTROY *PFNAUDIOTESTDESTROY; 128 128 129 /** 130 * Audio driver stack. 131 * 132 * This can be just be backend driver alone or DrvAudio with a backend. 133 * @todo add automatic resampling via mixer so we can test more of the audio 134 * stack used by the device emulations. 135 */ 136 typedef struct AUDIOTESTDRVSTACK 137 { 138 /** The device registration record for the backend. */ 139 PCPDMDRVREG pDrvReg; 140 /** The backend driver instance. */ 141 PPDMDRVINS pDrvBackendIns; 142 /** The backend's audio interface. */ 143 PPDMIHOSTAUDIO pIHostAudio; 144 145 /** The DrvAudio instance. */ 146 PPDMDRVINS pDrvAudioIns; 147 /** This is NULL if we don't use DrvAudio. */ 148 PPDMIAUDIOCONNECTOR pIAudioConnector; 149 } AUDIOTESTDRVSTACK; 150 /** Pointer to an audio driver stack. */ 151 typedef AUDIOTESTDRVSTACK *PAUDIOTESTDRVSTACK; 152 153 /** 154 * Backend-only stream structure. 155 */ 156 typedef struct AUDIOTESTDRVSTACKSTREAM 157 { 158 /** The public stream data. */ 159 PDMAUDIOSTREAM Core; 160 /** The acquired config. */ 161 PDMAUDIOSTREAMCFG Cfg; 162 /** The backend data (variable size). */ 163 PDMAUDIOBACKENDSTREAM Backend; 164 } AUDIOTESTDRVSTACKSTREAM; 165 /** Pointer to a backend-only stream structure. */ 166 typedef AUDIOTESTDRVSTACKSTREAM *PAUDIOTESTDRVSTACKSTREAM; 167 129 168 /** Maximum audio streams a test environment can handle. */ 130 169 #define AUDIOTESTENV_MAX_STREAMS 8 … … 140 179 /** Temporary path for this test environment. */ 141 180 char szPathTemp[RTPATH_MAX]; 142 /** The host (backend) driver to use. */143 PPDMIHOSTAUDIO pDrvAudio;181 /** The audio test driver stack. */ 182 AUDIOTESTDRVSTACK DrvStack; 144 183 /** The current (last) audio device enumeration to use. */ 145 184 PDMAUDIOHOSTENUM DevEnum; … … 166 205 PFNAUDIOTESTDESTROY pfnDestroy; 167 206 } AUDIOTESTDESC; 168 169 170 /**171 * Audio driver stack.172 *173 * This can be just be backend driver alone or DrvAudio with a backend.174 * @todo add automatic resampling via mixer so we can test more of the audio175 * stack used by the device emulations.176 */177 typedef struct AUDIOTESTDRVSTACK178 {179 /** The device registration record for the backend. */180 PCPDMDRVREG pDrvReg;181 /** The backend driver instance. */182 PPDMDRVINS pDrvBackendIns;183 /** The backend's audio interface. */184 PPDMIHOSTAUDIO pIHostAudio;185 186 /** The DrvAudio instance. */187 PPDMDRVINS pDrvAudioIns;188 /** This is NULL if we don't use DrvAudio. */189 PPDMIAUDIOCONNECTOR pIAudioConnector;190 } AUDIOTESTDRVSTACK;191 /** Pointer to an audio driver stack. */192 typedef AUDIOTESTDRVSTACK *PAUDIOTESTDRVSTACK;193 194 /**195 * Backend-only stream structure.196 */197 typedef struct AUDIOTESTDRVSTACKSTREAM198 {199 /** The public stream data. */200 PDMAUDIOSTREAM Core;201 /** The acquired config. */202 PDMAUDIOSTREAMCFG Cfg;203 /** The backend data (variable size). */204 PDMAUDIOBACKENDSTREAM Backend;205 } AUDIOTESTDRVSTACKSTREAM;206 /** Pointer to a backend-only stream structure. */207 typedef AUDIOTESTDRVSTACKSTREAM *PAUDIOTESTDRVSTACKSTREAM;208 207 209 208 … … 277 276 { 278 277 { "--backend", 'b', RTGETOPT_REQ_STRING }, 278 { "--drvaudio", 'd', RTGETOPT_REQ_NOTHING }, 279 279 { "--exclude", 'e', RTGETOPT_REQ_UINT32 }, 280 280 { "--exclude-all", 'a', RTGETOPT_REQ_NOTHING }, … … 412 412 pszRet = g_pszDrvAudioDebug; 413 413 414 AssertPtrReturn(pszRet, VERR_INVALID_POINTER); 415 414 416 int rc = RTStrCopy(pszString, cchString, pszRet); 415 417 … … 755 757 * @param pDrvStack The driver stack to initialize. 756 758 * @param pDrvReg The backend driver to use. 757 * @param fWithDrvAudio Whether to in lcude DrvAudio in the stack or not.759 * @param fWithDrvAudio Whether to include DrvAudio in the stack or not. 758 760 */ 759 761 static int audioTestDriverStackInit(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio) … … 1213 1215 * 1214 1216 * @param pTstEnv Audio test environment to initialize. 1215 * @param pDrvAudio Audio driver to use. 1216 * @param pszPathOut Output path to use. If NULL, the system's temp directory will be used. 1217 * @param pszPathTemp Temporary path to use. If NULL, the system's temp directory will be used. 1217 * @param pDrvReg Audio driver to use. 1218 * @param fWithDrvAudio Whether to include DrvAudio in the stack or not. 1218 1219 * @param pszTag Tag name to use. If NULL, a generated UUID will be used. 1219 1220 */ 1220 static int audioTestEnvInit(PAUDIOTESTENV pTstEnv, PPDMIHOSTAUDIO pDrvAudio, const char *pszTag) 1221 { 1222 pTstEnv->pDrvAudio = pDrvAudio; 1221 static int audioTestEnvInit(PAUDIOTESTENV pTstEnv, PCPDMDRVREG pDrvReg, bool fWithDrvAudio, const char *pszTag) 1222 { 1223 1223 PDMAudioHostEnumInit(&pTstEnv->DevEnum); 1224 1224 1225 int rc = VINF_SUCCESS; 1225 int rc = audioTestDriverStackInit(&pTstEnv->DrvStack, pDrvReg, fWithDrvAudio); 1226 if (RT_FAILURE(rc)) 1227 return rc; 1226 1228 1227 1229 char szPathTemp[RTPATH_MAX]; … … 1248 1250 } 1249 1251 1252 if (RT_FAILURE(rc)) 1253 audioTestDriverStackDelete(&pTstEnv->DrvStack); 1254 1250 1255 return rc; 1251 1256 } … … 1271 1276 1272 1277 AudioTestSetDestroy(&pTstEnv->Set); 1278 audioTestDriverStackDelete(&pTstEnv->DrvStack); 1273 1279 } 1274 1280 … … 1314 1320 RTTestSubF(g_hTest, "Enumerating audio devices and checking for device '%s'", pszDev ? pszDev : "<Default>"); 1315 1321 1316 if (!pTstEnv-> pDrvAudio->pfnGetDevices)1322 if (!pTstEnv->DrvStack.pIHostAudio->pfnGetDevices) 1317 1323 { 1318 1324 RTTestSkipped(g_hTest, "Backend does not support device enumeration, skipping"); … … 1325 1331 *ppDev = NULL; 1326 1332 1327 int rc = pTstEnv-> pDrvAudio->pfnGetDevices(pTstEnv->pDrvAudio, &pTstEnv->DevEnum);1333 int rc = pTstEnv->DrvStack.pIHostAudio->pfnGetDevices(pTstEnv->DrvStack.pIHostAudio, &pTstEnv->DevEnum); 1328 1334 if (RT_SUCCESS(rc)) 1329 1335 { … … 1413 1419 AssertRC(rc); /* Cannot fail. */ 1414 1420 1415 rc = pTstEnv-> pDrvAudio->pfnStreamCreate(pTstEnv->pDrvAudio, &pStream->Backend, pCfg, &CfgAcq);1421 rc = pTstEnv->DrvStack.pIHostAudio->pfnStreamCreate(pTstEnv->DrvStack.pIHostAudio, &pStream->Backend, pCfg, &CfgAcq); 1416 1422 if (RT_FAILURE(rc)) 1417 1423 return rc; … … 1419 1425 /* Do the async init in a synchronous way for now here. */ 1420 1426 if (rc == VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED) 1421 rc = pTstEnv-> pDrvAudio->pfnStreamInitAsync(pTstEnv->pDrvAudio, &pStream->Backend, false /* fDestroyed */);1427 rc = pTstEnv->DrvStack.pIHostAudio->pfnStreamInitAsync(pTstEnv->DrvStack.pIHostAudio, &pStream->Backend, false /* fDestroyed */); 1422 1428 1423 1429 if (RT_SUCCESS(rc)) … … 1444 1450 /** @todo Anything else to do here, e.g. test if there are left over samples or some such? */ 1445 1451 1446 int rc = pTstEnv-> pDrvAudio->pfnStreamDestroy(pTstEnv->pDrvAudio, &pStream->Backend);1452 int rc = pTstEnv->DrvStack.pIHostAudio->pfnStreamDestroy(pTstEnv->DrvStack.pIHostAudio, &pStream->Backend); 1447 1453 if (RT_SUCCESS(rc)) 1448 1454 RT_BZERO(pStream, sizeof(PDMAUDIOBACKENDSTREAM)); … … 1503 1509 AssertRCReturn(rc, rc); 1504 1510 1505 PDMHOSTAUDIOSTREAMSTATE enmState = pTstEnv-> pDrvAudio->pfnStreamGetState(pTstEnv->pDrvAudio, &pStream->Backend);1511 PDMHOSTAUDIOSTREAMSTATE enmState = pTstEnv->DrvStack.pIHostAudio->pfnStreamGetState(pTstEnv->DrvStack.pIHostAudio, &pStream->Backend); 1506 1512 if (enmState == PDMHOSTAUDIOSTREAMSTATE_OKAY) 1507 1513 { … … 1523 1529 { 1524 1530 uint32_t cbWritten; 1525 rc = pTstEnv-> pDrvAudio->pfnStreamPlay(pTstEnv->pDrvAudio, &pStream->Backend, abBuf, cbBuf, &cbWritten);1531 rc = pTstEnv->DrvStack.pIHostAudio->pfnStreamPlay(pTstEnv->DrvStack.pIHostAudio, &pStream->Backend, abBuf, cbBuf, &cbWritten); 1526 1532 } 1527 1533 } … … 1732 1738 switch (pOpt->iShort) 1733 1739 { 1734 case 'd': return "Use the specified audio device"; 1735 case 'e': return "Exclude the given test id from the list"; 1736 case 'a': return "Exclude all tests from the list (useful to enable single tests later with --include)"; 1737 case 'i': return "Include the given test id in the list"; 1740 case 'd': return "Go via DrvAudio instead of directly interfacing with the backend."; 1741 case VKAT_TEST_OPT_DEV: return "Use the specified audio device"; 1742 case 'e': return "Exclude the given test id from the list"; 1743 case 'a': return "Exclude all tests from the list (useful to enable single tests later with --include)"; 1744 case 'i': return "Include the given test id in the list"; 1738 1745 } 1739 1746 return NULL; … … 1754 1761 audioTestParmsInit(&TstCust); 1755 1762 1756 const char *pszDevice = NULL; /* Custom device to use. Can be NULL if not being used. */ 1757 const char *pszTag = NULL; /* Custom tag to use. Can be NULL if not being used. */ 1758 PCPDMDRVREG pDrvReg = g_aBackends[0].pDrvReg; 1763 const char *pszDevice = NULL; /* Custom device to use. Can be NULL if not being used. */ 1764 const char *pszTag = NULL; /* Custom tag to use. Can be NULL if not being used. */ 1765 PCPDMDRVREG pDrvReg = g_aBackends[0].pDrvReg; 1766 bool fWithDrvAudio = false; 1759 1767 1760 1768 int rc; … … 1782 1790 break; 1783 1791 1792 case 'd': 1793 fWithDrvAudio = true; 1794 break; 1795 1784 1796 case 'e': 1785 1797 if (ValueUnion.u32 >= RT_ELEMENTS(g_aTests)) … … 1854 1866 RTTestBanner(g_hTest); 1855 1867 1856 AUDIOTESTDRVSTACK DrvStack;1857 rc = audioTest DriverStackInit(&DrvStack, pDrvReg, false /*fWithDrvAudio*/);1868 /* For now all tests have the same test environment. */ 1869 rc = audioTestEnvInit(&TstEnv, pDrvReg, fWithDrvAudio, pszTag); 1858 1870 if (RT_SUCCESS(rc)) 1859 1871 { 1860 /* For now all tests have the same test environment. */ 1861 /** @todo bake the DrvStack into the test env make make it more flexible so 1862 * we can also test with/without DrvAudio (need option above). */ 1863 rc = audioTestEnvInit(&TstEnv, DrvStack.pIHostAudio, pszTag); 1872 PPDMAUDIOHOSTDEV pDev; 1873 rc = audioTestDevicesEnumerateAndCheck(&TstEnv, pszDevice, &pDev); 1864 1874 if (RT_SUCCESS(rc)) 1865 { 1866 PPDMAUDIOHOSTDEV pDev; 1867 rc = audioTestDevicesEnumerateAndCheck(&TstEnv, pszDevice, &pDev); 1868 if (RT_SUCCESS(rc)) 1869 audioTestWorker(&TstEnv, &TstCust); 1870 1871 /* Before destroying the test environment, pack up the test set so 1872 * that it's ready for transmission. */ 1873 char szFileOut[RTPATH_MAX]; 1874 rc = AudioTestSetPack(&TstEnv.Set, TstEnv.szPathOut, szFileOut, sizeof(szFileOut)); 1875 if (RT_SUCCESS(rc)) 1876 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set packed up to '%s'\n", szFileOut); 1877 1878 /* Clean up. */ 1879 int rc2 = AudioTestSetWipe(&TstEnv.Set); 1880 AssertRC(rc2); /* Annoying, but not test-critical. */ 1881 1882 audioTestEnvDestroy(&TstEnv); 1883 } 1884 audioTestDriverStackDelete(&DrvStack); 1875 audioTestWorker(&TstEnv, &TstCust); 1876 1877 /* Before destroying the test environment, pack up the test set so 1878 * that it's ready for transmission. */ 1879 char szFileOut[RTPATH_MAX]; 1880 rc = AudioTestSetPack(&TstEnv.Set, TstEnv.szPathOut, szFileOut, sizeof(szFileOut)); 1881 if (RT_SUCCESS(rc)) 1882 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set packed up to '%s'\n", szFileOut); 1883 1884 /* Clean up. */ 1885 int rc2 = AudioTestSetWipe(&TstEnv.Set); 1886 AssertRC(rc2); /* Annoying, but not test-critical. */ 1887 1888 audioTestEnvDestroy(&TstEnv); 1885 1889 } 1886 1890
Note:
See TracChangeset
for help on using the changeset viewer.