VirtualBox

Changeset 108630 in vbox


Ignore:
Timestamp:
Mar 20, 2025 11:15:51 AM (7 weeks ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
168042
Message:

Devices/Audio/testcase/tstAudioMixBuffer.cpp: Make it work for hosts where we don't know the host page size when building, bugref:10391

File:
1 edited

Legend:

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

    r106061 r108630  
    3737#include <iprt/string.h>
    3838#include <iprt/test.h>
     39#include <iprt/system.h>
    3940
    4041#include <VBox/vmm/pdm.h>
     
    168169
    169170    /* DrvAudioHlpClearBuf: */
     171    size_t const cbPageSize = RTSystemGetPageSize();
    170172    uint8_t *pbPage;
    171     int rc = RTTestGuardedAlloc(hTest, HOST_PAGE_SIZE, 0, false /*fHead*/, (void **)&pbPage);
     173    int rc = RTTestGuardedAlloc(hTest, cbPageSize, 0, false /*fHead*/, (void **)&pbPage);
    172174    RTTESTI_CHECK_RC_OK_RETV(rc);
    173175
    174     memset(pbPage, 0x42, HOST_PAGE_SIZE);
    175     PDMAudioPropsClearBuffer(&Cfg441StereoS16, pbPage, HOST_PAGE_SIZE, HOST_PAGE_SIZE / 4);
    176     RTTESTI_CHECK(ASMMemIsZero(pbPage, HOST_PAGE_SIZE));
    177 
    178     memset(pbPage, 0x42, HOST_PAGE_SIZE);
    179     PDMAudioPropsClearBuffer(&Cfg441StereoU16, pbPage, HOST_PAGE_SIZE, HOST_PAGE_SIZE / 4);
    180     for (uint32_t off = 0; off < HOST_PAGE_SIZE; off += 2)
     176    memset(pbPage, 0x42, cbPageSize);
     177    PDMAudioPropsClearBuffer(&Cfg441StereoS16, pbPage, cbPageSize, cbPageSize / 4);
     178    RTTESTI_CHECK(ASMMemIsZero(pbPage, cbPageSize));
     179
     180    memset(pbPage, 0x42, cbPageSize);
     181    PDMAudioPropsClearBuffer(&Cfg441StereoU16, pbPage, cbPageSize, cbPageSize / 4);
     182    for (uint32_t off = 0; off < cbPageSize; off += 2)
    181183        RTTESTI_CHECK_MSG(pbPage[off] == 0 && pbPage[off + 1] == 0x80, ("off=%#x: %#x %x\n", off, pbPage[off], pbPage[off + 1]));
    182184
    183     memset(pbPage, 0x42, HOST_PAGE_SIZE);
    184     PDMAudioPropsClearBuffer(&Cfg441StereoU32, pbPage, HOST_PAGE_SIZE, HOST_PAGE_SIZE / 8);
    185     for (uint32_t off = 0; off < HOST_PAGE_SIZE; off += 4)
     185    memset(pbPage, 0x42, cbPageSize);
     186    PDMAudioPropsClearBuffer(&Cfg441StereoU32, pbPage, cbPageSize, cbPageSize / 8);
     187    for (uint32_t off = 0; off < cbPageSize; off += 4)
    186188        RTTESTI_CHECK(pbPage[off] == 0 && pbPage[off + 1] == 0 && pbPage[off + 2] == 0 && pbPage[off + 3] == 0x80);
    187189
    188190
    189191    RTTestDisableAssertions(hTest);
    190     memset(pbPage, 0x42, HOST_PAGE_SIZE);
    191     PDMAudioPropsClearBuffer(&Cfg441StereoS16, pbPage, HOST_PAGE_SIZE, HOST_PAGE_SIZE); /* should adjust down the frame count. */
    192     RTTESTI_CHECK(ASMMemIsZero(pbPage, HOST_PAGE_SIZE));
    193 
    194     memset(pbPage, 0x42, HOST_PAGE_SIZE);
    195     PDMAudioPropsClearBuffer(&Cfg441StereoU16, pbPage, HOST_PAGE_SIZE, HOST_PAGE_SIZE); /* should adjust down the frame count. */
    196     for (uint32_t off = 0; off < HOST_PAGE_SIZE; off += 2)
     192    memset(pbPage, 0x42, cbPageSize);
     193    PDMAudioPropsClearBuffer(&Cfg441StereoS16, pbPage, cbPageSize, cbPageSize); /* should adjust down the frame count. */
     194    RTTESTI_CHECK(ASMMemIsZero(pbPage, cbPageSize));
     195
     196    memset(pbPage, 0x42, cbPageSize);
     197    PDMAudioPropsClearBuffer(&Cfg441StereoU16, pbPage, cbPageSize, cbPageSize); /* should adjust down the frame count. */
     198    for (uint32_t off = 0; off < cbPageSize; off += 2)
    197199        RTTESTI_CHECK_MSG(pbPage[off] == 0 && pbPage[off + 1] == 0x80, ("off=%#x: %#x %x\n", off, pbPage[off], pbPage[off + 1]));
    198200
    199     memset(pbPage, 0x42, HOST_PAGE_SIZE);
    200     PDMAudioPropsClearBuffer(&Cfg441StereoU32, pbPage, HOST_PAGE_SIZE, HOST_PAGE_SIZE); /* should adjust down the frame count. */
    201     for (uint32_t off = 0; off < HOST_PAGE_SIZE; off += 4)
     201    memset(pbPage, 0x42, cbPageSize);
     202    PDMAudioPropsClearBuffer(&Cfg441StereoU32, pbPage, cbPageSize, cbPageSize); /* should adjust down the frame count. */
     203    for (uint32_t off = 0; off < cbPageSize; off += 4)
    202204        RTTESTI_CHECK(pbPage[off] == 0 && pbPage[off + 1] == 0 && pbPage[off + 2] == 0 && pbPage[off + 3] == 0x80);
    203205    RTTestRestoreAssertions(hTest);
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