VirtualBox

Changeset 88394 in vbox for trunk/src


Ignore:
Timestamp:
Apr 7, 2021 11:03:58 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143642
Message:

DrvAudioRec,DrvHostAudioValidationKit: doxygen fixes. some cleanups. bugref:9890

Location:
trunk/src/VBox
Files:
2 edited

Legend:

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

    r88390 r88394  
    3737    /** Audio file to dump output to or read input from. */
    3838    PPDMAUDIOFILE      pFile;
    39     /** Text file to store timing of audio buffers submittions**/
     39    /** Text file to store timing of audio buffers submittions. */
    4040    RTFILE             hFileTiming;
    41     /** Timestamp of the first play or record request**/
     41    /** Timestamp of the first play or record request. */
    4242    uint64_t           tsStarted;
    43     /** Total number of samples played or recorded so far**/
    44     uint32_t           uSamplesSinceStarted;
     43    /** Total number of frames played or recorded so far. */
     44    uint32_t           cFramesSinceStarted;
    4545    union
    4646    {
     
    122122
    123123    pStreamDbg->tsStarted = 0;
    124     pStreamDbg->uSamplesSinceStarted = 0;
     124    pStreamDbg->cFramesSinceStarted = 0;
    125125    pStreamDbg->Out.tsLastPlayed  = 0;
    126126    pStreamDbg->Out.cbPlayBuffer  = PDMAudioPropsFramesToBytes(&pCfgReq->Props, pCfgReq->Backend.cFramesBufferSize);
     
    197197 */
    198198static DECLCALLBACK(int) drvHostValKitAudioHA_StreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
    199                                                          const void *pvBuf, uint32_t uBufSize, uint32_t *puWritten)
    200 {
    201     PDRVHOSTVAKITAUDIO pDrv       = RT_FROM_MEMBER(pInterface, DRVHOSTVAKITAUDIO, IHostAudio);
     199                                                         const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten)
     200{
     201    PDRVHOSTVAKITAUDIO pThis      = RT_FROM_MEMBER(pInterface, DRVHOSTVAKITAUDIO, IHostAudio);
    202202    PVAKITAUDIOSTREAM  pStreamDbg = (PVAKITAUDIOSTREAM)pStream;
    203     RT_NOREF(pDrv);
    204 
    205     uint64_t tsSinceStart;
    206     size_t cch;
     203    RT_NOREF(pThis);
     204
     205    uint64_t cNsSinceStart;
     206    if (pStreamDbg->tsStarted != 0)
     207        cNsSinceStart = RTTimeNanoTS() - pStreamDbg->tsStarted;
     208    else
     209    {
     210        pStreamDbg->tsStarted = RTTimeNanoTS();
     211        cNsSinceStart = 0;
     212    }
     213
     214    // Microseconds are used everythere below
     215    uint32_t const cFrames = PDMAudioPropsBytesToFrames(&pStreamDbg->pCfg->Props, cbBuf);
    207216    char szTimingInfo[128];
    208 
    209     if (pStreamDbg->tsStarted == 0)
    210     {
    211         pStreamDbg->tsStarted = RTTimeNanoTS();
    212         tsSinceStart = 0;
    213     }
    214     else
    215     {
    216         tsSinceStart = RTTimeNanoTS() - pStreamDbg->tsStarted;
    217     }
    218 
    219     // Microseconds are used everythere below
    220     uint32_t sBuf = uBufSize >> pStreamDbg->pCfg->Props.cShift;
    221     cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "%d %d %d %d\n",
    222         (uint32_t)(tsSinceStart / 1000), // Host time elapsed since Guest submitted the first buffer for playback
    223         (uint32_t)(pStreamDbg->uSamplesSinceStarted * 1.0E6 / pStreamDbg->pCfg->Props.uHz), // how long all the samples submitted previously were played
    224         (uint32_t)(sBuf * 1.0E6 / pStreamDbg->pCfg->Props.uHz), // how long a new uSamplesReady samples should\will be played
    225         sBuf);
     217    size_t cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "%d %d %d %d\n",
     218                             // Host time elapsed since Guest submitted the first buffer for playback:
     219                             (uint32_t)(cNsSinceStart / 1000),
     220                             // how long all the samples submitted previously were played:
     221                             (uint32_t)(pStreamDbg->cFramesSinceStarted * 1.0E6 / pStreamDbg->pCfg->Props.uHz),
     222                             // how long a new uSamplesReady samples should/will be played:
     223                             (uint32_t)(cFrames * 1.0E6 / pStreamDbg->pCfg->Props.uHz),
     224                             cFrames);
    226225    RTFileWrite(pStreamDbg->hFileTiming, szTimingInfo, cch, NULL);
    227     pStreamDbg->uSamplesSinceStarted += sBuf;
     226    pStreamDbg->cFramesSinceStarted += cFrames;
    228227
    229228    /* Remember when samples were consumed. */
    230    // pStreamDbg->Out.tsLastPlayed = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);;
    231 
    232     int rc2 = AudioHlpFileWrite(pStreamDbg->pFile, pvBuf, uBufSize, 0 /* fFlags */);
     229   // pStreamDbg->Out.tsLastPlayed = PDMDrvHlpTMGetVirtualTime(pThis->pDrvIns);
     230
     231    int rc2 = AudioHlpFileWrite(pStreamDbg->pFile, pvBuf, cbBuf, 0 /* fFlags */);
    233232    if (RT_FAILURE(rc2))
    234233        LogRel(("VaKitAudio: Writing output failed with %Rrc\n", rc2));
    235234
    236     *puWritten = uBufSize;
     235    *pcbWritten = cbBuf;
    237236
    238237    return VINF_SUCCESS;
  • trunk/src/VBox/Main/src-client/DrvAudioRec.cpp

    r88390 r88394  
    653653 */
    654654static DECLCALLBACK(int) drvAudioVideoRecHA_StreamPlay(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
    655                                                        const void *pvBuf, uint32_t uBufSize, uint32_t *puWritten)
    656 {
    657     AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    658     AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    659     AssertPtrReturn(pvBuf,      VERR_INVALID_POINTER);
    660     AssertReturn(uBufSize,         VERR_INVALID_PARAMETER);
    661     /* puWritten is optional. */
    662 
    663     PDRVAUDIORECORDING pThis     = PDMIHOSTAUDIO_2_DRVAUDIORECORDING(pInterface);
     655                                                       const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten)
     656{
    664657    RT_NOREF(pThis);
    665     PAVRECSTREAM      pStreamAV = (PAVRECSTREAM)pStream;
     658    PAVRECSTREAM pStreamAV = (PAVRECSTREAM)pStream;
     659    AssertPtrReturn(pStreamAV, VERR_INVALID_POINTER);
     660    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
     661    AssertReturn(cbBuf, VERR_INVALID_PARAMETER);
     662    AssertReturn(pcbWritten, VERR_INVALID_PARAMETER);
    666663
    667664    int rc = VINF_SUCCESS;
     
    683680    size_t cbCircBuf;
    684681
    685     uint32_t cbToWrite = uBufSize;
     682    uint32_t cbToWrite = cbBuf;
    686683
    687684    /*
     
    821818    }
    822819
    823     if (puWritten)
    824         *puWritten = cbWrittenTotal;
     820    *pcbWritten = cbWrittenTotal;
    825821#else
    826822    /* Report back all data as being processed. */
    827     if (puWritten)
    828         *puWritten = uBufSize;
     823    *pcbWritten = cbBuf;
    829824
    830825    rc = VERR_NOT_SUPPORTED;
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