VirtualBox

Changeset 90830 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Aug 24, 2021 10:47:52 AM (3 years ago)
Author:
vboxsync
Message:

Audio/ValKit: More work on ATS client destruction handling. bugref:10008

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

Legend:

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

    r90788 r90830  
    257257    pTstParmsAcq->enmDir      = PDMAUDIODIR_OUT;
    258258#ifdef DEBUG
    259     pTstParmsAcq->cIterations = 4;
     259    pTstParmsAcq->cIterations = 1;
    260260#else
    261261    pTstParmsAcq->cIterations = RTRandU32Ex(1, 10);
     
    361361    pTstParmsAcq->enmDir      = PDMAUDIODIR_IN;
    362362#ifdef DEBUG
    363     pTstParmsAcq->cIterations = 4;
     363    pTstParmsAcq->cIterations = 1;
    364364#else
    365365    pTstParmsAcq->cIterations = RTRandU32Ex(1, 10);
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdSelfTest.cpp

    r90769 r90830  
    162162    /* else Step 1a later. */
    163163
    164     RTThreadSleep(5000); /* Fudge: Wait until guest ATS is up. */
     164    RTThreadSleep(2000); /* Fudge: Wait until guest ATS is up. 2 seconds should be enough (tm). */
    165165
    166166    if (RT_SUCCESS(rc))
     
    192192    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,  "Shutting down self test\n");
    193193
    194     ASMAtomicWriteBool(&g_fTerminate, true);
    195 
     194    /* If we started the guest ATS ourselves, wait for it to terminate properly. */
    196195    if (fStartGuestAts)
    197196    {
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp

    r90767 r90830  
    6161    /** File handle to the (opened) test set archive for reading. */
    6262    RTFILE        hTestSetArchive;
     63    /** Number of currently connected clients. */
     64    uint8_t       cClients;
    6365} ATSCALLBACKCTX;
    6466typedef ATSCALLBACKCTX *PATSCALLBACKCTX;
     
    463465*********************************************************************************************************************************/
    464466
     467/** @copydoc ATSCALLBACKS::pfnHowdy
     468 *
     469 *  @note Runs as part of the guest ATS.
     470 */
     471static DECLCALLBACK(int) audioTestGstAtsHowdyCallback(void const *pvUser)
     472{
     473    PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
     474
     475    AssertReturn(pCtx->cClients <= UINT8_MAX, VERR_BUFFER_OVERFLOW);
     476
     477    pCtx->cClients++;
     478
     479    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "New client connected, now %RU8 total\n", pCtx->cClients);
     480
     481    return VINF_SUCCESS;
     482}
     483
     484/** @copydoc ATSCALLBACKS::pfnBye
     485 *
     486 *  @note Runs as part of the guest ATS.
     487 */
     488static DECLCALLBACK(int) audioTestGstAtsByeCallback(void const *pvUser)
     489{
     490    PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
     491
     492    AssertReturn(pCtx->cClients, VERR_WRONG_ORDER);
     493    pCtx->cClients--;
     494
     495    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Clients wants to disconnect, %RU8 remaining\n", pCtx->cClients);
     496
     497    if (0 == pCtx->cClients) /* All clients disconnected? Tear things down. */
     498    {
     499        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Last client disconnected, terminating server ...\n");
     500        ASMAtomicWriteBool(&g_fTerminate, true);
     501    }
     502
     503    return VINF_SUCCESS;
     504}
     505
    465506/** @copydoc ATSCALLBACKS::pfnTestSetBegin
    466507 *
     
    870911        ATSCALLBACKS Callbacks;
    871912        RT_ZERO(Callbacks);
     913        Callbacks.pfnHowdy            = audioTestGstAtsHowdyCallback;
     914        Callbacks.pfnBye              = audioTestGstAtsByeCallback;
    872915        Callbacks.pfnTestSetBegin     = audioTestGstAtsTestSetBeginCallback;
    873916        Callbacks.pfnTestSetEnd       = audioTestGstAtsTestSetEndCallback;
     
    9651008        return;
    9661009
     1010    /* When in host mode, we need to destroy our ATS clients in order to also let
     1011     * the ATS server(s) know we're going to quit. */
     1012    if (pTstEnv->enmMode == AUDIOTESTMODE_HOST)
     1013    {
     1014        AudioTestSvcClientDestroy(&pTstEnv->u.Host.AtsClValKit);
     1015        AudioTestSvcClientDestroy(&pTstEnv->u.Host.AtsClGuest);
     1016    }
     1017
    9671018    for (unsigned i = 0; i < RT_ELEMENTS(pTstEnv->aStreams); i++)
    9681019    {
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