VirtualBox

Ignore:
Timestamp:
Mar 7, 2021 2:29:40 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143113
Message:

Audio: Fixed broken DrvAudioHlpBytesToNano and DrvAudioHlpBytesToMicro implementation (overflow), the latter is the only one used. Also fixed silly confusion about 'const' and pointers (you want what they point to to be const, not the pointers themselves. duh) bugref:9890

File:
1 edited

Legend:

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

    r82968 r87990  
    3333
    3434
    35 /*********************************************************************************************************************************
    36 *   Structures and Typedefs                                                                                                      *
    37 *********************************************************************************************************************************/
     35static void tstBasics(RTTEST hTest)
     36{
     37    RTTestSubF(hTest, "Single buffer");
     38
     39    static const PDMAUDIOPCMPROPS s_Cfg441StereoS16 = PDMAUDIOPCMPROPS_INITIALIZOR(
     40        /* a_cb: */             2,
     41        /* a_fSigned: */        true,
     42        /* a_cChannels: */      2,
     43        /* a_uHz: */            44100,
     44        /* a_cShift: */         PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(2 /* cb */, 2 /* cChannels */),
     45        /* a_fSwapEndian: */    false
     46    );
     47
     48    RTTESTI_CHECK_MSG(PDMAUDIOPCMPROPS_F2B(&s_Cfg441StereoS16, 1) == 4,
     49                      ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(&s_Cfg441StereoS16, 1)));
     50
     51    uint32_t u32;
     52    RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(44100, &s_Cfg441StereoS16)) == 44100 * 2 * 2,
     53                      ("cb=%RU32\n", u32));
     54    RTTESTI_CHECK_MSG((u32 = DrvAudioHlpFramesToBytes(2, &s_Cfg441StereoS16)) == 2 * 2 * 2,
     55                      ("cb=%RU32\n", u32));
     56
     57    uint64_t u64;
     58    RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToNano(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_NS_1SEC,
     59                      ("ns=%RU64\n", u64));
     60    RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToMicro(&s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_US_1SEC,
     61                      ("us=%RU64\n", u64));
     62    RTTESTI_CHECK_MSG((u64 = DrvAudioHlpBytesToMilli(44100 * 2 * 2, &s_Cfg441StereoS16)) == RT_MS_1SEC,
     63                      ("ms=%RU64\n", u64));
     64
     65
     66
     67}
     68
    3869
    3970static int tstSingle(RTTEST hTest)
    4071{
    41     RTTestSubF(hTest, "Single buffer");
     72    RTTestSub(hTest, "Single buffer");
    4273
    4374    /* 44100Hz, 2 Channels, S16 */
     
    232263     * Using AudioMixBufWriteAt for writing to children.
    233264     */
    234     RTTestSubF(hTest, "2 Children -> Parent (AudioMixBufWriteAt)");
     265    RTTestSub(hTest, "2 Children -> Parent (AudioMixBufWriteAt)");
    235266
    236267    uint32_t cChildrenSamplesMixedTotal = 0;
     
    308339    uint32_t         cBufSize = 256;
    309340
    310     RTTestSubF(hTest, "Sample conversion (U8)");
     341    RTTestSub(hTest, "Sample conversion (U8)");
    311342
    312343    /* 44100Hz, 1 Channel, U8 */
     
    413444    uint32_t         cBufSize = 256;
    414445
    415     RTTestSubF(hTest, "Sample conversion (S16)");
     446    RTTestSub(hTest, "Sample conversion (S16)");
    416447
    417448    /* 44100Hz, 1 Channel, S16 */
     
    509540    uint32_t         cBufSize = 256;
    510541
    511     RTTestSubF(hTest, "Volume control");
     542    RTTestSub(hTest, "Volume control");
    512543
    513544    /* Same for parent/child. */
     
    635666    RTTestBanner(hTest);
    636667
    637     rc = tstSingle(hTest);
    638     if (RT_SUCCESS(rc))
    639         rc = tstParentChild(hTest);
    640     if (RT_SUCCESS(rc))
    641         rc = tstConversion8(hTest);
    642     if (RT_SUCCESS(rc))
    643         rc = tstConversion16(hTest);
    644     if (RT_SUCCESS(rc))
    645         rc = tstVolume(hTest);
     668    tstBasics(hTest);
     669    tstSingle(hTest);
     670    tstParentChild(hTest);
     671    tstConversion8(hTest);
     672    tstConversion16(hTest);
     673    tstVolume(hTest);
    646674
    647675    /*
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