VirtualBox

Changeset 90766 in vbox for trunk


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

Location:
trunk/src/VBox/ValidationKit/utils/audio
Files:
5 edited

Legend:

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

    r90721 r90766  
    246246    if (strlen(pTstEnv->szDev))
    247247    {
    248         rc = audioTestDriverStackSetDevice(&pTstEnv->DrvStack, PDMAUDIODIR_OUT, pTstEnv->szDev);
     248        rc = audioTestDriverStackSetDevice(pTstEnv->pDrvStack, PDMAUDIODIR_OUT, pTstEnv->szDev);
    249249        if (RT_FAILURE(rc))
    250250            return rc;
     
    350350    if (strlen(pTstEnv->szDev))
    351351    {
    352         rc = audioTestDriverStackSetDevice(&pTstEnv->DrvStack, PDMAUDIODIR_IN, pTstEnv->szDev);
     352        rc = audioTestDriverStackSetDevice(pTstEnv->pDrvStack, PDMAUDIODIR_IN, pTstEnv->szDev);
    353353        if (RT_FAILURE(rc))
    354354            return rc;
     
    857857        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "No test mode (--mode) specified!\n");
    858858
    859     /* For now all tests have the same test environment. */
    860     rc = audioTestEnvInit(&TstEnv, pDrvReg, fWithDrvAudio);
     859    AUDIOTESTDRVSTACK DrvStack;
     860    rc = audioTestDriverStackInitEx(&DrvStack, pDrvReg,
     861                                    true /* fEnabledIn */, true /* fEnabledOut */, fWithDrvAudio); /** @todo Make in/out configurable, too. */
     862    if (RT_FAILURE(rc))
     863        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unable to init driver stack: %Rrc\n", rc);
     864
     865    PPDMAUDIOHOSTDEV pDev;
     866    rc = audioTestDevicesEnumerateAndCheck(&DrvStack, TstEnv.szDev, &pDev);
     867    if (RT_FAILURE(rc))
     868        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Enumerating device(s) failed: %Rrc\n", rc);
     869
     870    /* For now all tests have the same test environment and driver stack. */
     871    rc = audioTestEnvInit(&TstEnv, &DrvStack);
    861872    if (RT_SUCCESS(rc))
    862873        rc = audioTestWorker(&TstEnv);
    863874
    864875    audioTestEnvDestroy(&TstEnv);
     876    audioTestDriverStackDelete(&DrvStack);
    865877
    866878    if (RT_FAILURE(rc)) /* Let us know that something went wrong in case we forgot to mention it. */
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdSelfTest.cpp

    r90721 r90766  
    7777                      2 /* 16-bit */, true  /* fSigned */, 2 /* cChannels */, 44100 /* uHz */);
    7878
    79     rc = audioTestEnvInit(pTstEnvGst, pTstEnvGst->DrvStack.pDrvReg, pCtx->fWithDrvAudio);
     79    rc = audioTestEnvInit(pTstEnvGst, &pCtx->DrvStack);
    8080    if (RT_SUCCESS(rc))
    8181    {
     
    150150    /* else Step 1a later. */
    151151
     152    RTThreadSleep(5000); /* Fudge: Wait until guest ATS is up. */
     153
    152154    if (RT_SUCCESS(rc))
    153155    {
     
    157159        pTstEnvHst->enmMode = AUDIOTESTMODE_HOST;
    158160
    159         rc = audioTestEnvInit(pTstEnvHst, &g_DrvHostValidationKitAudio, true /* fWithDrvAudio */);
     161        rc = audioTestEnvInit(pTstEnvHst, &pCtx->DrvStack);
    160162        if (RT_SUCCESS(rc))
    161163        {
     
    260262    RT_ZERO(Ctx);
    261263
    262     /* Go with the platform's default backend if nothing else is specified. */
    263     Ctx.Guest.pDrvReg = AudioTestGetDefaultBackend();
    264 
    265264    /* Argument processing loop: */
    266265    int           rc;
     
    292291
    293292            case 'b':
    294                 Ctx.Guest.pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
    295                 if (Ctx.Guest.pDrvReg == NULL)
     293                Ctx.pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
     294                if (Ctx.pDrvReg == NULL)
    296295                    return RTEXITCODE_SYNTAX;
    297296                break;
     
    320319    }
    321320
     321    /* Go with the Validation Kit audio backend if nothing else is specified. */
     322    if (Ctx.pDrvReg == NULL)
     323        Ctx.pDrvReg = AudioTestFindBackendOpt("valkit");
     324
     325    /*
     326     * In self-test mode the guest and the host side have to share the same driver stack,
     327     * as we don't have any device emulation between the two sides.
     328     *
     329     * This is necessary to actually get the played/recorded audio to from/to the guest
     330     * and host respectively.
     331     *
     332     * Choosing any other backend than the Validation Kit above *will* break this self-test!
     333     */
     334    rc = audioTestDriverStackInitEx(&Ctx.DrvStack, Ctx.pDrvReg,
     335                                    true /* fEnabledIn */, true /* fEnabledOut */, Ctx.fWithDrvAudio);
     336    if (RT_FAILURE(rc))
     337        return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Unable to init driver stack: %Rrc\n", rc);
     338
    322339    /*
    323340     * Start testing.
     
    328345    if (RT_FAILURE(rc2))
    329346        RTTestFailed(g_hTest, "Self test failed with rc=%Rrc", rc2);
     347
     348    audioTestDriverStackDelete(&Ctx.DrvStack);
    330349
    331350    /*
  • 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
  • trunk/src/VBox/ValidationKit/utils/audio/vkatDriverStack.cpp

    r89575 r90766  
    486486    pDrvStack->pDrvAudioIns     = NULL;
    487487    pDrvStack->pIAudioConnector = NULL;
     488
     489    PDMAudioHostEnumDelete(&pDrvStack->DevEnum);
    488490}
    489491
     
    505507    RT_ZERO(*pDrvStack);
    506508    pDrvStack->pDrvReg = pDrvReg;
     509
     510    PDMAudioHostEnumInit(&pDrvStack->DevEnum);
    507511
    508512    if (!fWithDrvAudio)
  • trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h

    r90723 r90766  
    7272    /** This is NULL if we don't use DrvAudio. */
    7373    PPDMIAUDIOCONNECTOR     pIAudioConnector;
     74
     75    /** The current (last) audio device enumeration to use. */
     76    PDMAUDIOHOSTENUM        DevEnum;
    7477} AUDIOTESTDRVSTACK;
    7578/** Pointer to an audio driver stack. */
     
    222225    /** Scheduling hint (in ms). */
    223226    RTMSINTERVAL            cMsSchedulingHint;
    224     /** The audio test driver stack. */
    225     AUDIOTESTDRVSTACK       DrvStack;
    226     /** The current (last) audio device enumeration to use. */
    227     PDMAUDIOHOSTENUM        DevEnum;
     227    /** Pointer to audio test driver stack to use. */
     228    PAUDIOTESTDRVSTACK      pDrvStack;
    228229    /** Audio stream. */
    229230    AUDIOTESTSTREAM         aStreams[AUDIOTESTENV_MAX_STREAMS];
     
    282283    /** Whether to use DrvAudio in the driver stack or not. */
    283284    bool             fWithDrvAudio;
     285    AUDIOTESTDRVSTACK DrvStack;
     286    /** Audio driver to use.
     287     *  Defaults to the platform's default driver. */
     288    PCPDMDRVREG      pDrvReg;
    284289    struct
    285290    {
    286291        AUDIOTESTENV TstEnv;
    287         /** Audio driver to use.
    288          *  Defaults to the platform's default driver. */
    289         PCPDMDRVREG  pDrvReg;
    290292        /** Where to bind the address of the guest ATS instance to.
    291293         *  Defaults to localhost (127.0.0.1) if empty. */
     
    443445int         audioTestDeviceOpen(PPDMAUDIOHOSTDEV pDev);
    444446int         audioTestDeviceClose(PPDMAUDIOHOSTDEV pDev);
     447
     448int         audioTestDevicesEnumerateAndCheck(PAUDIOTESTDRVSTACK pDrvStack, const char *pszDev, PPDMAUDIOHOSTDEV *ppDev);
    445449/** @}  */
    446450
     
    453457/** @name Test environment handling
    454458 * @{ */
    455 int         audioTestEnvInit(PAUDIOTESTENV pTstEnv, PCPDMDRVREG pDrvReg, bool fWithDrvAudio);
     459int         audioTestEnvInit(PAUDIOTESTENV pTstEnv, PAUDIOTESTDRVSTACK pDrvStack);
    456460void        audioTestEnvDestroy(PAUDIOTESTENV pTstEnv);
    457461int         audioTestEnvPrologue(PAUDIOTESTENV pTstEnv, bool fPack, char *pszPackFile, size_t cbPackFile);
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