VirtualBox

Changeset 91510 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 1, 2021 12:14:26 PM (3 years ago)
Author:
vboxsync
Message:

Audio/Validation Kit: Implemented playing back a pre + post beacon when playing back the test tone (in testing mode only), see comments for more. ​bugref:10008

File:
1 edited

Legend:

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

    r91198 r91510  
    267267        uint32_t cbPlayedTotal  = 0;
    268268
     269        /* We play a pre + post beacon before + after the actual test tone.
     270         * Note that the beacon is *not* part of the written test object, so that we can detect differences between
     271         * actual played back and serialized (written) data later. */
     272        uint32_t const cbBeacon       = pTstEnv ? 1024 : 0; /* Only play a beacon if we're running in testing mode. */
     273        uint32_t       cbBeaconToPlay = cbBeacon;
     274        uint32_t       cbBeaconPlayed = 0;
     275
    269276        RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Playing %RU32 bytes total\n", cbToPlayTotal);
     277        if (cbBeaconToPlay)
     278        {
     279            RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Playing 2 x %RU32 bytes pre/post beacons\n", cbBeaconToPlay);
     280            cbToPlayTotal += cbBeacon * 2 /* Pre + post beacon */;
     281        }
    270282
    271283        if (pTstEnv)
     
    313325                                 PDMAudioPropsBytesToMilli(pMix->pProps, cbCanWrite), cbCanWrite);
    314326
    315                 uint32_t const cbToGenerate = RT_MIN(RT_MIN(cbToPlayTotal - cbPlayedTotal, sizeof(abBuf)), cbCanWrite);
    316                 uint32_t       cbToPlay;
     327                uint32_t cbToPlay;
     328
     329                /* Any beacon to play? */
     330                if (   cbBeaconToPlay
     331                    && cbBeaconPlayed < cbBeaconToPlay)
     332                {
     333                    /* Limit to exactly one beacon (pre or post). */
     334                    cbToPlay = RT_MIN(sizeof(abBuf), RT_MIN(cbCanWrite, cbBeaconToPlay - cbBeaconPlayed));
     335                    memset(abBuf, 0x42 /* Our actual beacon data, hopefully the answer to all ... */, cbToPlay);
     336
     337                    rc = AudioTestMixStreamPlay(&pStream->Mix, abBuf, cbToPlay, &cbPlayed);
     338                    if (RT_FAILURE(rc))
     339                        break;
     340
     341                    cbBeaconPlayed += cbPlayed;
     342                    cbPlayedTotal  += cbPlayed;
     343                    continue;
     344                }
     345
     346                /* Start playing the post beacon? */
     347                if (cbPlayedTotal == cbToPlayTotal - cbBeaconToPlay)
     348                {
     349                    cbBeaconPlayed = 0;
     350                    continue;
     351                }
     352
     353                if (RT_FAILURE(rc))
     354                    break;
     355
     356                uint32_t const cbToGenerate = RT_MIN(RT_MIN(cbToPlayTotal - cbPlayedTotal - cbBeaconToPlay, sizeof(abBuf)),
     357                                                     cbCanWrite);
    317358                rc = AudioTestToneGenerate(&TstTone, abBuf, cbToGenerate, &cbToPlay);
    318359                if (RT_SUCCESS(rc))
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