VirtualBox

Changeset 89988 in vbox


Ignore:
Timestamp:
Jul 1, 2021 9:41:23 AM (4 years ago)
Author:
vboxsync
Message:

Audio/ValKit: Fixes and additions for test tone playback. bugref:10008

File:
1 edited

Legend:

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

    r89962 r89988  
    281281        AudioTestSetObjAddMetadataStr(pObj, "device_scheduling_hint_ms=%RU32\n", pStream->Cfg.Device.cMsSchedulingHint);
    282282
     283        PAUDIOTESTDRVMIXSTREAM pMix = &pStream->Mix;
     284
     285        uint32_t const  cbPreBuffer        = PDMAudioPropsFramesToBytes(pMix->pProps, pStream->Cfg.Backend.cFramesPreBuffering);
     286        uint64_t const  nsStarted          = RTTimeNanoTS();
     287        uint64_t        nsDonePreBuffering = 0;
     288
     289        uint64_t        offStream          = 0;
     290
    283291        while (cbToPlayTotal)
    284292        {
     293            /* Pace ourselves a little. */
     294            if (offStream >= cbPreBuffer)
     295            {
     296                if (!nsDonePreBuffering)
     297                    nsDonePreBuffering = RTTimeNanoTS();
     298                uint64_t const cNsWritten = PDMAudioPropsBytesToNano64(pMix->pProps, offStream - cbPreBuffer);
     299                uint64_t const cNsElapsed = RTTimeNanoTS() - nsStarted;
     300                if (cNsWritten > cNsElapsed + RT_NS_10MS)
     301                    RTThreadSleep((cNsWritten - cNsElapsed - RT_NS_10MS / 2) / RT_NS_1MS);
     302            }
     303
    285304            uint32_t       cbPlayed   = 0;
    286305            uint32_t const cbCanWrite = AudioTestMixStreamGetWritable(&pStream->Mix);
     
    292311                if (RT_SUCCESS(rc))
    293312                {
    294                     RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Playing %RU32 bytes ...\n", cbToPlay);
    295 
    296313                    /* Write stuff to disk before trying to play it. Help analysis later. */
    297314                    rc = AudioTestSetObjWrite(pObj, abBuf, cbToPlay);
    298315                    if (RT_SUCCESS(rc))
     316                    {
    299317                        rc = AudioTestMixStreamPlay(&pStream->Mix, abBuf, cbToPlay, &cbPlayed);
     318                        if (RT_SUCCESS(rc))
     319                        {
     320                            offStream += cbPlayed;
     321                        }
     322                    }
    300323                }
    301324
     
    311334            cbToPlayTotal -= cbPlayed;
    312335        }
     336
     337        if (RT_SUCCESS(rc))
     338            rc = AudioTestMixStreamDrain(&pStream->Mix, true /*fSync*/);
    313339
    314340        if (cbToPlayTotal != 0)
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