VirtualBox

Changeset 89293 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
May 26, 2021 2:04:25 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144639
Message:

Audio/ValKit: Made AudioTestToneInit() a bit more flexible; also use it when AudioTestToneInitRandom() is being called. bugref:10008

Location:
trunk/src/VBox/Devices/Audio
Files:
2 edited

Legend:

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

    r89290 r89293  
    8686
    8787/**
     88 * Returns a random test tone frequency.
     89 */
     90DECLINLINE(double) audioTestGetRandomFreq(void)
     91{
     92    return s_aAudioTestToneFreqsHz[RTRandU32Ex(0, RT_ELEMENTS(s_aAudioTestToneFreqsHz) - 1)];
     93}
     94
     95/**
    8896 * Initializes a test tone with a specific frequency (in Hz).
    8997 *
    90  * @returns Randomly picked frequency (in Hz).
     98 * @returns Used tone frequency (in Hz).
    9199 * @param   pTone               Pointer to test tone to initialize.
    92100 * @param   pProps              PCM properties to use for the test tone.
    93101 * @param   dbFreq              Frequency (in Hz) to initialize tone with.
    94  */
    95 void AudioTestToneInit(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps, double dbFreq)
    96 {
     102 *                              When set to 0.0, a random frequency will be chosen.
     103 */
     104double AudioTestToneInit(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps, double dbFreq)
     105{
     106    if (dbFreq == 0.0)
     107        dbFreq = audioTestGetRandomFreq();
     108
    97109    /* Pick a frequency from our selection, so that every time a recording starts
    98110     * we'll hopfully generate a different note. */
     
    104116
    105117    pTone->enmType = AUDIOTESTTONETYPE_SINE; /* Only type implemented so far. */
     118
     119    return dbFreq;
    106120}
    107121
     
    109123 * Initializes a test tone by picking a random but well-known frequency (in Hz).
    110124 *
    111  * @returns Randomly picked frequency (in Hz).
     125 * @returns Randomly picked tone frequency (in Hz).
    112126 * @param   pTone               Pointer to test tone to initialize.
    113127 * @param   pProps              PCM properties to use for the test tone.
     
    115129double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps)
    116130{
    117     AudioTestToneInit(pTone, pProps,
    118                       /* Pick a frequency from our selection, so that every time a recording starts
    119                        * we'll hopfully generate a different note. */
    120                       s_aAudioTestToneFreqsHz[RTRandU32Ex(0, RT_ELEMENTS(s_aAudioTestToneFreqsHz) - 1)]);
    121 
    122     return pTone->rdFreqHz;
     131    return AudioTestToneInit(pTone, pProps,
     132                             /* Pick a frequency from our selection, so that every time a recording starts
     133                              * we'll hopfully generate a different note. */
     134                             0.0);
    123135}
    124136
  • trunk/src/VBox/Devices/Audio/AudioTest.h

    r89289 r89293  
    293293
    294294
    295 void  AudioTestToneInit(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps, double dbFreq);
     295double AudioTestToneInit(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps, double dbFreq);
    296296double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps);
    297297int    AudioTestToneGenerate(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten);
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