VirtualBox

Changeset 76992 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Jan 25, 2019 2:02:17 PM (6 years ago)
Author:
vboxsync
Message:

Audio/DrvHostDSound: Also clear / reset internal DirectSound buffers in dsoundStreamReset() and do so when enabling a stream via dsoundStreamEnable() to make sure no stale data is left.

File:
1 edited

Legend:

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

    r76991 r76992  
    10191019             pStreamDS->Cfg.enmDir == PDMAUDIODIR_IN ? "capture" : "playback"));
    10201020
     1021    if (fEnable)
     1022        dsoundStreamReset(pThis, pStreamDS);
     1023
    10211024    pStreamDS->fEnabled = fEnable;
    10221025
     
    10451048        pStreamDS->In.offReadPos = 0;
    10461049        pStreamDS->In.cOverruns  = 0;
     1050
     1051        /* Also reset the DirectSound Capture Buffer (DSCB) by clearing all data to make sure
     1052         * not stale audio data is left. */
     1053        if (pStreamDS->In.pDSCB)
     1054        {
     1055            PVOID pv1; PVOID pv2; DWORD cb1; DWORD cb2;
     1056            HRESULT hr = directSoundCaptureLock(pStreamDS, 0 /* Offset */, pStreamDS->cbBufSize, &pv1, &pv2, &cb1, &cb2,
     1057                                                0 /* Flags */);
     1058            if (SUCCEEDED(hr))
     1059            {
     1060                DrvAudioHlpClearBuf(&pStreamDS->Cfg.Props, pv1, cb1, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb1));
     1061                if (pv2 && cb2)
     1062                    DrvAudioHlpClearBuf(&pStreamDS->Cfg.Props, pv2, cb2, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb2));
     1063                directSoundCaptureUnlock(pStreamDS->In.pDSCB, pv1, pv2, cb1, cb2);
     1064            }
     1065        }
    10471066    }
    10481067    else if (pStreamDS->Cfg.enmDir == PDMAUDIODIR_OUT)
     
    10611080        pStreamDS->Out.offPlayCursorLastPending = 0;
    10621081        pStreamDS->Out.offPlayCursorLastPlayed = 0;
     1082
     1083        /* Also reset the DirectSound Buffer (DSB) by setting the position to 0 and clear all data to make sure
     1084         * not stale audio data is left. */
     1085        if (pStreamDS->Out.pDSB)
     1086        {
     1087            HRESULT hr = IDirectSoundBuffer8_SetCurrentPosition(pStreamDS->Out.pDSB, 0);
     1088            if (SUCCEEDED(hr))
     1089            {
     1090                PVOID pv1; PVOID pv2; DWORD cb1; DWORD cb2;
     1091                hr = directSoundPlayLock(pThis, pStreamDS, 0 /* Offset */, pStreamDS->cbBufSize, &pv1, &pv2, &cb1, &cb2,
     1092                                         0 /* Flags */);
     1093                if (SUCCEEDED(hr))
     1094                {
     1095                    DrvAudioHlpClearBuf(&pStreamDS->Cfg.Props, pv1, cb1, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb1));
     1096                    if (pv2 && cb2)
     1097                        DrvAudioHlpClearBuf(&pStreamDS->Cfg.Props, pv2, cb2, PDMAUDIOPCMPROPS_B2F(&pStreamDS->Cfg.Props, cb2));
     1098                    directSoundPlayUnlock(pThis, pStreamDS->Out.pDSB, pv1, pv2, cb1, cb2);
     1099                }
     1100            }
     1101        }
    10631102    }
    10641103
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