Changeset 88112 in vbox for trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
- Timestamp:
- Mar 12, 2021 8:41:05 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r88028 r88112 38 38 RTTestSub(hTest, "Basics"); 39 39 40 static const PDMAUDIOPCMPROPS s_Cfg441StereoS16 = PDMAUDIOPCMPROPS_INITIALIZOR(40 const PDMAUDIOPCMPROPS Cfg441StereoS16 = PDMAUDIOPCMPROPS_INITIALIZOR( 41 41 /* a_cb: */ 2, 42 42 /* a_fSigned: */ true, … … 46 46 /* a_fSwapEndian: */ false 47 47 ); 48 static const PDMAUDIOPCMPROPS s_Cfg441StereoU16 = PDMAUDIOPCMPROPS_INITIALIZOR(48 const PDMAUDIOPCMPROPS Cfg441StereoU16 = PDMAUDIOPCMPROPS_INITIALIZOR( 49 49 /* a_cb: */ 2, 50 50 /* a_fSigned: */ false, … … 54 54 /* a_fSwapEndian: */ false 55 55 ); 56 static const PDMAUDIOPCMPROPS s_Cfg441StereoU32 = PDMAUDIOPCMPROPS_INITIALIZOR(56 const PDMAUDIOPCMPROPS Cfg441StereoU32 = PDMAUDIOPCMPROPS_INITIALIZOR( 57 57 /* a_cb: */ 4, 58 58 /* a_fSigned: */ false, … … 63 63 ); 64 64 65 RTTESTI_CHECK(PDMAudioPropsGetBitrate(& s_Cfg441StereoS16) == 44100*4*8);66 RTTESTI_CHECK(PDMAudioPropsGetBitrate(& s_Cfg441StereoU16) == 44100*4*8);67 RTTESTI_CHECK(PDMAudioPropsGetBitrate(& s_Cfg441StereoU32) == 44100*8*8);68 69 RTTESTI_CHECK(DrvAudioHlpPcmPropsAreValid(& s_Cfg441StereoS16));70 RTTESTI_CHECK(DrvAudioHlpPcmPropsAreValid(& s_Cfg441StereoU16) == false); /* go figure */71 RTTESTI_CHECK(DrvAudioHlpPcmPropsAreValid(& s_Cfg441StereoU32) == false); /* go figure */72 73 74 RTTESTI_CHECK_MSG(PDMAUDIOPCMPROPS_F2B(& s_Cfg441StereoS16, 1) == 4,75 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(& s_Cfg441StereoS16, 1)));76 RTTESTI_CHECK_MSG(PDMAUDIOPCMPROPS_F2B(& s_Cfg441StereoU16, 1) == 4,77 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(& s_Cfg441StereoU16, 1)));78 RTTESTI_CHECK_MSG(PDMAUDIOPCMPROPS_F2B(& s_Cfg441StereoU32, 1) == 8,79 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(& s_Cfg441StereoU32, 1)));80 81 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(& s_Cfg441StereoS16) == 4,82 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(& s_Cfg441StereoS16)));83 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(& s_Cfg441StereoU16) == 4,84 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(& s_Cfg441StereoU16)));85 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(& s_Cfg441StereoU32) == 8,86 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(& s_Cfg441StereoU32)));65 RTTESTI_CHECK(PDMAudioPropsGetBitrate(&Cfg441StereoS16) == 44100*4*8); 66 RTTESTI_CHECK(PDMAudioPropsGetBitrate(&Cfg441StereoU16) == 44100*4*8); 67 RTTESTI_CHECK(PDMAudioPropsGetBitrate(&Cfg441StereoU32) == 44100*8*8); 68 69 RTTESTI_CHECK(DrvAudioHlpPcmPropsAreValid(&Cfg441StereoS16)); 70 RTTESTI_CHECK(DrvAudioHlpPcmPropsAreValid(&Cfg441StereoU16) == false); /* go figure */ 71 RTTESTI_CHECK(DrvAudioHlpPcmPropsAreValid(&Cfg441StereoU32) == false); /* go figure */ 72 73 74 RTTESTI_CHECK_MSG(PDMAUDIOPCMPROPS_F2B(&Cfg441StereoS16, 1) == 4, 75 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(&Cfg441StereoS16, 1))); 76 RTTESTI_CHECK_MSG(PDMAUDIOPCMPROPS_F2B(&Cfg441StereoU16, 1) == 4, 77 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(&Cfg441StereoU16, 1))); 78 RTTESTI_CHECK_MSG(PDMAUDIOPCMPROPS_F2B(&Cfg441StereoU32, 1) == 8, 79 ("got %x, expected 4\n", PDMAUDIOPCMPROPS_F2B(&Cfg441StereoU32, 1))); 80 81 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(&Cfg441StereoS16) == 4, 82 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(&Cfg441StereoS16))); 83 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(&Cfg441StereoU16) == 4, 84 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(&Cfg441StereoU16))); 85 RTTESTI_CHECK_MSG(PDMAudioPropsBytesPerFrame(&Cfg441StereoU32) == 8, 86 ("got %x, expected 4\n", PDMAudioPropsBytesPerFrame(&Cfg441StereoU32))); 87 87 88 88 uint32_t u32; 89 89 for (uint32_t i = 0; i < 256; i += 8) 90 90 { 91 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(& s_Cfg441StereoU32, i) == true);91 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(&Cfg441StereoU32, i) == true); 92 92 for (uint32_t j = 1; j < 8; j++) 93 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(& s_Cfg441StereoU32, i + j) == false);93 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(&Cfg441StereoU32, i + j) == false); 94 94 for (uint32_t j = 0; j < 8; j++) 95 RTTESTI_CHECK(PDMAudioPropsFloorBytesToFrame(& s_Cfg441StereoU32, i + j) == i);95 RTTESTI_CHECK(PDMAudioPropsFloorBytesToFrame(&Cfg441StereoU32, i + j) == i); 96 96 } 97 97 for (uint32_t i = 0; i < 4096; i += 4) 98 98 { 99 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(& s_Cfg441StereoS16, i) == true);99 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(&Cfg441StereoS16, i) == true); 100 100 for (uint32_t j = 1; j < 4; j++) 101 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(& s_Cfg441StereoS16, i + j) == false);101 RTTESTI_CHECK(PDMAudioPropsIsSizeAligned(&Cfg441StereoS16, i + j) == false); 102 102 for (uint32_t j = 0; j < 4; j++) 103 RTTESTI_CHECK(PDMAudioPropsFloorBytesToFrame(& s_Cfg441StereoS16, i + j) == i);104 } 105 106 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(& s_Cfg441StereoS16, 44100)) == 44100 * 2 * 2,103 RTTESTI_CHECK(PDMAudioPropsFloorBytesToFrame(&Cfg441StereoS16, i + j) == i); 104 } 105 106 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&Cfg441StereoS16, 44100)) == 44100 * 2 * 2, 107 107 ("cb=%RU32\n", u32)); 108 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(& s_Cfg441StereoS16, 2)) == 2 * 2 * 2,108 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&Cfg441StereoS16, 2)) == 2 * 2 * 2, 109 109 ("cb=%RU32\n", u32)); 110 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(& s_Cfg441StereoS16, 1)) == 4,110 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&Cfg441StereoS16, 1)) == 4, 111 111 ("cb=%RU32\n", u32)); 112 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(& s_Cfg441StereoU16, 1)) == 4,112 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&Cfg441StereoU16, 1)) == 4, 113 113 ("cb=%RU32\n", u32)); 114 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(& s_Cfg441StereoU32, 1)) == 8,114 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsFramesToBytes(&Cfg441StereoU32, 1)) == 8, 115 115 ("cb=%RU32\n", u32)); 116 116 117 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(& s_Cfg441StereoS16, 4)) == 1, ("cb=%RU32\n", u32));118 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(& s_Cfg441StereoU16, 4)) == 1, ("cb=%RU32\n", u32));119 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(& s_Cfg441StereoU32, 8)) == 1, ("cb=%RU32\n", u32));117 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(&Cfg441StereoS16, 4)) == 1, ("cb=%RU32\n", u32)); 118 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(&Cfg441StereoU16, 4)) == 1, ("cb=%RU32\n", u32)); 119 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsBytesToFrames(&Cfg441StereoU32, 8)) == 1, ("cb=%RU32\n", u32)); 120 120 121 121 uint64_t u64; 122 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToNano(& s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_NS_1SEC,122 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToNano(&Cfg441StereoS16, 44100 * 2 * 2)) == RT_NS_1SEC, 123 123 ("ns=%RU64\n", u64)); 124 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToMicro(& s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_US_1SEC,124 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToMicro(&Cfg441StereoS16, 44100 * 2 * 2)) == RT_US_1SEC, 125 125 ("us=%RU64\n", u64)); 126 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToMilli(& s_Cfg441StereoS16, 44100 * 2 * 2)) == RT_MS_1SEC,126 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsBytesToMilli(&Cfg441StereoS16, 44100 * 2 * 2)) == RT_MS_1SEC, 127 127 ("ms=%RU64\n", u64)); 128 128 129 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(& s_Cfg441StereoS16, 44100)) == RT_NS_1SEC, ("ns=%RU64\n", u64));130 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(& s_Cfg441StereoS16, 1)) == 22675, ("ns=%RU64\n", u64));131 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(& s_Cfg441StereoS16, 31)) == 702947, ("ns=%RU64\n", u64));132 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(& s_Cfg441StereoS16, 255)) == 5782312, ("ns=%RU64\n", u64));133 //RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToMicro(& s_Cfg441StereoS16, 44100)) == RT_US_1SEC,129 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(&Cfg441StereoS16, 44100)) == RT_NS_1SEC, ("ns=%RU64\n", u64)); 130 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(&Cfg441StereoS16, 1)) == 22675, ("ns=%RU64\n", u64)); 131 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(&Cfg441StereoS16, 31)) == 702947, ("ns=%RU64\n", u64)); 132 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToNano(&Cfg441StereoS16, 255)) == 5782312, ("ns=%RU64\n", u64)); 133 //RTTESTI_CHECK_MSG((u64 = DrvAudioHlpFramesToMicro(&Cfg441StereoS16, 44100)) == RT_US_1SEC, 134 134 // ("us=%RU64\n", u64)); 135 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToMilli(& s_Cfg441StereoS16, 44100)) == RT_MS_1SEC, ("ms=%RU64\n", u64));136 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToMilli(& s_Cfg441StereoS16, 255)) == 5, ("ms=%RU64\n", u64));137 138 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToFrames(& s_Cfg441StereoS16, RT_NS_1SEC)) == 44100, ("cb=%RU32\n", u32));139 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToFrames(& s_Cfg441StereoS16, 215876)) == 10, ("cb=%RU32\n", u32));140 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToFrames(& s_Cfg441StereoS16, RT_MS_1SEC)) == 44100, ("cb=%RU32\n", u32));141 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToFrames(& s_Cfg441StereoU32, 6)) == 265, ("cb=%RU32\n", u32));142 143 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToBytes(& s_Cfg441StereoS16, RT_NS_1SEC)) == 44100*2*2, ("cb=%RU32\n", u32));144 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToBytes(& s_Cfg441StereoS16, 702947)) == 31*2*2, ("cb=%RU32\n", u32));145 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToBytes(& s_Cfg441StereoS16, RT_MS_1SEC)) == 44100*2*2, ("cb=%RU32\n", u32));146 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToBytes(& s_Cfg441StereoS16, 5)) == 884, ("cb=%RU32\n", u32));135 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToMilli(&Cfg441StereoS16, 44100)) == RT_MS_1SEC, ("ms=%RU64\n", u64)); 136 RTTESTI_CHECK_MSG((u64 = PDMAudioPropsFramesToMilli(&Cfg441StereoS16, 255)) == 5, ("ms=%RU64\n", u64)); 137 138 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToFrames(&Cfg441StereoS16, RT_NS_1SEC)) == 44100, ("cb=%RU32\n", u32)); 139 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToFrames(&Cfg441StereoS16, 215876)) == 10, ("cb=%RU32\n", u32)); 140 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToFrames(&Cfg441StereoS16, RT_MS_1SEC)) == 44100, ("cb=%RU32\n", u32)); 141 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToFrames(&Cfg441StereoU32, 6)) == 265, ("cb=%RU32\n", u32)); 142 143 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToBytes(&Cfg441StereoS16, RT_NS_1SEC)) == 44100*2*2, ("cb=%RU32\n", u32)); 144 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsNanoToBytes(&Cfg441StereoS16, 702947)) == 31*2*2, ("cb=%RU32\n", u32)); 145 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToBytes(&Cfg441StereoS16, RT_MS_1SEC)) == 44100*2*2, ("cb=%RU32\n", u32)); 146 RTTESTI_CHECK_MSG((u32 = PDMAudioPropsMilliToBytes(&Cfg441StereoS16, 5)) == 884, ("cb=%RU32\n", u32)); 147 147 148 148 /* DrvAudioHlpClearBuf: */ … … 152 152 153 153 memset(pbPage, 0x42, PAGE_SIZE); 154 PDMAudioPropsClearBuffer(& s_Cfg441StereoS16, pbPage, PAGE_SIZE, PAGE_SIZE / 4);154 PDMAudioPropsClearBuffer(&Cfg441StereoS16, pbPage, PAGE_SIZE, PAGE_SIZE / 4); 155 155 RTTESTI_CHECK(ASMMemIsZero(pbPage, PAGE_SIZE)); 156 156 157 157 memset(pbPage, 0x42, PAGE_SIZE); 158 PDMAudioPropsClearBuffer(& s_Cfg441StereoU16, pbPage, PAGE_SIZE, PAGE_SIZE / 4);158 PDMAudioPropsClearBuffer(&Cfg441StereoU16, pbPage, PAGE_SIZE, PAGE_SIZE / 4); 159 159 for (uint32_t off = 0; off < PAGE_SIZE; off += 2) 160 160 RTTESTI_CHECK_MSG(pbPage[off] == 0x80 && pbPage[off + 1] == 0, ("off=%#x: %#x %x\n", off, pbPage[off], pbPage[off + 1])); 161 161 162 162 memset(pbPage, 0x42, PAGE_SIZE); 163 PDMAudioPropsClearBuffer(& s_Cfg441StereoU32, pbPage, PAGE_SIZE, PAGE_SIZE / 8);163 PDMAudioPropsClearBuffer(&Cfg441StereoU32, pbPage, PAGE_SIZE, PAGE_SIZE / 8); 164 164 for (uint32_t off = 0; off < PAGE_SIZE; off += 4) 165 165 RTTESTI_CHECK(pbPage[off] == 0x80 && pbPage[off + 1] == 0 && pbPage[off + 2] == 0 && pbPage[off + 3] == 0); … … 168 168 RTTestDisableAssertions(hTest); 169 169 memset(pbPage, 0x42, PAGE_SIZE); 170 PDMAudioPropsClearBuffer(& s_Cfg441StereoS16, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */170 PDMAudioPropsClearBuffer(&Cfg441StereoS16, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */ 171 171 RTTESTI_CHECK(ASMMemIsZero(pbPage, PAGE_SIZE)); 172 172 173 173 memset(pbPage, 0x42, PAGE_SIZE); 174 PDMAudioPropsClearBuffer(& s_Cfg441StereoU16, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */174 PDMAudioPropsClearBuffer(&Cfg441StereoU16, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */ 175 175 for (uint32_t off = 0; off < PAGE_SIZE; off += 2) 176 176 RTTESTI_CHECK_MSG(pbPage[off] == 0x80 && pbPage[off + 1] == 0, ("off=%#x: %#x %x\n", off, pbPage[off], pbPage[off + 1])); 177 177 178 178 memset(pbPage, 0x42, PAGE_SIZE); 179 PDMAudioPropsClearBuffer(& s_Cfg441StereoU32, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */179 PDMAudioPropsClearBuffer(&Cfg441StereoU32, pbPage, PAGE_SIZE, PAGE_SIZE); /* should adjust down the frame count. */ 180 180 for (uint32_t off = 0; off < PAGE_SIZE; off += 4) 181 181 RTTESTI_CHECK(pbPage[off] == 0x80 && pbPage[off + 1] == 0 && pbPage[off + 2] == 0 && pbPage[off + 3] == 0);
Note:
See TracChangeset
for help on using the changeset viewer.