VirtualBox

Changeset 92211 in vbox


Ignore:
Timestamp:
Nov 4, 2021 2:15:01 PM (3 years ago)
Author:
vboxsync
Message:

Audio/Validation Kit: More code for audio data beacon handling. Now has dedicated beacons for recording / playback tests. bugref:10008

Location:
trunk/src/VBox
Files:
4 edited

Legend:

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

    r92210 r92211  
    24702470    uint32_t const cbFrameSize = PDMAudioPropsFrameSize(&pBeacon->Props); /* Use the audio frame size as chunk size. */
    24712471
    2472     if (cbBuf < cbFrameSize)
     2472    if (cbBuf < cbFrameSize) /* Fend-off data which isn't at least one full frame. */
    24732473        return 0;
    24742474
     
    24762476                    ("Buffer size must be frame-aligned"), 0);
    24772477
    2478     uint8_t const byBeacon      = AudioTestBeaconByteFromType(pBeacon->enmType);
    2479     /*bool          fInBeacon     = false;
    2480     uint32_t      cbBeacon      = 0;
    2481     size_t        offLastBeacon = 0;*/
    2482     size_t offGap = 0;
    2483 
    2484     unsigned const cbStep             = cbFrameSize;
    2485     uint32_t const cbProcessedInitial = pBeacon->cbUsed;
     2478    uint8_t  const byBeacon      = AudioTestBeaconByteFromType(pBeacon->enmType);
     2479    unsigned const cbStep        = cbFrameSize;
     2480    uint32_t const cbUsedInitial = pBeacon->cbUsed;
    24862481
    24872482    for (size_t i = 0; i < cbBuf; i += cbStep)
     
    24922487            && pauBuf[i + 3] == byBeacon)
    24932488        {
    2494             if (offGap)
    2495             {
    2496                 pBeacon->cbUsed = 0;
    2497             }
    24982489            pBeacon->cbUsed += cbStep;
    2499             offGap = 0;
     2490
     2491            if (pBeacon->cbUsed > pBeacon->cbSize)
     2492                pBeacon->cbUsed -= pBeacon->cbSize;
    25002493        }
    25012494        else
    2502             offGap = i;
    2503     }
    2504 
    2505     Assert(pBeacon->cbUsed >= cbProcessedInitial);
    2506     return pBeacon->cbUsed - cbProcessedInitial;
     2495        {
     2496            /* If beacon is not complete yet, we detected a gap here. Start all over then. */
     2497            if (pBeacon->cbUsed < pBeacon->cbSize)
     2498                pBeacon->cbUsed = 0;
     2499        }
     2500    }
     2501
     2502    if (!pBeacon->cbUsed)
     2503        return 0;
     2504
     2505    AssertMsg(pBeacon->cbUsed >= cbUsedInitial, ("cbUsed (%RU32) < cbUsedInitial (%RU32)\n", pBeacon->cbUsed, cbUsedInitial));
     2506    return pBeacon->cbUsed - cbUsedInitial;
    25072507}
    25082508
     
    30413041#undef CHECK_RC_MAYBE_RET
    30423042#undef CHECK_RC_MSG_MAYBE_RET
     3043
     3044/**
     3045 * Converts an audio test state enum value to a string.
     3046 *
     3047 * @returns Pointer to read-only internal test state string on success,
     3048 *          "illegal" if invalid command value.
     3049 * @param   enmState            The state to convert.
     3050 */
     3051const char *AudioTestStateToStr(AUDIOTESTSTATE enmState)
     3052{
     3053    switch (enmState)
     3054    {
     3055        case AUDIOTESTSTATE_INIT: return "init";
     3056        case AUDIOTESTSTATE_PRE:  return "pre";
     3057        case AUDIOTESTSTATE_RUN:  return "run";
     3058        case AUDIOTESTSTATE_POST: return "post";
     3059        case AUDIOTESTSTATE_DONE: return "done";
     3060        case AUDIOTESTSTATE_32BIT_HACK:
     3061            break;
     3062    }
     3063    AssertMsgFailedReturn(("Invalid test state: #%x\n", enmState), "illegal");
     3064}
    30433065
    30443066
  • trunk/src/VBox/Devices/Audio/AudioTest.h

    r92210 r92211  
    353353typedef AUDIOTESTERRORDESC const *PCAUDIOTESTERRORDESC;
    354354
     355/**
     356 * Enumeration specifying an internal test state.
     357 */
     358typedef enum AUDIOTESTSTATE
     359{
     360    /** Test is initializing. */
     361    AUDIOTESTSTATE_INIT = 0,
     362    /** Test is in pre-run phase. */
     363    AUDIOTESTSTATE_PRE,
     364    /** Test is running */
     365    AUDIOTESTSTATE_RUN,
     366    /** Test is in post-run phase. */
     367    AUDIOTESTSTATE_POST,
     368    /** Test has been run. */
     369    AUDIOTESTSTATE_DONE,
     370    /** The usual 32-bit hack. */
     371    AUDIOTESTSTATE_32BIT_HACK = 0x7fffffff
     372} AUDIOTESTSTATE;
     373
    355374double AudioTestToneInit(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps, double dbFreq);
    356375double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps);
     
    410429
    411430void   AudioTestErrorDescDestroy(PAUDIOTESTERRORDESC pErr);
     431
     432const char *AudioTestStateToStr(AUDIOTESTSTATE enmState);
    412433
    413434/** @name Wave File Accessors
  • trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp

    r92206 r92211  
    9999
    100100/**
    101  * Enumeration specifying an internal test state.
    102  */
    103 typedef enum VALKITTESTSTATE
    104 {
    105     /** Test is initializing. */
    106     VALKITTESTSTATE_INIT = 0,
    107     /** Test is in pre-run phase. */
    108     VALKITTESTSTATE_PRE,
    109     /** Test is running */
    110     VALKITTESTSTATE_RUN,
    111     /** Test is in post-run phase. */
    112     VALKITTESTSTATE_POST,
    113     /** Test has been run. */
    114     VALKITTESTSTATE_DONE
    115 } VALKITTESTSTATE;
    116 
    117 /**
    118101 * Structure keeping a single Validation Kit test.
    119102 */
     
    127110    PAUDIOTESTENTRY        pEntry;
    128111    /** Current test state. */
    129     VALKITTESTSTATE        enmState;
     112    AUDIOTESTSTATE         enmState;
    130113    /** Current test object to process. */
    131114    AUDIOTESTOBJ           Obj;
     
    216199
    217200/**
    218  * Converts an internal test state enum value to a string.
    219  *
    220  * @returns Pointer to read-only internal test state string on success,
    221  *          "illegal" if invalid command value.
    222  * @param   enmState            The state to convert.
    223  */
    224 DECLINLINE(const char *) drvHostValKitTestStatusToStr(VALKITTESTSTATE enmState)
    225 {
    226     switch (enmState)
    227     {
    228         case VALKITTESTSTATE_INIT: return "init";
    229         case VALKITTESTSTATE_PRE:  return "pre";
    230         case VALKITTESTSTATE_RUN:  return "run";
    231         case VALKITTESTSTATE_POST: return "post";
    232         case VALKITTESTSTATE_DONE: return "done";
    233         /* no default: */
    234             break;
    235     }
    236     AssertMsgFailedReturn(("Invalid test state: #%x\n", enmState), "illegal");
    237 }
    238 
    239 /**
    240201 * Unregisters a ValKit test, common code.
    241202 *
     
    333294    RTListForEachSafe(&pThis->lstTestsRec, pTst, pTstNext, VALKITTESTDATA, Node)
    334295    {
    335         if (pTst->enmState != VALKITTESTSTATE_DONE)
     296        if (pTst->enmState != AUDIOTESTSTATE_DONE)
    336297            LogRel(("ValKit: \tWarning: Test #%RU32 (recording) not done yet (state is '%s')\n",
    337                     pTst->idxTest, drvHostValKitTestStatusToStr(pTst->enmState)));
     298                    pTst->idxTest, AudioTestStateToStr(pTst->enmState)));
    338299
    339300        size_t const cbOutstanding = pTst->t.TestTone.u.Rec.cbToWrite - pTst->t.TestTone.u.Rec.cbWritten;
     
    350311    RTListForEachSafe(&pThis->lstTestsPlay, pTst, pTstNext, VALKITTESTDATA, Node)
    351312    {
    352         if (pTst->enmState != VALKITTESTSTATE_DONE)
     313        if (pTst->enmState != AUDIOTESTSTATE_DONE)
    353314            LogRel(("ValKit: \tWarning: Test #%RU32 (playback) not done yet (state is '%s')\n",
    354                     pTst->idxTest, drvHostValKitTestStatusToStr(pTst->enmState)));
     315                    pTst->idxTest, AudioTestStateToStr(pTst->enmState)));
    355316
    356317        size_t const cbOutstanding = pTst->t.TestTone.u.Play.cbToRead - pTst->t.TestTone.u.Play.cbRead;
     
    449410            {
    450411                LogRel(("ValKit: Waiting for all tests of set '%s' to end ...\n", pszTag));
    451                 rc = RTSemEventWait(pThis->EventSemEnded, RT_MS_1MIN);
     412                rc = RTSemEventWait(pThis->EventSemEnded, RT_MS_5SEC);
    452413                if (RT_FAILURE(rc))
    453414                {
     
    528489    AssertPtrReturn(pTestData, VERR_NO_MEMORY);
    529490
    530     pTestData->enmState = VALKITTESTSTATE_INIT;
     491    pTestData->enmState = AUDIOTESTSTATE_INIT;
    531492
    532493    memcpy(&pTestData->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS));
     
    585546    AssertPtrReturn(pTestData, VERR_NO_MEMORY);
    586547
    587     pTestData->enmState = VALKITTESTSTATE_INIT;
     548    pTestData->enmState = AUDIOTESTSTATE_INIT;
    588549
    589550    memcpy(&pTestData->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS));
     
    879840
    880841    if (   pTst
    881         && pTst->enmState == VALKITTESTSTATE_INIT) /* Test not started yet? */
     842        && pTst->enmState == AUDIOTESTSTATE_INIT) /* Test not started yet? */
    882843    {
    883844        AUDIOTESTPARMS Parms;
     
    909870        LogRel2(("ValKit: Now total of %RU32 bytes available for capturing\n", pStrmValKit->cbAvail));
    910871
    911         pTst->enmState = VALKITTESTSTATE_PRE;
     872        pTst->enmState = AUDIOTESTSTATE_PRE;
    912873    }
    913874
     
    1037998    }
    1038999
    1039     if (pTst->enmState == VALKITTESTSTATE_INIT) /* Test not started yet? */
     1000    if (pTst->enmState == AUDIOTESTSTATE_INIT) /* Test not started yet? */
    10401001    {
    10411002        AUDIOTESTPARMS Parms;
     
    10611022            LogRel(("ValKit: Test created (caller UTC): %s\n", szTimeCreated));
    10621023
    1063             pTst->enmState = VALKITTESTSTATE_PRE;
     1024            pTst->enmState = AUDIOTESTSTATE_PRE;
    10641025        }
    10651026    }
     
    10751036        switch (pTst->enmState)
    10761037        {
    1077             case VALKITTESTSTATE_PRE:
     1038            case AUDIOTESTSTATE_PRE:
    10781039                RT_FALL_THROUGH();
    1079             case VALKITTESTSTATE_POST:
     1040            case AUDIOTESTSTATE_POST:
    10801041            {
    10811042                PAUDIOTESTTONEBEACON pBeacon = &pTst->t.TestTone.Beacon;
     
    10851046                    bool const fStarted = AudioTestBeaconGetRemaining(pBeacon) == AudioTestBeaconGetSize(pBeacon);
    10861047
     1048                    /* Limit adding data to the beacon size. */
    10871049                    uint32_t const cbToAddMax = RT_MIN(cbBuf, AudioTestBeaconGetRemaining(pBeacon));
    10881050
    10891051                    AudioTestBeaconAddConsecutive(pBeacon, (uint8_t *)pvBuf, cbToAddMax);
     1052                    /** @todo Take left-over data into account (and stash them away for the test tone)? */
    10901053
    10911054                    if (fStarted)
    1092                         LogRel2(("ValKit: Test #%RU32: Detection of %s playback beacon started (%RU32ms played so far)\n",
     1055                        LogRel2(("ValKit: Test #%RU32: Detection of %s beacon started (%RU32ms played so far)\n",
    10931056                                 pTst->idxTest, AudioTestBeaconTypeGetName(pBeacon->enmType),
    10941057                                 PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, pThis->cbPlayedTotal)));
    10951058                    if (AudioTestBeaconIsComplete(pBeacon))
    10961059                    {
    1097                         LogRel2(("ValKit: Test #%RU32: Detection of %s playback beacon ended\n",
     1060                        LogRel2(("ValKit: Test #%RU32: Detection of %s beacon ended\n",
    10981061                                 pTst->idxTest, AudioTestBeaconTypeGetName(pBeacon->enmType)));
    10991062
    1100                         if (pTst->enmState == VALKITTESTSTATE_PRE)
    1101                             pTst->enmState = VALKITTESTSTATE_RUN;
    1102                         else if (pTst->enmState == VALKITTESTSTATE_POST)
    1103                             pTst->enmState = VALKITTESTSTATE_DONE;
     1063                        if (pTst->enmState == AUDIOTESTSTATE_PRE)
     1064                            pTst->enmState = AUDIOTESTSTATE_RUN;
     1065                        else if (pTst->enmState == AUDIOTESTSTATE_POST)
     1066                            pTst->enmState = AUDIOTESTSTATE_DONE;
    11041067                    }
    11051068                }
    1106 
     1069                else /* Go to the next state. */
     1070                    pTst->enmState = AUDIOTESTSTATE_RUN;
    11071071                break;
    11081072            }
    11091073
    1110             case VALKITTESTSTATE_RUN:
     1074            case AUDIOTESTSTATE_RUN:
    11111075            {
    11121076                /* Whether we count all silence as recorded data or not.
     
    11251089                                pTst->idxTest, pTst->t.TestTone.u.Play.cbRead - pTst->t.TestTone.u.Play.cbToRead));
    11261090
    1127                     pTst->enmState = VALKITTESTSTATE_POST;
     1091                    pTst->enmState = AUDIOTESTSTATE_POST;
    11281092                    /* Re-use the beacon object, but this time it's the post beacon. */
    11291093                    AudioTestBeaconInit(&pTst->t.TestTone.Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pTst->t.TestTone.Parms.Props);
     
    11321096            }
    11331097
    1134             case VALKITTESTSTATE_DONE:
     1098            case AUDIOTESTSTATE_DONE:
    11351099            {
    11361100                /* Handled below. */
     
    11471111    }
    11481112
    1149     if (pTst->enmState == VALKITTESTSTATE_DONE)
     1113    if (pTst->enmState == AUDIOTESTSTATE_DONE)
    11501114    {
    11511115        AudioTestSetTestDone(pTst->pEntry);
     
    12381202    switch (pTst->enmState)
    12391203    {
    1240         case VALKITTESTSTATE_PRE:
     1204        case AUDIOTESTSTATE_PRE:
    12411205            RT_FALL_THROUGH();
    1242         case VALKITTESTSTATE_POST:
     1206        case AUDIOTESTSTATE_POST:
    12431207        {
    12441208            PAUDIOTESTTONEBEACON pBeacon = &pTst->t.TestTone.Beacon;
     
    12661230                             pTst->idxTest, AudioTestBeaconTypeGetName(pBeacon->enmType)));
    12671231
    1268                     if (pTst->enmState == VALKITTESTSTATE_PRE)
    1269                         pTst->enmState = VALKITTESTSTATE_RUN;
    1270                     else if (pTst->enmState == VALKITTESTSTATE_POST)
    1271                         pTst->enmState = VALKITTESTSTATE_DONE;
     1232                    if (pTst->enmState == AUDIOTESTSTATE_PRE)
     1233                        pTst->enmState = AUDIOTESTSTATE_RUN;
     1234                    else if (pTst->enmState == AUDIOTESTSTATE_POST)
     1235                        pTst->enmState = AUDIOTESTSTATE_DONE;
    12721236                }
    12731237            }
     1238            else /* Go to the next state. */
     1239                pTst->enmState = AUDIOTESTSTATE_RUN;
    12741240            break;
    12751241        }
    12761242
    1277         case VALKITTESTSTATE_RUN:
     1243        case AUDIOTESTSTATE_RUN:
    12781244        {
    12791245            uint32_t const cbToWrite = RT_MIN(cbBuf, pTst->t.TestTone.u.Rec.cbToWrite - pTst->t.TestTone.u.Rec.cbWritten);
     
    13011267                        pTst->idxTest, RTTimeMilliTS() - pTst->msStartedTS));
    13021268
    1303                 pTst->enmState = VALKITTESTSTATE_POST;
     1269                pTst->enmState = AUDIOTESTSTATE_POST;
    13041270                /* Re-use the beacon object, but this time it's the post beacon. */
    13051271                AudioTestBeaconInit(&pTst->t.TestTone.Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pTst->t.TestTone.Parms.Props);
     
    13091275        }
    13101276
    1311         case VALKITTESTSTATE_DONE:
     1277        case AUDIOTESTSTATE_DONE:
    13121278        {
    13131279            /* Handled below. */
     
    13271293    }
    13281294
    1329     if (pTst->enmState == VALKITTESTSTATE_DONE)
     1295    if (pTst->enmState == AUDIOTESTSTATE_DONE)
    13301296    {
    13311297        AudioTestSetTestDone(pTst->pEntry);
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp

    r92195 r92211  
    744744    if (RT_SUCCESS(rc))
    745745    {
    746         uint64_t cbRecTotal  = 0; /* Counts everything, including silence / whatever. */
    747         uint64_t cbTestToRec = PDMAudioPropsMilliToBytes(&pStream->Cfg.Props, pParms->msDuration);
     746        uint32_t cbRecTotal  = 0; /* Counts everything, including silence / whatever. */
     747        uint32_t cbTestToRec = PDMAudioPropsMilliToBytes(&pStream->Cfg.Props, pParms->msDuration);
     748        uint32_t cbTestRec   = 0;
     749
     750        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Recording %RU32 bytes total\n", cbTestToRec);
    748751
    749752        /* We expect a pre + post beacon before + after the actual test tone.
     
    754757        uint32_t const cbBeacon = AudioTestBeaconGetSize(&Beacon);
    755758        if (cbBeacon)
    756         {
    757759            RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Expecting 2 x %RU32 bytes pre/post beacons\n", cbBeacon);
    758             cbTestToRec = cbBeacon * 2 /* Pre + post beacon */;
    759         }
    760760
    761761        AudioTestObjAddMetadataStr(Obj, "beacon_type=%RU32\n", (uint32_t)AudioTestBeaconGetType(&Beacon));
     
    769769        AudioTestObjAddMetadataStr(Obj, "device_scheduling_hint_ms=%RU32\n", pIoOpts->cMsSchedulingHint);
    770770
    771         RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Recording %RU32 bytes total\n", cbTestToRec);
    772 
    773771        uint8_t         abSamples[16384];
    774772        uint32_t const  cbSamplesAligned  = PDMAudioPropsFloorBytesToFrame(pMix->pProps, sizeof(abSamples));
    775         uint64_t        cbTestRec         = 0;
    776773
    777774        uint64_t const  nsStarted         = RTTimeNanoTS();
     
    780777        uint64_t        nsLastMsgCantRead = 0; /* Timestamp (in ns) when the last message of an unreadable stream was shown. */
    781778
    782         while (!g_fTerminate && cbTestRec < cbTestToRec)
     779        AUDIOTESTSTATE  enmState          = AUDIOTESTSTATE_PRE;
     780
     781        while (!g_fTerminate)
    783782        {
    784783            uint64_t const nsNow = RTTimeNanoTS();
     
    799798                if (RT_SUCCESS(rc))
    800799                {
    801                     if (cbRecorded)
     800                    /* Flag indicating whether the whole block we're going to play is silence or not. */
     801                    bool const fIsAllSilence = PDMAudioPropsIsBufferSilence(&pStream->pStream->Cfg.Props, abSamples, cbRecorded);
     802
     803                    cbRecTotal += cbRecorded; /* Do a bit of accounting. */
     804
     805                    /* Always write (record) everything, no matter if the current audio contains complete silence or not.
     806                     * Might be also become handy later if we want to have a look at start/stop timings and so on. */
     807                    rc = AudioTestObjWrite(Obj, abSamples, cbRecorded);
     808                    AssertRCBreak(rc);
     809
     810                    switch (enmState)
    802811                    {
    803                         cbRecTotal += cbRecorded;
    804 
    805                         rc = AudioTestObjWrite(Obj, abSamples, cbRecorded);
    806                         if (RT_SUCCESS(rc))
     812                        case AUDIOTESTSTATE_PRE:
     813                            RT_FALL_THROUGH();
     814                        case AUDIOTESTSTATE_POST:
    807815                        {
    808                             if (AudioTestBeaconGetSize(&Beacon))
     816                            if (    AudioTestBeaconGetSize(&Beacon)
     817                                && !AudioTestBeaconIsComplete(&Beacon))
    809818                            {
    810                                 if (!AudioTestBeaconIsComplete(&Beacon))
     819                                bool const fStarted = AudioTestBeaconGetRemaining(&Beacon) == AudioTestBeaconGetSize(&Beacon);
     820
     821                                /* Limit adding data to the beacon size. */
     822                                uint32_t const cbToAddMax = RT_MIN(cbRecorded, AudioTestBeaconGetRemaining(&Beacon));
     823
     824                                AudioTestBeaconAddConsecutive(&Beacon, abSamples, cbToAddMax);
     825                                /** @todo Take left-over data into account (and stash them away for the test tone)? */
     826
     827                                if (   fStarted
     828                                    && g_uVerbosity >= 2)
     829                                    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
     830                                                 "Detection of %s beacon started (%RU32ms recorded so far)\n",
     831                                                 AudioTestBeaconTypeGetName(Beacon.enmType),
     832                                                 PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, cbRecTotal));
     833
     834                                if (AudioTestBeaconIsComplete(&Beacon))
    811835                                {
    812                                     bool const fStarted = AudioTestBeaconGetRemaining(&Beacon) == AudioTestBeaconGetSize(&Beacon);
    813 
    814                                     uint32_t const cbToAddMax = RT_MIN(cbRecorded, AudioTestBeaconGetRemaining(&Beacon));
    815 
    816                                     uint32_t const cbAdded = AudioTestBeaconAddConsecutive(&Beacon, abSamples, cbToAddMax);
    817                                     if (cbAdded)
    818                                         cbTestRec += cbAdded; /* Only count data which belongs to a (complete test tone). */
    819 
    820                                     if (   fStarted
    821                                         && g_uVerbosity >= 2)
    822                                         RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
    823                                                      "Detection of %s playback beacon started (%RU32ms recorded so far)\n",
    824                                                      AudioTestBeaconTypeGetName(Beacon.enmType),
    825                                                      PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, cbRecTotal));
    826 
    827                                     if (AudioTestBeaconIsComplete(&Beacon))
    828                                     {
    829                                         if (g_uVerbosity >= 2)
    830                                             RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Detection of %s playback beacon ended\n",
    831                                                          AudioTestBeaconTypeGetName(Beacon.enmType));
    832                                     }
    833                                 }
    834                                 else
    835                                 {
    836                                     uint32_t const cbTestToneToRec = cbTestToRec - cbTestRec - cbBeacon;
    837                                     if (cbTestToneToRec == 0) /* Done recording the test tone? */
    838                                     {
    839                                         AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pStream->Cfg.Props);
    840                                     }
    841                                     else /* Count test tone data. */
    842                                         cbTestRec += cbRecorded;
     836                                    if (g_uVerbosity >= 2)
     837                                        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Detection of %s beacon ended\n",
     838                                                     AudioTestBeaconTypeGetName(Beacon.enmType));
     839
     840                                    if (enmState == AUDIOTESTSTATE_PRE)
     841                                        enmState = AUDIOTESTSTATE_RUN;
     842                                    else if (enmState == AUDIOTESTSTATE_POST)
     843                                        enmState = AUDIOTESTSTATE_DONE;
    843844                                }
    844845                            }
     846                            break;
    845847                        }
     848
     849                        case AUDIOTESTSTATE_RUN:
     850                        {
     851                            /* Whether we count all silence as recorded data or not.
     852                             * Currently we don't, as otherwise consequtively played tones will be cut off in the end. */
     853                            if (!fIsAllSilence)
     854                                cbTestRec += cbRecorded;
     855
     856                            if (cbTestToRec - cbTestRec == 0) /* Done recording the test tone? */
     857                            {
     858                                enmState = AUDIOTESTSTATE_POST;
     859                                /* Re-use the beacon object, but this time it's the post beacon. */
     860                                AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pStream->Cfg.Props);
     861                            }
     862                        }
     863
     864                        case AUDIOTESTSTATE_DONE:
     865                        {
     866                            /* Nothing to do here. */
     867                            break;
     868                        }
     869
     870                        default:
     871                            AssertFailed();
     872                            break;
    846873                    }
    847874                }
     875
     876                if (enmState == AUDIOTESTSTATE_DONE)
     877                    break;
    848878            }
    849879            else if (AudioTestMixStreamIsOkay(pMix))
     
    874904        }
    875905
     906        if (g_uVerbosity >= 2)
     907            RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Recorded %RU32 bytes total\n", cbRecTotal);
    876908        if (cbTestRec != cbTestToRec)
     909        {
    877910            RTTestFailed(g_hTest, "Recording ended unexpectedly (%RU32/%RU32 recorded)\n", cbTestRec, cbTestToRec);
     911            rc = VERR_WRONG_ORDER; /** @todo Find a better rc. */
     912        }
     913
     914        if (RT_FAILURE(rc))
     915            RTTestFailed(g_hTest, "Recording failed (state is '%s')\n", AudioTestStateToStr(enmState));
    878916
    879917        int rc2 = AudioTestMixStreamDisable(pMix);
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