VirtualBox

Changeset 90918 in vbox


Ignore:
Timestamp:
Aug 26, 2021 3:29:25 PM (3 years ago)
Author:
vboxsync
Message:

Audio/Validation Kit: Simplified ATS init / destruction handling. bugref:10008

Location:
trunk/src/VBox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioTestService.cpp

    r90911 r90918  
    10371037
    10381038/**
    1039  * Creates an ATS instance.
     1039 * Initializes an ATS instance.
     1040 *
     1041 * @note This does *not* start the server!
    10401042 *
    10411043 * @returns VBox status code.
    1042  * @param   pThis               The ATS instance to create.
    1043  */
    1044 int AudioTestSvcCreate(PATSSERVER pThis)
    1045 {
    1046     /*
    1047      * The default transporter is the first one.
    1048      */
    1049     pThis->pTransport = g_apTransports[0]; /** @todo Make this dynamic. */
    1050 
    1051     return pThis->pTransport->pfnCreate(&pThis->pTransportInst);
    1052 }
    1053 
    1054 /**
    1055  * Initializes an ATS instance.
    1056  *
    1057  * @returns VBox status code.
    10581044 * @param   pThis               The ATS instance.
    10591045 * @param   pCallbacks          The callbacks table to use.
     
    10611047int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks)
    10621048{
     1049    RT_BZERO(pThis, sizeof(ATSSERVER));
     1050
     1051    pThis->hPipeR = NIL_RTPIPE;
     1052    pThis->hPipeW = NIL_RTPIPE;
     1053
     1054    RTListInit(&pThis->LstClientsNew);
     1055
     1056    /* Copy callback table. */
    10631057    memcpy(&pThis->Callbacks, pCallbacks, sizeof(ATSCALLBACKS));
    10641058
    1065     pThis->fStarted   = false;
    1066     pThis->fTerminate = false;
    1067 
    1068     pThis->hPipeR     = NIL_RTPIPE;
    1069     pThis->hPipeW     = NIL_RTPIPE;
    1070 
    1071     RTListInit(&pThis->LstClientsNew);
    1072 
    1073     /*
    1074      * Initialize the transport layer.
    1075      */
    10761059    int rc = RTCritSectInit(&pThis->CritSectClients);
    10771060    if (RT_SUCCESS(rc))
     
    10831066            if (RT_SUCCESS(rc))
    10841067            {
    1085                 /* Spin off the thread serving connections. */
    1086                 rc = RTThreadCreate(&pThis->hThreadServing, atsClientWorker, pThis, 0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE,
    1087                                     "AUDTSTSRVC");
     1068                /*
     1069                 * The default transporter is the first one.
     1070                 */
     1071                pThis->pTransport = g_apTransports[0]; /** @todo Make this dynamic. */
     1072
     1073                rc =  pThis->pTransport->pfnCreate(&pThis->pTransportInst);
    10881074                if (RT_SUCCESS(rc))
    10891075                    return VINF_SUCCESS;
    1090                 else
    1091                     LogRel(("Creating the client worker thread failed with %Rrc\n", rc));
    10921076
    10931077                RTPipeClose(pThis->hPipeR);
     
    11051089    }
    11061090    else
    1107         LogRel(("Creating global critical section failed with %Rrc\n", rc));
     1091        LogRel(("Creating critical section failed with %Rrc\n", rc));
     1092
     1093    if (RT_FAILURE(rc))
     1094        LogRel(("Creating server failed with %Rrc\n", rc));
    11081095
    11091096    return rc;
     
    11341121int AudioTestSvcStart(PATSSERVER pThis)
    11351122{
    1136     int rc = pThis->pTransport->pfnStart(pThis->pTransportInst);
     1123    /* Spin off the thread serving connections. */
     1124    int rc = RTThreadCreate(&pThis->hThreadServing, atsClientWorker, pThis, 0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE,
     1125                            "ATSCLWORK");
     1126    if (RT_FAILURE(rc))
     1127    {
     1128        LogRel(("Creating the client worker thread failed with %Rrc\n", rc));
     1129        return rc;
     1130    }
     1131
     1132    rc = pThis->pTransport->pfnStart(pThis->pTransportInst);
    11371133    if (RT_SUCCESS(rc))
    11381134    {
    11391135        /* Spin off the connection thread. */
    11401136        rc = RTThreadCreate(&pThis->hThreadMain, atsMainThread, pThis, 0, RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE,
    1141                             "AUDTSTSRVM");
     1137                            "ATSMAIN");
    11421138        if (RT_SUCCESS(rc))
    11431139        {
     
    11521148
    11531149/**
    1154  * Shuts down a formerly started ATS instance.
     1150 * Stops (shuts down) a formerly started ATS instance.
    11551151 *
    11561152 * @returns VBox status code.
    11571153 * @param   pThis               The ATS instance.
    11581154 */
    1159 int AudioTestSvcShutdown(PATSSERVER pThis)
     1155int AudioTestSvcStop(PATSSERVER pThis)
    11601156{
    11611157    if (!pThis->fStarted)
  • trunk/src/VBox/Devices/Audio/AudioTestService.h

    r90912 r90918  
    171171typedef ATSSERVER *PATSSERVER;
    172172
    173 int AudioTestSvcCreate(PATSSERVER pThis);
    174173int AudioTestSvcInit(PATSSERVER pThis, PCATSCALLBACKS pCallbacks);
    175174int AudioTestSvcDestroy(PATSSERVER pThis);
    176175int AudioTestSvcHandleOption(PATSSERVER pThis, int ch, PCRTGETOPTUNION pVal);
    177176int AudioTestSvcStart(PATSSERVER pThis);
    178 int AudioTestSvcShutdown(PATSSERVER pThis);
     177int AudioTestSvcStop(PATSSERVER pThis);
    179178
    180179/**
  • trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp

    r90912 r90918  
    11081108    /* Dont' use rc here, as this will be reported back to PDM and will prevent VBox
    11091109     * from starting -- not critical but warn the user though. */
    1110     int rc2 = AudioTestSvcCreate(&pThis->Srv);
     1110    int rc2 = AudioTestSvcInit(&pThis->Srv, &Callbacks);
    11111111    if (RT_SUCCESS(rc2))
    11121112    {
     
    11261126        AssertRC(rc2);
    11271127
    1128         rc2 = AudioTestSvcInit(&pThis->Srv, &Callbacks);
    1129         if (RT_SUCCESS(rc2))
    1130             rc2 = AudioTestSvcStart(&pThis->Srv);
     1128        rc2 = AudioTestSvcStart(&pThis->Srv);
    11311129    }
    11321130
     
    11621160    LogRel(("ValKit: Shutting down Audio Test Service (ATS) ...\n"));
    11631161
    1164     int rc = AudioTestSvcShutdown(&pThis->Srv);
     1162    int rc = AudioTestSvcStop(&pThis->Srv);
    11651163    if (RT_SUCCESS(rc))
    11661164        rc = AudioTestSvcDestroy(&pThis->Srv);
  • trunk/src/VBox/Devices/Audio/testcase/tstAudioTestService.cpp

    r90912 r90918  
    158158    RTTEST_CHECK_RC_OK(hTest, rc);
    159159
    160     rc = AudioTestSvcShutdown(&Srv);
     160    rc = AudioTestSvcStop(&Srv);
     161    RTTEST_CHECK_RC_OK(hTest, rc);
     162
     163    rc = AudioTestSvcDestroy(&Srv);
    161164    RTTEST_CHECK_RC_OK(hTest, rc);
    162165
  • trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp

    r90898 r90918  
    311311        {
    312312            /*
    313              * 2. Tell the guest ATS to start playback.
     313             * 2. Tell VKAT on guest to start playback.
    314314             */
    315             RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Telling guest VKAT to play tone ...\n");
     315            RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Telling VKAT on guest to play tone ...\n");
    316316            rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClGuest, pToneParms);
    317317            if (RT_FAILURE(rc))
     
    418418             * 2. Tell the guest ATS to start recording.
    419419             */
    420             RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Telling guest VKAT to record audio ...\n");
     420            RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Telling VKAT on guest to record audio ...\n");
    421421            rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClGuest, &pTstParms->TestTone);
    422422            if (RT_FAILURE(rc))
     
    547547        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Shutting down guest ATS ...\n");
    548548
    549         int rc2 = AudioTestSvcShutdown(&pTstEnv->Srv);
     549        int rc2 = AudioTestSvcStop(pTstEnv->pSrv);
    550550        if (RT_SUCCESS(rc))
    551551            rc = rc2;
     
    557557        RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Using tag '%s'\n", pTstEnv->szTag);
    558558
     559        RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Telling ValKit audio driver on host to begin a new test set ...\n");
    559560        rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClValKit, pTstEnv->szTag);
    560561        if (RT_SUCCESS(rc))
    561562        {
     563            RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Telling VKAT on guest to begin a new test set ...\n");
    562564            rc = AudioTestSvcClientTestSetBegin(&pTstEnv->u.Host.AtsClGuest, pTstEnv->szTag);
    563565            if (RT_FAILURE(rc))
     
    733735    RT_ZERO(TstEnv);
    734736
    735     int rc = AudioTestSvcCreate(&TstEnv.Srv);
    736     if (RT_FAILURE(rc))
    737         return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Creating ATS service instance failed with %Rrc\n", rc);
     737    int         rc;
    738738
    739739    const char *pszTag        = NULL; /* Custom tag to use. Can be NULL if not being used. */
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdSelfTest.cpp

    r90900 r90918  
    139139        RTStrCopy(pTstEnvGst->TcpOpts.szConnectAddr, sizeof(pTstEnvGst->TcpOpts.szConnectAddr), "127.0.0.1");
    140140
    141     int rc = AudioTestSvcCreate(&pTstEnvGst->Srv);
    142     AssertRCReturn(rc, rc);
    143 
    144141    /* Generate tag for guest side. */
    145     rc = RTStrCopy(pTstEnvGst->szTag, sizeof(pTstEnvGst->szTag), pCtx->szTag);
     142    int rc = RTStrCopy(pTstEnvGst->szTag, sizeof(pTstEnvGst->szTag), pCtx->szTag);
    146143    AssertRCReturn(rc, rc);
    147144
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp

    r90912 r90918  
    492492    pCtx->cClients--;
    493493
    494     RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Clients wants to disconnect, %RU8 remaining\n", pCtx->cClients);
     494    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Client wants to disconnect, %RU8 remaining\n", pCtx->cClients);
    495495
    496496    if (0 == pCtx->cClients) /* All clients disconnected? Tear things down. */
     
    772772    RT_ZERO(Val);
    773773
     774    int rc = AudioTestSvcInit(pSrv, pCallbacks);
     775    if (RT_FAILURE(rc))
     776        return rc;
     777
    774778    Val.u32 = pTcpOpts->enmConnMode;
    775     AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONN_MODE, &Val);
     779    rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONN_MODE, &Val);
     780    AssertRCReturn(rc, rc);
    776781
    777782    if (   pTcpOpts->enmConnMode == ATSCONNMODE_BOTH
     
    780785        Assert(pTcpOpts->uBindPort); /* Always set by the caller. */
    781786        Val.u16 = pTcpOpts->uBindPort;
    782         AudioTestSvcHandleOption(pSrv, ATSTCPOPT_BIND_PORT, &Val);
     787        rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_BIND_PORT, &Val);
     788        AssertRCReturn(rc, rc);
    783789
    784790        if (pTcpOpts->szBindAddr[0])
    785791        {
    786792            Val.psz = pTcpOpts->szBindAddr;
    787             AudioTestSvcHandleOption(pSrv, ATSTCPOPT_BIND_ADDRESS, &Val);
     793            rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_BIND_ADDRESS, &Val);
     794            AssertRCReturn(rc, rc);
    788795        }
    789796        else
     
    803810        Assert(pTcpOpts->uConnectPort); /* Always set by the caller. */
    804811        Val.u16 = pTcpOpts->uConnectPort;
    805         AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONNECT_PORT, &Val);
     812        rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONNECT_PORT, &Val);
     813        AssertRCReturn(rc, rc);
    806814
    807815        if (pTcpOpts->szConnectAddr[0])
    808816        {
    809817            Val.psz = pTcpOpts->szConnectAddr;
    810             AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONNECT_ADDRESS, &Val);
     818            rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONNECT_ADDRESS, &Val);
     819            AssertRCReturn(rc, rc);
    811820        }
    812821        else
     
    820829    }
    821830
    822     int rc = AudioTestSvcInit(pSrv, pCallbacks);
    823831    if (RT_SUCCESS(rc))
     832    {
    824833        rc = AudioTestSvcStart(pSrv);
    825 
    826     if (RT_FAILURE(rc))
    827         RTTestFailed(g_hTest, "Starting server for %s failed with %Rrc\n", pszDesc, rc);
     834        if (RT_FAILURE(rc))
     835            RTTestFailed(g_hTest, "Starting server for %s failed with %Rrc\n", pszDesc, rc);
     836    }
    828837
    829838    return rc;
     
    953962            pTstEnv->TcpOpts.uConnectPort = ATS_TCP_DEF_CONNECT_PORT_GUEST;
    954963
     964        pTstEnv->pSrv = (PATSSERVER)RTMemAlloc(sizeof(ATSSERVER));
     965        AssertPtrReturn(pTstEnv->pSrv, VERR_NO_MEMORY);
     966
    955967        /*
    956968         * Start the ATS (Audio Test Service) on the guest side.
     
    960972         * Note that we have to bind to "0.0.0.0" by default so that the host can connect to it.
    961973         */
    962         rc = audioTestEnvConfigureAndStartTcpServer(&pTstEnv->Srv, &Callbacks, "guest", &pTstEnv->TcpOpts);
     974        rc = audioTestEnvConfigureAndStartTcpServer(pTstEnv->pSrv, &Callbacks, "guest", &pTstEnv->TcpOpts);
    963975    }
    964976    else /* Host mode */
     
    10211033    }
    10221034
     1035    if (pTstEnv->pSrv)
     1036    {
     1037        int rc2 = AudioTestSvcDestroy(pTstEnv->pSrv);
     1038        AssertRC(rc2);
     1039
     1040        RTMemFree(pTstEnv->pSrv);
     1041        pTstEnv->pSrv = NULL;
     1042    }
     1043
    10231044    for (unsigned i = 0; i < RT_ELEMENTS(pTstEnv->aStreams); i++)
    10241045    {
  • trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h

    r90912 r90918  
    253253    /** TCP options to use for ATS. */
    254254    AUDIOTESTENVTCPOPTS     TcpOpts;
    255     /** ATS server instance to use. */
    256     ATSSERVER               Srv;
     255    /** ATS server instance to use.
     256     *  NULL if not in use. */
     257    PATSSERVER              pSrv;
    257258    /** ATS callback context to use. */
    258259    ATSCALLBACKCTX          CallbackCtx;
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