VirtualBox

Changeset 73550 in vbox for trunk/src


Ignore:
Timestamp:
Aug 7, 2018 3:34:47 PM (6 years ago)
Author:
vboxsync
Message:

Audio/DrvHostDSound.cpp: Added a flag to indicate that an output stream is in "draining mode" and only transfer audio output data if we at least have data for a whole period (and not before).

File:
1 edited

Legend:

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

    r73547 r73550  
    154154            /** Flag indicating whether playback was just (re)started. */
    155155            bool                        fFirstTransfer;
     156            /** Flag indicating whether this stream is in draining mode, e.g. no new
     157             *  data is being written to it but DirectSound still needs to be able to
     158             *  play its remaining (buffered) data. */
     159            bool                        fDrain;
    156160            /** How much (in bytes) the last transfer from the internal buffer
    157161             *  to the DirectSound buffer was. */
     
    851855    if (!pStreamDS->Dbg.tsLastTransferredMs)
    852856        pStreamDS->Dbg.tsLastTransferredMs = RTTimeMilliTS();
    853     Log3Func(("tsLastTransferredMs=%RU64ms, cbAvail=%RU32, cbFree=%RU32 -> cbToTransfer=%RU32\n",
    854               RTTimeMilliTS() - pStreamDS->Dbg.tsLastTransferredMs, cbAvail, cbFree, cbToTransfer));
     857    Log3Func(("tsLastTransferredMs=%RU64ms, cbAvail=%RU32, cbFree=%RU32 -> cbToTransfer=%RU32 (fDrain=%RTbool)\n",
     858              RTTimeMilliTS() - pStreamDS->Dbg.tsLastTransferredMs, cbAvail, cbFree, cbToTransfer, pStreamDS->Out.fDrain));
    855859    pStreamDS->Dbg.tsLastTransferredMs = RTTimeMilliTS();
    856860#endif
    857861
    858 #if 0
    859     if (cbToTransfer > cbAvail) /* Paranoia. */
    860         cbToTransfer = cbAvail;
    861 
    862     if (cbToTransfer > cbFree)
    863         cbToTransfer = cbFree;
    864 #endif
     862    /* Only transfer anything if we have enough data for a DirectSound stream's period *and* are not
     863     * in draining mode (already). */
     864    if (   !pStreamDS->Out.fDrain
     865        && cbToTransfer < DrvAudioHlpFramesToBytes(pStreamDS->Cfg.Backend.cfPeriod, &pStreamDS->Cfg.Props))
     866        return VINF_SUCCESS;
    865867
    866868    while (cbToTransfer)
     
    17601762    pStreamDS->Out.cbTransferred = 0;
    17611763    pStreamDS->Out.fFirstTransfer = true;
     1764    pStreamDS->Out.fDrain = false;
    17621765    pStreamDS->Out.cbLastTransferred = 0;
    17631766    pStreamDS->Out.tsLastTransferred = 0;
     
    18111814        {
    18121815            /* Make sure we transferred everything. */
     1816            pStreamDS->Out.fDrain = true;
    18131817            rc = dsoundPlayTransfer(pThis);
    18141818            if (   RT_SUCCESS(rc)
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