VirtualBox

Changeset 103568 in vbox


Ignore:
Timestamp:
Feb 26, 2024 1:08:48 PM (13 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
161919
Message:

Audio/VKAT: Use a circular buffer when recording data; should make it easier to detect and handle start/stop beacons [build fix].

File:
1 edited

Legend:

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

    r103567 r103568  
    854854    if (RT_SUCCESS(rc))
    855855    {
    856         uint32_t cbToReadTotal = PDMAudioPropsMilliToBytes(&pStream->Cfg.Props, pParms->msDuration);
     856        size_t cbToReadTotal = PDMAudioPropsMilliToBytes(&pStream->Cfg.Props, pParms->msDuration);
    857857        AssertStmt(cbToReadTotal, rc = VERR_INVALID_PARAMETER);
    858         uint32_t cbReadTotal   = 0; /* Counts the read test tone data (w/o any beacons). */
     858        size_t cbReadTotal   = 0; /* Counts the read test tone data (w/o any beacons). */
    859859
    860860        RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Recording %RU32 bytes total (%RU32ms timeout)\n",
     
    925925                if (cbBlock)
    926926                {
    927                     rc = AudioTestMixStreamCapture(pMix, pvBlock, cbBlock, &cbCaptured);
     927                    rc = AudioTestMixStreamCapture(pMix, pvBlock, (uint32_t)cbBlock, &cbCaptured);
    928928                    if (RT_FAILURE(rc))
    929929                       RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Reading from stream failed with %Rrc\n", idxTest, rc);
     
    964964            if (pTstEnv->fSelftest) /* For self-test mode we want to have a bit more randomness. */
    965965            {
    966                 size_t const u = RTCircBufUsed(pCircBuf);
    967                 size_t const r = RTRandU32Ex(1, RTCircBufSize(pCircBuf));
    968                 cbBlockToAcq   = PDMAudioPropsFloorBytesToFrame(pMix->pProps, RT_MIN(u, r));
     966                size_t const u = (uint32_t)RTCircBufUsed(pCircBuf);
     967                size_t const r = RTRandU32Ex(1, (uint32_t)RTCircBufSize(pCircBuf));
     968                cbBlockToAcq   = PDMAudioPropsFloorBytesToFrame(pMix->pProps, RT_MIN((uint32_t)u, (uint32_t)r));
    969969            }
    970970            else
    971                 cbBlockToAcq = PDMAudioPropsFloorBytesToFrame(pMix->pProps, RTCircBufUsed(pCircBuf));
     971                cbBlockToAcq = PDMAudioPropsFloorBytesToFrame(pMix->pProps, (uint32_t)RTCircBufUsed(pCircBuf));
    972972
    973973            RTCircBufAcquireReadBlock(pCircBuf, cbBlockToAcq, &pvBlock, &cbBlock);
     
    977977            /* Flag indicating whether the whole block we've captured is silence or not. */
    978978            bool const fIsAllSilence = PDMAudioPropsIsBufferSilence(&pStream->pStream->Cfg.Props, pvBlock, cbBlock);
    979             uint32_t   cbRead = 0;
     979            size_t     cbRead = 0;
    980980
    981981            switch (enmState)
     
    10021002                        {
    10031003                            RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
    1004                                          "Test #%RU32: Detection of %s beacon started (%RU32ms recorded so far)\n",
     1004                                         "Test #%RU32: Detection of %s beacon started (%RU64ms recorded so far)\n",
    10051005                                         idxTest, AudioTestBeaconTypeGetName(Beacon.enmType),
    1006                                          PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, cbReadTotal));
     1006                                         PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, (uint32_t)cbReadTotal));
    10071007                        }
    10081008
     
    10861086            {
    10871087                if (g_uVerbosity >= 3)
    1088                     RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Read data (%RU32 bytes):\n"
     1088                    RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Read data (%zu bytes):\n"
    10891089                                                            "%.*Rhxd\n",
    10901090                                 idxTest, cbRead, cbRead, pvBlock);
     
    10971097
    10981098            if (g_uVerbosity >= 2)
    1099                 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Processed %RU64ms (%RU32 bytes)\n",
     1099                RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Processed %RU64ms (%zu bytes)\n",
    11001100                             idxTest, PDMAudioPropsBytesToMilli(pMix->pProps, cbRead), cbRead);
    11011101
     
    11191119
    11201120        if (g_uVerbosity >= 2)
    1121             RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Recorded %RU32 bytes total\n", idxTest, cbReadTotal);
     1121            RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Recorded %zu bytes total\n", idxTest, cbReadTotal);
    11221122        if (cbReadTotal != cbToReadTotal)
    11231123        {
    1124             RTTestFailed(g_hTest, "Test #%RU32: Recording ended unexpectedly (%RU32 read, expected %RU32)\n",
     1124            RTTestFailed(g_hTest, "Test #%RU32: Recording ended unexpectedly (%zu read, expected %zu)\n",
    11251125                         idxTest, cbReadTotal, cbToReadTotal);
    11261126            int rc2 = cbReadTotal > cbToReadTotal ? VERR_BUFFER_OVERFLOW : VERR_BUFFER_UNDERFLOW;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette