VirtualBox

Ignore:
Timestamp:
Sep 9, 2021 6:54:31 PM (3 years ago)
Author:
vboxsync
Message:

Audio/Validation Kit: Some more diagnostics to find out why some testbox guests refuse to play any test tones. ​bugref:10008

File:
1 edited

Legend:

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

    r91185 r91186  
    309309            if (cbCanWrite)
    310310            {
     311                if (g_uVerbosity)
     312                    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Stream is writable with %RU32ms (%RU32 bytes)\n",
     313                                 PDMAudioPropsBytesToMilli(pMix->pProps, cbCanWrite), cbCanWrite);
     314
    311315                uint32_t const cbToGenerate = RT_MIN(RT_MIN(cbToPlayTotal - cbPlayedTotal, sizeof(abBuf)), cbCanWrite);
    312316                uint32_t       cbToPlay;
     
    341345            else if (AudioTestMixStreamIsOkay(&pStream->Mix))
    342346            {
     347                RTMSINTERVAL const msSleep = RT_MIN(RT_MAX(1, pStream->Cfg.Device.cMsSchedulingHint), 256);
     348
    343349                if (!nsLastMsgCantWrite || nsNow - nsLastMsgCantWrite > RT_NS_10SEC) /* Don't spam the output too much. */
    344350                {
    345                     RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Waiting for stream to be writable again ...\n");
     351                    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Waiting %RU32ms for stream to be writable again ...\n", msSleep);
    346352                    nsLastMsgCantWrite = nsNow;
    347353                }
    348354
    349                 RTThreadSleep(RT_MIN(RT_MAX(1, pStream->Cfg.Device.cMsSchedulingHint), 256));
     355                RTThreadSleep(msSleep);
    350356            }
    351357            else
     
    359365            if (cNsElapsed > nsTimeout)
    360366            {
    361                 RTTestFailed(g_hTest, "Playback took too long (runng %RU64 vs. timeout %RU64), aborting\n", cNsElapsed, nsTimeout);
     367                RTTestFailed(g_hTest, "Playback took too long (running %RU64 vs. timeout %RU64), aborting\n", cNsElapsed, nsTimeout);
    362368                rc = VERR_TIMEOUT;
    363369            }
     
    433439        uint32_t const  cbSamplesAligned = PDMAudioPropsFloorBytesToFrame(pMix->pProps, sizeof(abSamples));
    434440        uint64_t        cbRecTotal  = 0;
     441
     442        uint64_t const  nsStarted         = RTTimeNanoTS();
     443
     444        uint64_t        nsTimeout         = RT_MS_5MIN_64 * RT_NS_1MS;
     445        uint64_t        nsLastMsgCantRead = 0; /* Timestamp (in ns) when the last message of an unreadable stream was shown. */
     446
    435447        while (!g_fTerminate && cbRecTotal < cbToRecTotal)
    436448        {
     449            uint64_t const nsNow = RTTimeNanoTS();
     450
    437451            /*
    438452             * Anything we can read?
     
    441455            if (cbCanRead)
    442456            {
     457                if (g_uVerbosity)
     458                    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Stream is readable with %RU32ms (%RU32 bytes)\n",
     459                                 PDMAudioPropsBytesToMilli(pMix->pProps, cbCanRead), cbCanRead);
     460
    443461                uint32_t const cbToRead   = RT_MIN(cbCanRead, cbSamplesAligned);
    444462                uint32_t       cbRecorded = 0;
     
    459477            }
    460478            else if (AudioTestMixStreamIsOkay(pMix))
    461                 RTThreadSleep(RT_MIN(RT_MAX(1, pTstEnv->cMsSchedulingHint), 256));
     479            {
     480                RTMSINTERVAL const msSleep = RT_MIN(RT_MAX(1, pStream->Cfg.Device.cMsSchedulingHint), 256);
     481
     482                if (!nsLastMsgCantRead || nsNow - nsLastMsgCantRead > RT_NS_10SEC) /* Don't spam the output too much. */
     483                {
     484                    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Waiting %RU32ms for stream to be readable again ...\n", msSleep);
     485                    nsLastMsgCantRead = nsNow;
     486                }
     487
     488                RTThreadSleep(msSleep);
     489            }
     490
     491            /* Fail-safe in case something screwed up while playing back. */
     492            uint64_t const cNsElapsed = nsNow - nsStarted;
     493            if (cNsElapsed > nsTimeout)
     494            {
     495                RTTestFailed(g_hTest, "Recording took too long (running %RU64 vs. timeout %RU64), aborting\n", cNsElapsed, nsTimeout);
     496                rc = VERR_TIMEOUT;
     497            }
    462498
    463499            if (RT_FAILURE(rc))
    464500                break;
    465501        }
     502
     503        if (cbRecTotal != cbToRecTotal)
     504            RTTestFailed(g_hTest, "Recording ended unexpectedly (%RU32/%RU32 recorded)\n", cbRecTotal, cbToRecTotal);
    466505
    467506        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