VirtualBox

Ignore:
Timestamp:
May 28, 2021 8:44:41 AM (4 years ago)
Author:
vboxsync
Message:

AudioMixer: Removed AudioMixBufAcquireReadBlock, AudioMixBufReleaseReadBlock and AudioMixBufFinish. bugref:9890

File:
1 edited

Legend:

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

    r89333 r89335  
    215215    RTTESTI_CHECK(AUDIOMIXBUF_F2B(&mb, AudioMixBufFree(&mb)) == AudioMixBufFreeBytes(&mb));
    216216
    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);
    219222
    220223    /*
     
    227230    RTTESTI_CHECK(AudioMixBufUsed(&mb) == 0);
    228231
    229     AudioMixBufWrite(&mb, &WrState, &aFrames16, sizeof(aFrames16), 0 /*offDstFrame*/, cBufSize / 4, &cFramesWritten);
     232    AudioMixBufWrite(&mb, &WriteState, &aFrames16, sizeof(aFrames16), 0 /*offDstFrame*/, cBufSize / 4, &cFramesWritten);
    230233    RTTESTI_CHECK(cFramesWritten == 1 /* Frames */);
    231234    RTTESTI_CHECK(AudioMixBufUsed(&mb) == 0);
     
    235238    RTTESTI_CHECK(AudioMixBufWritePos(&mb) == 1);
    236239
    237     AudioMixBufWrite(&mb, &WrState, &aFrames32, sizeof(aFrames32), 0 /*offDstFrame*/, cBufSize / 4, &cFramesWritten);
     240    AudioMixBufWrite(&mb, &WriteState, &aFrames32, sizeof(aFrames32), 0 /*offDstFrame*/, cBufSize / 4, &cFramesWritten);
    238241    RTTESTI_CHECK(cFramesWritten == 2 /* Frames */);
    239242    AudioMixBufCommit(&mb, cFramesWritten);
     
    253256    uint16_t *paSamples = (uint16_t *)RTMemAlloc(cbSamples);
    254257    RTTESTI_CHECK_RETV(paSamples);
    255     AudioMixBufWrite(&mb, &WrState, paSamples, cbSamples, 0 /*offDstFrame*/, cBufSize, &cFramesWritten);
     258    AudioMixBufWrite(&mb, &WriteState, paSamples, cbSamples, 0 /*offDstFrame*/, cBufSize, &cFramesWritten);
    256259    RTTESTI_CHECK(cFramesWritten == cBufSize);
    257260    AudioMixBufCommit(&mb, cFramesWritten);
     
    263266
    264267    /*
    265      * Circular writes.
     268     * Writes and reads (used to be circular).
    266269     */
    267270    AudioMixBufReset(&mb);
     
    272275    for (uint32_t i = 0; i < cToWrite; i++)
    273276    {
    274         AudioMixBufWrite(&mb, &WrState, &aFrames16[0], sizeof(aFrames16), 0 /*offDstFrame*/, 1, &cFramesWritten);
     277        AudioMixBufWrite(&mb, &WriteState, &aFrames16[0], sizeof(aFrames16), 0 /*offDstFrame*/, 1, &cFramesWritten);
    275278        RTTESTI_CHECK(cFramesWritten == 1);
    276279        AudioMixBufCommit(&mb, cFramesWritten);
     
    281284    RTTESTI_CHECK(AudioMixBufUsed(&mb) == cToWrite + cFramesWrittenAbs /* + last absolute write */);
    282285
    283     AudioMixBufWrite(&mb, &WrState, &aFrames16[0], sizeof(aFrames16), 0 /*offDstFrame*/, 1, &cFramesWritten);
     286    AudioMixBufWrite(&mb, &WriteState, &aFrames16[0], sizeof(aFrames16), 0 /*offDstFrame*/, 1, &cFramesWritten);
    284287    RTTESTI_CHECK(cFramesWritten == 1);
    285288    AudioMixBufCommit(&mb, cFramesWritten);
     
    288291    RTTESTI_CHECK(AudioMixBufUsed(&mb) == cBufSize);
    289292
    290     /* Circular reads. */
     293    /* Reads. */
     294    RTTESTI_CHECK(AudioMixBufReadPos(&mb) == 0);
     295    uint32_t cbRead;
     296    uint16_t aFrames16Buf[RT_ELEMENTS(aFrames16)];
    291297    uint32_t cToRead = AudioMixBufSize(&mb) - cFramesWrittenAbs - 1;
    292298    for (uint32_t i = 0; i < cToRead; i++)
    293299    {
    294         RTTESTI_CHECK_RC_OK(AudioMixBufAcquireReadBlock(&mb, &aFrames16, sizeof(aFrames16), &cFramesRead));
     300        AudioMixBufPeek(&mb, 0 /*offSrcFrame*/, 1, &cFramesRead, &PeekState, aFrames16Buf, sizeof(aFrames16Buf), &cbRead);
    295301        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);
    298305    }
    299306    RTTESTI_CHECK(!AudioMixBufIsEmpty(&mb));
     
    302309    RTTESTI_CHECK(AudioMixBufUsed(&mb) == cBufSize - cToRead);
    303310
    304     RTTESTI_CHECK_RC_OK(AudioMixBufAcquireReadBlock(&mb, &aFrames16, sizeof(aFrames16), &cFramesRead));
     311    AudioMixBufPeek(&mb, 0 /*offSrcFrame*/, 1, &cFramesRead, &PeekState, aFrames16Buf, sizeof(aFrames16Buf), &cbRead);
    305312    RTTESTI_CHECK(cFramesRead == 1);
    306     AudioMixBufReleaseReadBlock(&mb, cFramesRead);
    307     AudioMixBufFinish(&mb, cFramesRead);
     313    RTTESTI_CHECK(cbRead == sizeof(aFrames16Buf));
     314    AudioMixBufAdvance(&mb, cFramesRead);
    308315    RTTESTI_CHECK(AudioMixBufFree(&mb) == cBufSize - cFramesWrittenAbs);
    309316    RTTESTI_CHECK(AudioMixBufFreeBytes(&mb) == AUDIOMIXBUF_F2B(&mb, cBufSize - cFramesWrittenAbs));
    310317    RTTESTI_CHECK(AudioMixBufUsed(&mb) == cFramesWrittenAbs);
     318    RTTESTI_CHECK(AudioMixBufReadPos(&mb) == 0);
    311319
    312320    AudioMixBufDestroy(&mb);
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