VirtualBox

Changeset 89435 in vbox


Ignore:
Timestamp:
Jun 1, 2021 1:30:30 PM (4 years ago)
Author:
vboxsync
Message:

Audio/ValKit: Made buffering / pre-buffering and scheduling hint sizes more flexible. bugref:10008

File:
1 edited

Legend:

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

    r89433 r89435  
    184184    /** Temporary path for this test environment. */
    185185    char                    szPathTemp[RTPATH_MAX];
     186    /** Buffer size (in ms). */
     187    RTMSINTERVAL            cMsBufferSize;
     188    /** Pre-buffering time (in ms). */
     189    RTMSINTERVAL            cMsPreBuffer;
     190    /** Scheduling hint (in ms). */
     191    RTMSINTERVAL            cMsSchedulingHint;
    186192    /** The audio test driver stack. */
    187193    AUDIOTESTDRVSTACK       DrvStack;
     
    430436        uint8_t  abBuf[_4K];
    431437
    432         const uint16_t cSchedulingMs = RTRandU32Ex(10, 80); /* Choose a random scheduling (in ms). */
    433         const uint32_t cbPerMs       = PDMAudioPropsMilliToBytes(&pParms->Props, cSchedulingMs);
     438        const uint32_t cbPerMs       = PDMAudioPropsMilliToBytes(&pParms->Props, pTstEnv->cMsSchedulingHint);
    434439              uint32_t cbToWrite     = PDMAudioPropsMilliToBytes(&pParms->Props, pParms->msDuration);
    435440
    436         AudioTestSetObjAddMetadataStr(pObj, "schedule_ms=%RU16", cSchedulingMs);
     441        AudioTestSetObjAddMetadataStr(pObj, "buffer_size_ms=%RU32", pTstEnv->cMsBufferSize);
     442        AudioTestSetObjAddMetadataStr(pObj, "prebuf_size_ms=%RU32", pTstEnv->cMsPreBuffer);
     443        AudioTestSetObjAddMetadataStr(pObj, "scheduling_hint_ms=%RU32", pTstEnv->cMsSchedulingHint);
    437444
    438445        while (cbToWrite)
    439446        {
    440447            uint32_t cbWritten    = 0;
    441             uint32_t cbToGenerate = RT_MIN(cbToWrite, RT_MIN(cbPerMs, (uint32_t)sizeof(abBuf)));
     448            uint32_t cbToGenerate = RT_MIN(cbToWrite, RT_MIN(cbPerMs, sizeof(abBuf)));
    442449            Assert(cbToGenerate);
    443450
     
    455462                break;
    456463
    457             RTThreadSleep(cSchedulingMs);
     464            RTThreadSleep(pTstEnv->cMsSchedulingHint);
    458465
    459466            Assert(cbToWrite >= cbWritten);
     
    573580    PDMAudioHostEnumInit(&pTstEnv->DevEnum);
    574581
     582    pTstEnv->cMsBufferSize     = 300; /* ms */ /** @todo Randomize this also? */
     583    pTstEnv->cMsPreBuffer      = 150; /* ms */ /** @todo Ditto. */
     584    pTstEnv->cMsSchedulingHint = RTRandU32Ex(10, 80); /* Choose a random scheduling (in ms). */
     585
    575586    /* Only the guest mode needs initializing the driver stack. */
    576587    const bool fUseDriverStack = pTstEnv->enmMode == AUDIOTESTMODE_GUEST;
     
    858869{
    859870    pStream->pBackend = NULL;
    860     int rc = audioTestDriverStackStreamCreateInput(&pTstEnv->DrvStack, pProps, 300 /*cMsBufferSize*/, 150 /*cMsPreBuffer*/,
    861                                                    10 /*cMsSchedulingHint*/, &pStream->pStream, &pStream->Cfg);
     871    int rc = audioTestDriverStackStreamCreateInput(&pTstEnv->DrvStack, pProps, pTstEnv->cMsBufferSize, pTstEnv->cMsPreBuffer,
     872                                                   pTstEnv->cMsSchedulingHint, &pStream->pStream, &pStream->Cfg);
    862873    if (RT_SUCCESS(rc) && !pTstEnv->DrvStack.pIAudioConnector)
    863874        pStream->pBackend = &((PAUDIOTESTDRVSTACKSTREAM)pStream->pStream)->Backend;
     
    892903
    893904        const uint64_t tsStartMs     = RTTimeMilliTS();
    894         const uint16_t cSchedulingMs = RTRandU32Ex(10, 80); /* Choose a random scheduling (in ms). */
    895905
    896906        do
     
    907917                break;
    908918
    909             RTThreadSleep(cSchedulingMs);
     919            RTThreadSleep(pTstEnv->cMsSchedulingHint);
    910920
    911921        } while (RT_SUCCESS(rc));
     
    933943{
    934944    pStream->pBackend = NULL;
    935     int rc = audioTestDriverStackStreamCreateOutput(&pTstEnv->DrvStack, pProps, 300 /*cMsBufferSize*/, 200 /*cMsPreBuffer*/,
    936                                                     10 /*cMsSchedulingHint*/, &pStream->pStream, &pStream->Cfg);
     945    int rc = audioTestDriverStackStreamCreateOutput(&pTstEnv->DrvStack, pProps, pTstEnv->cMsBufferSize, pTstEnv->cMsPreBuffer,
     946                                                    pTstEnv->cMsSchedulingHint, &pStream->pStream, &pStream->Cfg);
    937947    if (RT_SUCCESS(rc) && !pTstEnv->DrvStack.pIAudioConnector)
    938948        pStream->pBackend = &((PAUDIOTESTDRVSTACKSTREAM)pStream->pStream)->Backend;
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