Changeset 89335 in vbox for trunk/src/VBox/Devices/Audio/testcase
- Timestamp:
- May 28, 2021 8:44:41 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/testcase/tstAudioMixBuffer.cpp
r89333 r89335 215 215 RTTESTI_CHECK(AUDIOMIXBUF_F2B(&mb, AudioMixBufFree(&mb)) == AudioMixBufFreeBytes(&mb)); 216 216 217 AUDIOMIXBUFWRITESTATE WrState; 218 RTTESTI_CHECK_RC(AudioMixBufInitWriteState(&mb, &WrState, &config), VINF_SUCCESS); 217 AUDIOMIXBUFWRITESTATE WriteState; 218 RTTESTI_CHECK_RC(AudioMixBufInitWriteState(&mb, &WriteState, &config), VINF_SUCCESS); 219 220 AUDIOMIXBUFPEEKSTATE PeekState; 221 RTTESTI_CHECK_RC(AudioMixBufInitPeekState(&mb, &PeekState, &config), VINF_SUCCESS); 219 222 220 223 /* … … 227 230 RTTESTI_CHECK(AudioMixBufUsed(&mb) == 0); 228 231 229 AudioMixBufWrite(&mb, &Wr State, &aFrames16, sizeof(aFrames16), 0 /*offDstFrame*/, cBufSize / 4, &cFramesWritten);232 AudioMixBufWrite(&mb, &WriteState, &aFrames16, sizeof(aFrames16), 0 /*offDstFrame*/, cBufSize / 4, &cFramesWritten); 230 233 RTTESTI_CHECK(cFramesWritten == 1 /* Frames */); 231 234 RTTESTI_CHECK(AudioMixBufUsed(&mb) == 0); … … 235 238 RTTESTI_CHECK(AudioMixBufWritePos(&mb) == 1); 236 239 237 AudioMixBufWrite(&mb, &Wr State, &aFrames32, sizeof(aFrames32), 0 /*offDstFrame*/, cBufSize / 4, &cFramesWritten);240 AudioMixBufWrite(&mb, &WriteState, &aFrames32, sizeof(aFrames32), 0 /*offDstFrame*/, cBufSize / 4, &cFramesWritten); 238 241 RTTESTI_CHECK(cFramesWritten == 2 /* Frames */); 239 242 AudioMixBufCommit(&mb, cFramesWritten); … … 253 256 uint16_t *paSamples = (uint16_t *)RTMemAlloc(cbSamples); 254 257 RTTESTI_CHECK_RETV(paSamples); 255 AudioMixBufWrite(&mb, &Wr State, paSamples, cbSamples, 0 /*offDstFrame*/, cBufSize, &cFramesWritten);258 AudioMixBufWrite(&mb, &WriteState, paSamples, cbSamples, 0 /*offDstFrame*/, cBufSize, &cFramesWritten); 256 259 RTTESTI_CHECK(cFramesWritten == cBufSize); 257 260 AudioMixBufCommit(&mb, cFramesWritten); … … 263 266 264 267 /* 265 * Circular writes.268 * Writes and reads (used to be circular). 266 269 */ 267 270 AudioMixBufReset(&mb); … … 272 275 for (uint32_t i = 0; i < cToWrite; i++) 273 276 { 274 AudioMixBufWrite(&mb, &Wr State, &aFrames16[0], sizeof(aFrames16), 0 /*offDstFrame*/, 1, &cFramesWritten);277 AudioMixBufWrite(&mb, &WriteState, &aFrames16[0], sizeof(aFrames16), 0 /*offDstFrame*/, 1, &cFramesWritten); 275 278 RTTESTI_CHECK(cFramesWritten == 1); 276 279 AudioMixBufCommit(&mb, cFramesWritten); … … 281 284 RTTESTI_CHECK(AudioMixBufUsed(&mb) == cToWrite + cFramesWrittenAbs /* + last absolute write */); 282 285 283 AudioMixBufWrite(&mb, &Wr State, &aFrames16[0], sizeof(aFrames16), 0 /*offDstFrame*/, 1, &cFramesWritten);286 AudioMixBufWrite(&mb, &WriteState, &aFrames16[0], sizeof(aFrames16), 0 /*offDstFrame*/, 1, &cFramesWritten); 284 287 RTTESTI_CHECK(cFramesWritten == 1); 285 288 AudioMixBufCommit(&mb, cFramesWritten); … … 288 291 RTTESTI_CHECK(AudioMixBufUsed(&mb) == cBufSize); 289 292 290 /* Circular reads. */ 293 /* Reads. */ 294 RTTESTI_CHECK(AudioMixBufReadPos(&mb) == 0); 295 uint32_t cbRead; 296 uint16_t aFrames16Buf[RT_ELEMENTS(aFrames16)]; 291 297 uint32_t cToRead = AudioMixBufSize(&mb) - cFramesWrittenAbs - 1; 292 298 for (uint32_t i = 0; i < cToRead; i++) 293 299 { 294 RTTESTI_CHECK_RC_OK(AudioMixBufAcquireReadBlock(&mb, &aFrames16, sizeof(aFrames16), &cFramesRead));300 AudioMixBufPeek(&mb, 0 /*offSrcFrame*/, 1, &cFramesRead, &PeekState, aFrames16Buf, sizeof(aFrames16Buf), &cbRead); 295 301 RTTESTI_CHECK(cFramesRead == 1); 296 AudioMixBufReleaseReadBlock(&mb, cFramesRead); 297 AudioMixBufFinish(&mb, cFramesRead); 302 RTTESTI_CHECK(cbRead == sizeof(aFrames16Buf)); 303 AudioMixBufAdvance(&mb, cFramesRead); 304 RTTESTI_CHECK(AudioMixBufReadPos(&mb) == i + 1); 298 305 } 299 306 RTTESTI_CHECK(!AudioMixBufIsEmpty(&mb)); … … 302 309 RTTESTI_CHECK(AudioMixBufUsed(&mb) == cBufSize - cToRead); 303 310 304 RTTESTI_CHECK_RC_OK(AudioMixBufAcquireReadBlock(&mb, &aFrames16, sizeof(aFrames16), &cFramesRead));311 AudioMixBufPeek(&mb, 0 /*offSrcFrame*/, 1, &cFramesRead, &PeekState, aFrames16Buf, sizeof(aFrames16Buf), &cbRead); 305 312 RTTESTI_CHECK(cFramesRead == 1); 306 AudioMixBufReleaseReadBlock(&mb, cFramesRead);307 AudioMixBuf Finish(&mb, cFramesRead);313 RTTESTI_CHECK(cbRead == sizeof(aFrames16Buf)); 314 AudioMixBufAdvance(&mb, cFramesRead); 308 315 RTTESTI_CHECK(AudioMixBufFree(&mb) == cBufSize - cFramesWrittenAbs); 309 316 RTTESTI_CHECK(AudioMixBufFreeBytes(&mb) == AUDIOMIXBUF_F2B(&mb, cBufSize - cFramesWrittenAbs)); 310 317 RTTESTI_CHECK(AudioMixBufUsed(&mb) == cFramesWrittenAbs); 318 RTTESTI_CHECK(AudioMixBufReadPos(&mb) == 0); 311 319 312 320 AudioMixBufDestroy(&mb);
Note:
See TracChangeset
for help on using the changeset viewer.