VirtualBox

Ignore:
Timestamp:
Aug 20, 2021 5:30:57 PM (3 years ago)
Author:
vboxsync
Message:

Audio/ValKit: Decoupled the driver stack from the test environment, so that two test environments can use the same driver stack -- needed for self-tests and also is a cleaner solution. bugref:10008

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp

    r90724 r90766  
    7070static int audioTestStreamInit(PAUDIOTESTDRVSTACK pDrvStack, PAUDIOTESTSTREAM pStream, PDMAUDIODIR enmDir, PCPDMAUDIOPCMPROPS pProps, bool fWithMixer, uint32_t cMsBufferSize, uint32_t cMsPreBuffer, uint32_t cMsSchedulingHint);
    7171static int audioTestStreamDestroy(PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream);
    72 static int audioTestDevicesEnumerateAndCheck(PAUDIOTESTENV pTstEnv, const char *pszDev, PPDMAUDIOHOSTDEV *ppDev);
    7372
    7473
     
    8180 *
    8281 * @returns VBox status code.
    83  * @param   pTstEnv             Test env to use for enumeration.
     82 * @param   pDrvStack           Driver stack to use for enumeration.
    8483 * @param   pszDev              Device name to search for. Can be NULL if the default device shall be used.
    8584 * @param   ppDev               Where to return the pointer of the device enumeration of \a pTstEnv when a
    8685 *                              specific device was found.
    8786 */
    88 static int audioTestDevicesEnumerateAndCheck(PAUDIOTESTENV pTstEnv, const char *pszDev, PPDMAUDIOHOSTDEV *ppDev)
     87int audioTestDevicesEnumerateAndCheck(PAUDIOTESTDRVSTACK pDrvStack, const char *pszDev, PPDMAUDIOHOSTDEV *ppDev)
    8988{
    9089    RTTestSubF(g_hTest, "Enumerating audio devices and checking for device '%s'", pszDev && *pszDev ? pszDev : "<Default>");
    9190
    92     if (!pTstEnv->DrvStack.pIHostAudio->pfnGetDevices)
     91    if (!pDrvStack->pIHostAudio->pfnGetDevices)
    9392    {
    9493        RTTestSkipped(g_hTest, "Backend does not support device enumeration, skipping");
     
    101100        *ppDev = NULL;
    102101
    103     int rc = pTstEnv->DrvStack.pIHostAudio->pfnGetDevices(pTstEnv->DrvStack.pIHostAudio, &pTstEnv->DevEnum);
     102    int rc = pDrvStack->pIHostAudio->pfnGetDevices(pDrvStack->pIHostAudio, &pDrvStack->DevEnum);
    104103    if (RT_SUCCESS(rc))
    105104    {
    106105        PPDMAUDIOHOSTDEV pDev;
    107         RTListForEach(&pTstEnv->DevEnum.LstDevices, pDev, PDMAUDIOHOSTDEV, ListEntry)
     106        RTListForEach(&pDrvStack->DevEnum.LstDevices, pDev, PDMAUDIOHOSTDEV, ListEntry)
    108107        {
    109108            char szFlags[PDMAUDIOHOSTDEV_MAX_FLAGS_STRING_LEN];
     
    199198        /** @todo Anything else to do here, e.g. test if there are left over samples or some such? */
    200199
    201         audioTestDriverStackStreamDestroy(&pTstEnv->DrvStack, pStream->pStream);
     200        audioTestDriverStackStreamDestroy(pTstEnv->pDrvStack, pStream->pStream);
    202201        pStream->pStream  = NULL;
    203202        pStream->pBackend = NULL;
     
    504503    const PAUDIOTESTSTREAM pTstStream = &pTstEnv->aStreams[0]; /** @todo Make this dynamic. */
    505504
    506     int rc = audioTestStreamInit(&pTstEnv->DrvStack, pTstStream, PDMAUDIODIR_OUT, &pTstEnv->Props, false /* fWithMixer */,
     505    int rc = audioTestStreamInit(pTstEnv->pDrvStack, pTstStream, PDMAUDIODIR_OUT, &pTstEnv->Props, false /* fWithMixer */,
    507506                                 pTstEnv->cMsBufferSize, pTstEnv->cMsPreBuffer, pTstEnv->cMsSchedulingHint);
    508507    if (RT_SUCCESS(rc))
     
    545544    const PAUDIOTESTSTREAM pTstStream = &pTstEnv->aStreams[0]; /** @todo Make this dynamic. */
    546545
    547     int rc = audioTestStreamInit(&pTstEnv->DrvStack, pTstStream, PDMAUDIODIR_IN, &pTstEnv->Props, false /* fWithMixer */,
     546    int rc = audioTestStreamInit(pTstEnv->pDrvStack, pTstStream, PDMAUDIODIR_IN, &pTstEnv->Props, false /* fWithMixer */,
    548547                                 pTstEnv->cMsBufferSize, pTstEnv->cMsPreBuffer, pTstEnv->cMsSchedulingHint);
    549548    if (RT_SUCCESS(rc))
     
    795794 * @param   fWithDrvAudio       Whether to include DrvAudio in the stack or not.
    796795 */
    797 int audioTestEnvInit(PAUDIOTESTENV pTstEnv,
    798                      PCPDMDRVREG pDrvReg, bool fWithDrvAudio)
     796int audioTestEnvInit(PAUDIOTESTENV pTstEnv, PAUDIOTESTDRVSTACK pDrvStack)
    799797{
    800798    int rc = VINF_SUCCESS;
     799
     800    pTstEnv->pDrvStack = pDrvStack;
    801801
    802802    /*
     
    821821    }
    822822
    823     /* Go with the platform's default backend if nothing else is set. */
    824     if (!pDrvReg)
    825         pDrvReg = AudioTestGetDefaultBackend();
    826 
    827823    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Initializing environment for mode '%s'\n", pTstEnv->enmMode == AUDIOTESTMODE_HOST ? "host" : "guest");
    828     RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using backend '%s'\n", pDrvReg->szName);
    829824    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using tag '%s'\n", pTstEnv->szTag);
    830825    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Output directory is '%s'\n", pTstEnv->szPathOut);
     
    837832    if (!pTstEnv->cMsSchedulingHint)
    838833        pTstEnv->cMsSchedulingHint = UINT32_MAX;
    839 
    840     PDMAudioHostEnumInit(&pTstEnv->DevEnum);
    841 
    842     bool fUseDriverStack = false; /* Whether to init + use the audio driver stack or not. */
    843 
    844     /* In regular testing mode only the guest mode needs initializing the driver stack. */
    845     if (pTstEnv->enmMode == AUDIOTESTMODE_GUEST)
    846         fUseDriverStack = true;
    847 
    848     /* When running in self-test mode, the host mode also needs to initialize the stack in order to
    849      * to run the Valdation Kit audio driver ATS (no "real" VBox involved). */
    850     if (pTstEnv->enmMode == AUDIOTESTMODE_HOST && pTstEnv->fSelftest)
    851         fUseDriverStack = true;
    852 
    853     if (fUseDriverStack)
    854     {
    855         rc = audioTestDriverStackInitEx(&pTstEnv->DrvStack, pDrvReg,
    856                                         true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio);
    857         if (RT_FAILURE(rc))
    858             return rc;
    859 
    860         PPDMAUDIOHOSTDEV pDev;
    861         rc = audioTestDevicesEnumerateAndCheck(pTstEnv, pTstEnv->szDev, &pDev);
    862         if (RT_FAILURE(rc))
    863             return rc;
    864     }
    865834
    866835    char szPathTemp[RTPATH_MAX];
     
    983952    }
    984953
    985     if (   RT_FAILURE(rc)
    986         && fUseDriverStack)
    987         audioTestDriverStackDelete(&pTstEnv->DrvStack);
    988 
    989954    return rc;
    990955}
     
    999964    if (!pTstEnv)
    1000965        return;
    1001 
    1002     PDMAudioHostEnumDelete(&pTstEnv->DevEnum);
    1003966
    1004967    for (unsigned i = 0; i < RT_ELEMENTS(pTstEnv->aStreams); i++)
     
    1013976    RTDirRemove(pTstEnv->szPathOut);
    1014977
    1015     audioTestDriverStackDelete(&pTstEnv->DrvStack);
     978    pTstEnv->pDrvStack = NULL;
    1016979}
    1017980
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette