VirtualBox

Changeset 73408 in vbox


Ignore:
Timestamp:
Jul 31, 2018 11:32:55 AM (6 years ago)
Author:
vboxsync
Message:

Audio: Renamed *Ms* (milliseconds) timing helper functions to *Milli*.

Location:
trunk/src/VBox
Files:
9 edited

Legend:

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

    r73404 r73408  
    657657    if (RT_SUCCESS(rc))
    658658    {
    659         rc = RTCircBufCreate(&pMixStream->pCircBuf, DrvAudioHlpMsToBytes(100 /* ms */, &pSink->PCMProps)); /** @todo Make this configurable. */
     659        rc = RTCircBufCreate(&pMixStream->pCircBuf, DrvAudioHlpMilliToBytes(100 /* ms */, &pSink->PCMProps)); /** @todo Make this configurable. */
    660660        AssertRC(rc);
    661661    }
     
    931931#else
    932932        /* Return how much data we expect since the last write. */
    933         cbWritable = DrvAudioHlpMsToBytes(RTTimeMilliTS() - pSink->tsLastReadWrittenMs, &pSink->PCMProps);
     933        cbWritable = DrvAudioHlpMilliToBytes(RTTimeMilliTS() - pSink->tsLastReadWrittenMs, &pSink->PCMProps);
    934934#endif
    935935    }
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r73405 r73408  
    667667
    668668    /* If no own pre-buffer is set, let the backend choose. */
    669     uint32_t msPreBuf = DrvAudioHlpFramesToMs(CfgHostAcq.Backend.cfPreBuf, &pCfgHost->Props);
     669    uint32_t msPreBuf = DrvAudioHlpFramesToMilli(CfgHostAcq.Backend.cfPreBuf, &pCfgHost->Props);
    670670    LogRel2(("Audio: Pre-buffering size of stream '%s' is %RU32ms (%RU32 frames)\n",
    671671             pHstStream->szName, msPreBuf, CfgHostAcq.Backend.cfPreBuf));
    672672
    673673    /* Make sure the configured buffer size by the backend at least can hold the configured latency. */
    674     const uint32_t msPeriod = DrvAudioHlpFramesToMs(CfgHostAcq.Backend.cfPeriod, &pCfgHost->Props);
     674    const uint32_t msPeriod = DrvAudioHlpFramesToMilli(CfgHostAcq.Backend.cfPeriod, &pCfgHost->Props);
    675675
    676676    LogRel2(("Audio: Period size of stream '%s' is %RU32ms (%RU32 frames)\n",
     
    685685    }
    686686
    687     uint32_t msBufferSize = DrvAudioHlpFramesToMs(CfgHostAcq.Backend.cfBufferSize, &pCfgHost->Props);
     687    uint32_t msBufferSize = DrvAudioHlpFramesToMilli(CfgHostAcq.Backend.cfBufferSize, &pCfgHost->Props);
    688688
    689689    LogRel2(("Audio: Buffer size of stream '%s' is %RU32ms (%RU32 frames)\n",
     
    10441044            {
    10451045                Log3Func(("[%s] Buffer: Last written %RU64ms, writing %RU32 frames (%RU64ms), now filled with %RU64ms -- %RU8%%\n",
    1046                           pHstStream->szName, tsDeltaWrittenMs, cfGstWritten, DrvAudioHlpFramesToMs(cfGstWritten, &pHstStream->Cfg.Props),
    1047                           DrvAudioHlpFramesToMs(AudioMixBufUsed(&pHstStream->MixBuf), &pHstStream->Cfg.Props),
     1046                          pHstStream->szName, tsDeltaWrittenMs, cfGstWritten, DrvAudioHlpFramesToMilli(cfGstWritten, &pHstStream->Cfg.Props),
     1047                          DrvAudioHlpFramesToMilli(AudioMixBufUsed(&pHstStream->MixBuf), &pHstStream->Cfg.Props),
    10481048                          AudioMixBufUsed(&pHstStream->MixBuf) * 100 / AudioMixBufSize(&pHstStream->MixBuf)));
    10491049
     
    15991599        Log3Func(("[%s] Buffer: Last played %RU64ms, filled with %RU64ms (%RU8%%) total, "
    16001600                  "(cfLive=%RU32, fThresholdReached=%RTbool)\n",
    1601                   pHstStream->szName, tsDeltaPlayedCapturedMs, DrvAudioHlpFramesToMs(cfLive, &pHstStream->Cfg.Props),
     1601                  pHstStream->szName, tsDeltaPlayedCapturedMs, DrvAudioHlpFramesToMilli(cfLive, &pHstStream->Cfg.Props),
    16021602                  uLivePercent, cfLive, pHstStream->fThresholdReached));
    16031603#endif
     
    16451645                cfToPlay = pHstStream->Cfg.Backend.cfPeriod;
    16461646            else
    1647                 cfToPlay = DrvAudioHlpMsToFrames(tsDeltaPlayedCapturedMs, &pHstStream->Cfg.Props);
     1647                cfToPlay = DrvAudioHlpMilliToFrames(tsDeltaPlayedCapturedMs, &pHstStream->Cfg.Props);
    16481648
    16491649            Log3Func(("[%s] Buffer: fJustStarted=%RTbool, cfLive=%RU32, cfToPlay=%RU32\n",
     
    32543254     */
    32553255    if (pDrvCfg->uPeriodMs)
    3256         pCfgReq->Backend.cfPeriod = DrvAudioHlpMsToFrames(pDrvCfg->uPeriodMs, &pCfgReq->Props);
     3256        pCfgReq->Backend.cfPeriod = DrvAudioHlpMilliToFrames(pDrvCfg->uPeriodMs, &pCfgReq->Props);
    32573257    else /* Set default period size. */
    3258         pCfgReq->Backend.cfPeriod = DrvAudioHlpMsToFrames(50 /* ms */, &pCfgReq->Props);
     3258        pCfgReq->Backend.cfPeriod = DrvAudioHlpMilliToFrames(50 /* ms */, &pCfgReq->Props);
    32593259
    32603260    LogRel2(("Audio: Using %s period size (%RU32ms, %RU32 frames) for stream '%s'\n",
    3261              pDrvCfg->uPeriodMs ? "custom" : "default", DrvAudioHlpFramesToMs(pCfgReq->Backend.cfPeriod, &pCfgReq->Props),
     3261             pDrvCfg->uPeriodMs ? "custom" : "default", DrvAudioHlpFramesToMilli(pCfgReq->Backend.cfPeriod, &pCfgReq->Props),
    32623262             pCfgReq->Backend.cfPeriod, pHstStream->szName));
    32633263
     
    32663266     */
    32673267    if (pDrvCfg->uBufferSizeMs)
    3268         pCfgReq->Backend.cfBufferSize = DrvAudioHlpMsToFrames(pDrvCfg->uBufferSizeMs, &pCfgReq->Props);
     3268        pCfgReq->Backend.cfBufferSize = DrvAudioHlpMilliToFrames(pDrvCfg->uBufferSizeMs, &pCfgReq->Props);
    32693269    else /* Set default buffer size. */
    3270         pCfgReq->Backend.cfBufferSize = DrvAudioHlpMsToFrames(200 /* ms */, &pCfgReq->Props);
     3270        pCfgReq->Backend.cfBufferSize = DrvAudioHlpMilliToFrames(200 /* ms */, &pCfgReq->Props);
    32713271
    32723272    LogRel2(("Audio: Using %s buffer size (%RU32ms, %RU32 frames) for stream '%s'\n",
    3273              pDrvCfg->uBufferSizeMs ? "custom" : "default", DrvAudioHlpFramesToMs(pCfgReq->Backend.cfBufferSize, &pCfgReq->Props),
     3273             pDrvCfg->uBufferSizeMs ? "custom" : "default", DrvAudioHlpFramesToMilli(pCfgReq->Backend.cfBufferSize, &pCfgReq->Props),
    32743274             pCfgReq->Backend.cfBufferSize, pHstStream->szName));
    32753275
     
    32813281        if (!pDrvCfg->uPreBufMs) /* Pre-buffering is set to disabled. */
    32823282            LogRel2(("Audio: Using custom pre-buffering (disabled) for stream '%s'\n", pHstStream->szName));
    3283         pCfgReq->Backend.cfPreBuf = DrvAudioHlpMsToFrames(pDrvCfg->uPreBufMs, &pCfgReq->Props);
     3283        pCfgReq->Backend.cfPreBuf = DrvAudioHlpMilliToFrames(pDrvCfg->uPreBufMs, &pCfgReq->Props);
    32843284    }
    32853285    else /* Set default pre-buffering size. */
     
    32873287
    32883288    LogRel2(("Audio: Using %s pre-buffering size (%RU32ms, %RU32 frames) for stream '%s'\n",
    3289              pDrvCfg->uPreBufMs != UINT32_MAX ? "custom" : "default", DrvAudioHlpFramesToMs(pCfgReq->Backend.cfPreBuf, &pCfgReq->Props),
     3289             pDrvCfg->uPreBufMs != UINT32_MAX ? "custom" : "default", DrvAudioHlpFramesToMilli(pCfgReq->Backend.cfPreBuf, &pCfgReq->Props),
    32903290             pCfgReq->Backend.cfPreBuf, pHstStream->szName));
    32913291
     
    32963296    {
    32973297        LogRel(("Audio: Error for stream '%s': Buffer size (%RU32ms) must not be smaller than the period size (%RU32ms)\n",
    3298                 pHstStream->szName, DrvAudioHlpFramesToMs(pCfgReq->Backend.cfBufferSize, &pCfgReq->Props),
    3299                 DrvAudioHlpFramesToMs(pCfgReq->Backend.cfPeriod, &pCfgReq->Props)));
     3298                pHstStream->szName, DrvAudioHlpFramesToMilli(pCfgReq->Backend.cfBufferSize, &pCfgReq->Props),
     3299                DrvAudioHlpFramesToMilli(pCfgReq->Backend.cfPeriod, &pCfgReq->Props)));
    33003300        return VERR_INVALID_PARAMETER;
    33013301    }
     
    33073307        {
    33083308            LogRel(("Audio: Error for stream '%s': Pre-buffering size (%RU32ms) must not be bigger than the buffer size (%RU32ms)\n",
    3309                     pHstStream->szName, DrvAudioHlpFramesToMs(pCfgReq->Backend.cfPreBuf, &pCfgReq->Props),
    3310                     DrvAudioHlpFramesToMs(pCfgReq->Backend.cfBufferSize, &pCfgReq->Props)));
     3309                    pHstStream->szName, DrvAudioHlpFramesToMilli(pCfgReq->Backend.cfPreBuf, &pCfgReq->Props),
     3310                    DrvAudioHlpFramesToMilli(pCfgReq->Backend.cfBufferSize, &pCfgReq->Props)));
    33113311            return VERR_INVALID_PARAMETER;
    33123312        }
     
    33463346    {
    33473347        LogRel2(("Audio: Custom buffer size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n",
    3348                  pHstStream->szName, DrvAudioHlpFramesToMs(pCfgAcq->Backend.cfBufferSize, &pCfgAcq->Props), pCfgAcq->Backend.cfBufferSize));
     3348                 pHstStream->szName, DrvAudioHlpFramesToMilli(pCfgAcq->Backend.cfBufferSize, &pCfgAcq->Props), pCfgAcq->Backend.cfBufferSize));
    33493349    }
    33503350
     
    33533353    {
    33543354        LogRel2(("Audio: Custom period size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n",
    3355                  pHstStream->szName, DrvAudioHlpFramesToMs(pCfgAcq->Backend.cfPeriod, &pCfgAcq->Props), pCfgAcq->Backend.cfPeriod));
     3355                 pHstStream->szName, DrvAudioHlpFramesToMilli(pCfgAcq->Backend.cfPeriod, &pCfgAcq->Props), pCfgAcq->Backend.cfPeriod));
    33563356    }
    33573357
     
    33603360    {
    33613361        LogRel2(("Audio: Custom pre-buffering size overwritten by backend for stream '%s' (now %RU64ms, %RU32 frames)\n",
    3362                  pHstStream->szName, DrvAudioHlpFramesToMs(pCfgAcq->Backend.cfPreBuf, &pCfgAcq->Props), pCfgAcq->Backend.cfPreBuf));
     3362                 pHstStream->szName, DrvAudioHlpFramesToMilli(pCfgAcq->Backend.cfPreBuf, &pCfgAcq->Props), pCfgAcq->Backend.cfPreBuf));
    33633363    }
    33643364
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r73407 r73408  
    187187bool     DrvAudioHlpBytesIsAligned(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps);
    188188uint32_t DrvAudioHlpBytesToFrames(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);
    189 uint64_t DrvAudioHlpBytesToMs(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);
     189uint64_t DrvAudioHlpBytesToMilli(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);
    190190uint64_t DrvAudioHlpBytesToNano(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);
    191191uint32_t DrvAudioHlpFramesToBytes(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);
    192 uint64_t DrvAudioHlpFramesToMs(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);
     192uint64_t DrvAudioHlpFramesToMilli(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);
    193193uint64_t DrvAudioHlpFramesToNano(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps);
    194 uint32_t DrvAudioHlpMsToBytes(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps);
     194uint32_t DrvAudioHlpMilliToBytes(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps);
    195195uint32_t DrvAudioHlpNanoToBytes(uint32_t uNs, const PPDMAUDIOPCMPROPS pProps);
    196 uint32_t DrvAudioHlpMsToFrames(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps);
     196uint32_t DrvAudioHlpMilliToFrames(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps);
    197197uint32_t DrvAudioHlpNanoToFrames(uint32_t uNs, const PPDMAUDIOPCMPROPS pProps);
    198198/** @}  */
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r73407 r73408  
    11201120 * @param   pProps              PCM properties to calculate amount of bytes for.
    11211121 */
    1122 uint64_t DrvAudioHlpBytesToMs(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps)
     1122uint64_t DrvAudioHlpBytesToMilli(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps)
    11231123{
    11241124    AssertPtrReturn(pProps, 0);
     
    11811181 * @param   pProps              PCM properties to calculate time (in ms) for.
    11821182 */
    1183 uint64_t DrvAudioHlpFramesToMs(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps)
     1183uint64_t DrvAudioHlpFramesToMilli(uint32_t cFrames, const PPDMAUDIOPCMPROPS pProps)
    11841184{
    11851185    AssertPtrReturn(pProps, 0);
     
    12211221 * @param   pProps              PCM properties to calculate amount of bytes for.
    12221222 */
    1223 uint32_t DrvAudioHlpMsToBytes(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps)
     1223uint32_t DrvAudioHlpMilliToBytes(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps)
    12241224{
    12251225    AssertPtrReturn(pProps, 0);
     
    12551255 * @param   pProps              PCM properties to calculate amount of frames for.
    12561256 */
    1257 uint32_t DrvAudioHlpMsToFrames(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps)
     1257uint32_t DrvAudioHlpMilliToFrames(uint32_t uMs, const PPDMAUDIOPCMPROPS pProps)
    12581258{
    12591259    AssertPtrReturn(pProps, 0);
     
    12631263        return 0;
    12641264
    1265     return DrvAudioHlpMsToBytes(uMs, pProps) / cbFrame;
     1265    return DrvAudioHlpMilliToBytes(uMs, pProps) / cbFrame;
    12661266}
    12671267
  • trunk/src/VBox/Devices/Audio/DrvHostALSAAudio.cpp

    r73380 r73408  
    12901290        req.freq        = pCfgReq->Props.uHz;
    12911291        req.nchannels   = pCfgReq->Props.cChannels;
    1292         req.period_size = DrvAudioHlpMsToFrames(50 /* ms */, &pCfgReq->Props); /** @todo Make this configurable. */
     1292        req.period_size = DrvAudioHlpMilliToFrames(50 /* ms */, &pCfgReq->Props); /** @todo Make this configurable. */
    12931293        req.buffer_size = req.period_size * 2; /** @todo Make this configurable. */
    12941294        req.threshold   = req.period_size;
  • trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp

    r73392 r73408  
    677677
    678678        DSLOG(("DSound: Requested playback buffer is %RU64ms (%ld bytes)\n",
    679                pCfgReq->Backend.cfBufferSize, DrvAudioHlpBytesToMs(bd.dwBufferBytes, &pCfgReq->Props), bd.dwBufferBytes));
     679               pCfgReq->Backend.cfBufferSize, DrvAudioHlpBytesToMilli(bd.dwBufferBytes, &pCfgReq->Props), bd.dwBufferBytes));
    680680
    681681        hr = IDirectSound8_CreateSoundBuffer(pThis->pDS, &bd, &pDSB, NULL);
     
    719719
    720720        DSLOG(("DSound: Acquired playback buffer is %RU64ms (%ld bytes)\n",
    721                DrvAudioHlpBytesToMs(bc.dwBufferBytes, &pCfgReq->Props), bc.dwBufferBytes));
     721               DrvAudioHlpBytesToMilli(bc.dwBufferBytes, &pCfgReq->Props), bc.dwBufferBytes));
    722722
    723723        DSLOG(("DSound: Acquired playback format:\n"
     
    13611361
    13621362        DSLOG(("DSound: Requested capture buffer is %RU64ms (%ld bytes)\n",
    1363                pCfgReq->Backend.cfBufferSize, DrvAudioHlpBytesToMs(bd.dwBufferBytes, &pCfgReq->Props), bd.dwBufferBytes));
     1363               pCfgReq->Backend.cfBufferSize, DrvAudioHlpBytesToMilli(bd.dwBufferBytes, &pCfgReq->Props), bd.dwBufferBytes));
    13641364
    13651365        LPDIRECTSOUNDCAPTUREBUFFER pDSCB;
     
    14141414
    14151415        DSLOG(("DSound: Acquired capture buffer is %RU64ms (%ld bytes)\n",
    1416                DrvAudioHlpBytesToMs(bc.dwBufferBytes, &pCfgReq->Props), bc.dwBufferBytes));
     1416               DrvAudioHlpBytesToMilli(bc.dwBufferBytes, &pCfgReq->Props), bc.dwBufferBytes));
    14171417
    14181418        DSLOG(("DSound: Capture format:\n"
     
    22972297        {
    22982298            const uint64_t diffLastTransferredMs  = RTTimeMilliTS() - pStreamDS->Out.tsLastTransferred;
    2299             const uint64_t uLastTranserredChunkMs = DrvAudioHlpBytesToMs(pStreamDS->Out.cbLastTransferred, &pStreamDS->Cfg.Props);
     2299            const uint64_t uLastTranserredChunkMs = DrvAudioHlpBytesToMilli(pStreamDS->Out.cbLastTransferred, &pStreamDS->Cfg.Props);
    23002300            if (   uLastTranserredChunkMs
    23012301                && diffLastTransferredMs < uLastTranserredChunkMs)
  • trunk/src/VBox/Devices/Audio/HDAStream.cpp

    r73381 r73408  
    207207
    208208    /* By default we allocate an internal buffer of 100ms. */
    209     rc = RTCircBufCreate(&pStream->State.pCircBuf, DrvAudioHlpMsToBytes(100 /* ms */, &pCfg->Props)); /** @todo Make this configurable. */
     209    rc = RTCircBufCreate(&pStream->State.pCircBuf, DrvAudioHlpMilliToBytes(100 /* ms */, &pCfg->Props)); /** @todo Make this configurable. */
    210210    AssertRCReturn(rc, rc);
    211211
  • trunk/src/VBox/Main/src-client/DrvAudioVRDE.cpp

    r73380 r73408  
    9191
    9292    /* According to the VRDP docs, the VRDP server stores audio in 200ms chunks. */
    93     const uint32_t cfVRDPServer = DrvAudioHlpMsToFrames(200  /* ms */, &pCfgAcq->Props);
     93    const uint32_t cfVRDPServer = DrvAudioHlpMilliToFrames(200  /* ms */, &pCfgAcq->Props);
    9494
    9595    int rc = RTCircBufCreate(&pStreamVRDE->In.pCircBuf, DrvAudioHlpFramesToBytes(cfVRDPServer, &pCfgAcq->Props));
     
    136136
    137137        /* According to the VRDP docs, the VRDP server stores audio in 200ms chunks. */
    138         pCfgAcq->Backend.cfPeriod     = DrvAudioHlpMsToFrames(10  /* ms */, &pCfgAcq->Props);
    139         pCfgAcq->Backend.cfBufferSize = DrvAudioHlpMsToFrames(200  /* ms */, &pCfgAcq->Props);
     138        pCfgAcq->Backend.cfPeriod     = DrvAudioHlpMilliToFrames(10  /* ms */, &pCfgAcq->Props);
     139        pCfgAcq->Backend.cfBufferSize = DrvAudioHlpMilliToFrames(200  /* ms */, &pCfgAcq->Props);
    140140        pCfgAcq->Backend.cfPreBuf     = pCfgAcq->Backend.cfBufferSize;
    141141    }
     
    170170        {
    171171            rc = pDrv->pConsoleVRDPServer->SendAudioInputBegin(NULL, pStreamVRDE,
    172                                                                DrvAudioHlpMsToFrames(200 /* ms */, &pStreamVRDE->pCfg->Props),
     172                                                               DrvAudioHlpMilliToFrames(200 /* ms */, &pStreamVRDE->pCfg->Props),
    173173                                                               pStreamVRDE->pCfg->Props.uHz, pStreamVRDE->pCfg->Props.cChannels,
    174174                                                               pStreamVRDE->pCfg->Props.cBits);
  • trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp

    r73380 r73408  
    524524
    525525            /* Every Opus frame marks a period for now. Optimize this later. */
    526             pCfgAcq->Backend.cfPeriod  = DrvAudioHlpMsToFrames(pSink->Codec.Opus.msFrame, &pCfgAcq->Props); /** @todo Make this configurable. */
     526            pCfgAcq->Backend.cfPeriod  = DrvAudioHlpMilliToFrames(pSink->Codec.Opus.msFrame, &pCfgAcq->Props); /** @todo Make this configurable. */
    527527        }
    528528    }
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