VirtualBox

Ignore:
Timestamp:
Jun 24, 2021 3:56:05 PM (3 years ago)
Author:
vboxsync
Message:

Audio/ValKit: More code for audio verification. bugref:10008

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioTest.cpp

    r89889 r89890  
    128128
    129129/**
    130  * Returns a random test tone frequency.
    131  */
    132 DECLINLINE(double) audioTestToneGetRandomFreq(void)
    133 {
    134     return s_aAudioTestToneFreqsHz[RTRandU32Ex(0, RT_ELEMENTS(s_aAudioTestToneFreqsHz) - 1)];
    135 }
    136 
    137 /**
    138130 * Initializes a test tone with a specific frequency (in Hz).
    139131 *
     
    147139{
    148140    if (dbFreq == 0.0)
    149         dbFreq = audioTestToneGetRandomFreq();
     141        dbFreq = AudioTestToneGetRandomFreq();
    150142
    151143    pTone->rdFreqHz = dbFreq;
     
    290282
    291283/**
    292  * Initializes an audio test tone parameters struct with random values.
    293  * @param   pToneParams         Test tone parameters to initialize.
    294  * @param   pProps              PCM properties to use for the test tone.
    295  */
    296 int AudioTestToneParamsInitRandom(PAUDIOTESTTONEPARMS pToneParams, PPDMAUDIOPCMPROPS pProps)
    297 {
    298     AssertReturn(PDMAudioPropsAreValid(pProps), VERR_INVALID_PARAMETER);
    299 
    300     memcpy(&pToneParams->Props, pProps, sizeof(PDMAUDIOPCMPROPS));
    301 
    302     /** @todo Make this a bit more sophisticated later, e.g. muting and prequel/sequel are not very balanced. */
    303 
    304     pToneParams->dbFreqHz       = audioTestToneGetRandomFreq();
    305     pToneParams->msPrequel      = RTRandU32Ex(0, RT_MS_5SEC);
    306 #ifdef DEBUG_andy
    307     pToneParams->msDuration     = RTRandU32Ex(0, RT_MS_1SEC);
    308 #else
    309     pToneParams->msDuration     = RTRandU32Ex(0, RT_MS_10SEC); /** @todo Probably a bit too long, but let's see. */
    310 #endif
    311     pToneParams->msSequel       = RTRandU32Ex(0, RT_MS_5SEC);
    312     pToneParams->uVolumePercent = RTRandU32Ex(0, 100);
    313 
    314     return VINF_SUCCESS;
     284 * Returns a random test tone frequency.
     285 */
     286double AudioTestToneGetRandomFreq(void)
     287{
     288    return s_aAudioTestToneFreqsHz[RTRandU32Ex(0, RT_ELEMENTS(s_aAudioTestToneFreqsHz) - 1)];
    315289}
    316290
     
    14111385
    14121386/**
     1387 * Returns whether a test set has running (active) tests or not.
     1388 *
     1389 * @returns \c true if it has running tests, or \c false if not.
     1390 * @param   pSet                Test set to return status for.
     1391 */
     1392bool AudioTestSetIsRunning(PAUDIOTESTSET pSet)
     1393{
     1394    return (pSet->cTestsRunning > 0);
     1395}
     1396
     1397/**
    14131398 * Unpacks a formerly packed audio test set.
    14141399 *
     
    17131698    rc = RTFileQuerySize(pObjB->File.hFile, &cbSizeB);
    17141699    AssertRCReturn(rc, rc);
    1715     if (   cbSizeA != cbSizeB
    1716         || !audioTestFilesCompareBinary(pObjA->File.hFile, pObjB->File.hFile, cbSizeA))
     1700
     1701    if (!cbSizeA)
     1702    {
     1703        int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "File '%s' is empty\n", pObjA->szName);
     1704        AssertRC(rc2);
     1705    }
     1706
     1707    if (!cbSizeB)
     1708    {
     1709        int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "File '%s' is empty\n", pObjB->szName);
     1710        AssertRC(rc2);
     1711    }
     1712
     1713    if (cbSizeA != cbSizeB)
     1714    {
     1715        int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "File '%s' is %zu bytes %s than '%s'\n",
     1716                                        pObjA->szName,
     1717                                        cbSizeA > cbSizeB ? cbSizeA - cbSizeB : cbSizeB - cbSizeA,
     1718                                        cbSizeA > cbSizeB ? "bigger" : "smaller",
     1719                                        pObjB->szName);
     1720        AssertRC(rc2);
     1721    }
     1722    else if (audioTestFilesCompareBinary(pObjA->File.hFile, pObjB->File.hFile, cbSizeA))
    17171723    {
    17181724        /** @todo Add more sophisticated stuff here. */
    17191725
    1720         int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "Files '%s' and '%s' don't match\n", szObjA, szObjB);
     1726        int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "Files '%s' and '%s' have different content\n",
     1727                                        pObjA->szName, pObjB->szName);
    17211728        AssertRC(rc2);
    17221729    }
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