VirtualBox

Changeset 70840 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jan 31, 2018 4:06:48 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120652
Message:

Audio/DrvHostDSound.cpp: Renamed dsoundPlayClearSamples() -> dsoundPlayClearBuffer() and do all clearing in on go (no need to fragment writes). Also, make sure to re-fetch positions after clearing.

File:
1 edited

Legend:

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

    r70839 r70840  
    803803
    804804
    805 static void dsoundPlayClearSamples(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS)
     805static void dsoundPlayClearBuffer(PDRVHOSTDSOUND pThis, PDSOUNDSTREAM pStreamDS)
    806806{
    807807    AssertPtrReturnVoid(pStreamDS);
     
    810810    PPDMAUDIOPCMPROPS pProps = &pStreamDS->pCfg->Props;
    811811
    812     PVOID pv1, pv2;
    813     DWORD cb1, cb2;
    814     HRESULT hr = directSoundPlayLock(pThis, pStreamDS,
    815                                      0 /* dwOffset */, pStreamDS->Out.cbBufSize,
    816                                      &pv1, &pv2, &cb1, &cb2, DSBLOCK_ENTIREBUFFER);
     812    HRESULT hr = IDirectSoundBuffer_SetCurrentPosition(pStreamDS->Out.pDSB, 0 /* Position */);
     813    if (FAILED(hr))
     814        DSLOGREL(("DSound: Setting current position to 0 when clearing buffer failed with %Rhrc\n", hr));
     815
     816    PVOID pv1;
     817    hr = directSoundPlayLock(pThis, pStreamDS,
     818                             0 /* dwOffset */, pStreamDS->Out.cbBufSize,
     819                             &pv1, NULL, 0, 0, DSBLOCK_ENTIREBUFFER);
    817820    if (SUCCEEDED(hr))
    818821    {
    819         DWORD len1 = PDMAUDIOPCMPROPS_B2F(pProps, cb1);
    820         DWORD len2 = PDMAUDIOPCMPROPS_B2F(pProps, cb2);
    821 
    822         if (pv1 && len1)
    823             DrvAudioHlpClearBuf(pProps, pv1, cb1, len1);
    824 
    825         if (pv2 && len2)
    826             DrvAudioHlpClearBuf(pProps, pv2, cb2, len2);
    827 
    828         directSoundPlayUnlock(pThis, pStreamDS->Out.pDSB, pv1, pv2, cb1, cb2);
     822        DrvAudioHlpClearBuf(pProps, pv1, pStreamDS->Out.cbBufSize, PDMAUDIOPCMPROPS_B2F(pProps, pStreamDS->Out.cbBufSize));
     823
     824        directSoundPlayUnlock(pThis, pStreamDS->Out.pDSB, pv1, NULL, 0, 0);
     825
     826        /* Make sure to get the last playback position and current write position from DirectSound again.
     827         * Those positions in theory could have changed, re-fetch them to be sure. */
     828        hr = IDirectSoundBuffer_GetCurrentPosition(pStreamDS->Out.pDSB,
     829                                                   &pStreamDS->Out.offPlayCursorLastPlayed, &pStreamDS->Out.offWritePos);
     830        if (FAILED(hr))
     831            DSLOGREL(("DSound: Re-fetching current position when clearing buffer failed with %Rhrc\n", hr));
    829832    }
    830833}
     
    917920            else
    918921            {
    919                 dsoundPlayClearSamples(pThis, pStreamDS);
     922                dsoundPlayClearBuffer(pThis, pStreamDS);
    920923
    921924                pStreamDS->Out.fRestartPlayback = true;
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