Changeset 54460 in vbox for trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
- Timestamp:
- Feb 24, 2015 4:50:08 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 98565
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r53945 r54460 5 5 6 6 /* 7 * Copyright (C) 2014 Oracle Corporation7 * Copyright (C) 2014-2015 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 133 133 static int tstParentChild(RTTEST hTest) 134 134 { 135 RTTestSubF(hTest, " Child<->Parent");135 RTTestSubF(hTest, "2 Children -> Parent"); 136 136 137 137 uint32_t cBufSize = _1K; 138 138 139 PDMAUDIOSTREAMCFG c p =139 PDMAUDIOSTREAMCFG cfg_p = 140 140 { 141 141 44100, /* Hz */ … … 146 146 PDMPCMPROPS props; 147 147 148 int rc = drvAudioStreamCfgToProps(&c p, &props);148 int rc = drvAudioStreamCfgToProps(&cfg_p, &props); 149 149 AssertRC(rc); 150 150 … … 152 152 RTTESTI_CHECK_RC_OK(audioMixBufInit(&parent, "Parent", &props, cBufSize)); 153 153 154 PDMAUDIOSTREAMCFG c c =154 PDMAUDIOSTREAMCFG cfg_c1 = /* Downmixing */ 155 155 { 156 156 22100, /* Hz */ … … 160 160 }; 161 161 162 rc = drvAudioStreamCfgToProps(&c c, &props);162 rc = drvAudioStreamCfgToProps(&cfg_c1, &props); 163 163 AssertRC(rc); 164 164 … … 167 167 RTTESTI_CHECK_RC_OK(audioMixBufLinkTo(&child1, &parent)); 168 168 169 PDMAUDIOSTREAMCFG cfg_c2 = /* Upmixing */ 170 { 171 48000, /* Hz */ 172 2 /* Channels */, 173 AUD_FMT_S16 /* Format */, 174 PDMAUDIOENDIANESS_LITTLE /* Endianess */ 175 }; 176 177 rc = drvAudioStreamCfgToProps(&cfg_c2, &props); 178 AssertRC(rc); 179 169 180 PDMAUDIOMIXBUF child2; 170 181 RTTESTI_CHECK_RC_OK(audioMixBufInit(&child2, "Child2", &props, cBufSize)); … … 172 183 173 184 /* 174 * Writing + mixing from child(s) -> parent, sequential. 175 */ 176 int16_t samples16[2] = { 0xAA, 0xBB }; 177 uint32_t read = 0, written = 0, proc, mixed = 0; 178 179 RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child1, 0, &samples16, sizeof(samples16), 180 &written)); 181 RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child1, written, &mixed)); 182 RTTESTI_CHECK(mixed == 1); 183 RTTESTI_CHECK(audioMixBufMixed(&child1) == mixed); 184 185 RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child2, 0, &samples16, sizeof(samples16), 186 &written)); 187 RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child2, written, &mixed)); 188 RTTESTI_CHECK(mixed == 1); 189 RTTESTI_CHECK(audioMixBufMixed(&child2) == mixed); 185 * Writing + mixing from child/children -> parent, sequential. 186 */ 187 size_t cbBuf = _1K; 188 char pvBuf[_1K]; 189 int16_t samples16[32] = { 0xAA, 0xBB }; 190 uint32_t read , written, proc, mixed; 191 192 uint32_t cSamplesParent1 = 16; 193 uint32_t cSamplesChild1 = 16; 194 uint32_t cSamplesParent2 = 32; 195 uint32_t cSamplesChild2 = 16; 196 197 for (int i = 0; i < 32; i++) 198 { 199 RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child1, 0, &samples16, sizeof(samples16), &written)); 200 RTTESTI_CHECK(written == cSamplesChild1); 201 RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child1, written, &mixed)); 202 RTTESTI_CHECK(mixed == cSamplesChild1); 203 204 RTTESTI_CHECK_RC_OK(audioMixBufReadCirc(&parent, pvBuf, cbBuf, &read)); 205 RTTESTI_CHECK(read == 31); 206 207 RTTESTI_CHECK_RC_OK(audioMixBufWriteAt(&child2, 0, &samples16, sizeof(samples16), &written)); 208 RTTESTI_CHECK(written == cSamplesChild2); 209 RTTESTI_CHECK_RC_OK(audioMixBufMixToParent(&child2, written, &mixed)); 210 RTTESTI_CHECK(mixed == cSamplesChild2); 211 212 RTTESTI_CHECK_RC_OK(audioMixBufReadCirc(&parent, pvBuf, cbBuf, &read)); 213 RTTESTI_CHECK(read == 15); 214 } 190 215 191 216 RTTESTI_CHECK(audioMixBufProcessed(&parent) == 0); 192 193 217 194 218 return RTTestSubErrorCount(hTest) ? VERR_GENERAL_FAILURE : VINF_SUCCESS; … … 208 232 RTTestBanner(hTest); 209 233 210 rc = tstSingle(hTest);211 if (RT_SUCCESS(rc)) 234 /*rc = tstSingle(hTest); 235 if (RT_SUCCESS(rc))*/ 212 236 rc = tstParentChild(hTest); 213 237
Note:
See TracChangeset
for help on using the changeset viewer.