VirtualBox

Changeset 55650 in vbox for trunk/src


Ignore:
Timestamp:
May 4, 2015 2:49:21 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
100025
Message:

DrvAudioVRDE: consume samples at configured rate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r55269 r55650  
    216216    AssertPtrReturn(pVRDEStrmOut, VERR_INVALID_POINTER);
    217217
    218     /*
    219      * Just call the VRDP server with the data.
    220      */
    221218    uint32_t live = drvAudioHstOutSamplesLive(pHstStrmOut, NULL /* pcStreamsLive */);
    222219    uint64_t now = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);
     
    224221    uint64_t ticks_per_second = PDMDrvHlpTMGetVirtualFreq(pDrv->pDrvIns);
    225222
     223    /* Minimize the rounding error: samples = int((ticks * freq) / ticks_per_second + 0.5). */
    226224    uint32_t cSamplesPlayed = (int)((2 * ticks * pHstStrmOut->Props.uHz + ticks_per_second) / ticks_per_second / 2);
    227     if (!cSamplesPlayed)
     225
     226    /* Don't play more than available. */
     227    if (cSamplesPlayed > live)
    228228        cSamplesPlayed = live;
     229
     230    /* Remember when samples were consumed. */
     231    pVRDEStrmOut->old_ticks = now;
    229232
    230233    VRDEAUDIOFORMAT format = VRDE_AUDIO_FMT_MAKE(pHstStrmOut->Props.uHz,
     
    233236                                                 pHstStrmOut->Props.fSigned);
    234237
    235     pVRDEStrmOut->old_ticks = now;
    236 
    237     int cSamplesToSend = live;
    238 
    239 /*  if (!cSamplesToSend)
    240     {
    241         if (pcSamplesPlayed)
    242             pcSamplesPlayed = 0;
    243 
    244         return 0;
    245     }*/
     238    int cSamplesToSend = cSamplesPlayed;
    246239
    247240    LogFlowFunc(("uFreq=%RU32, cChan=%RU8, cBits=%RU8, fSigned=%RTbool, enmFormat=%ld, cSamplesToSend=%RU32\n",
     
    250243                 format, cSamplesToSend));
    251244
     245    /*
     246     * Call the VRDP server with the data.
     247     */
    252248    uint32_t cReadTotal = 0;
    253249
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette