VirtualBox

Ignore:
Timestamp:
Feb 3, 2017 7:00:44 PM (8 years ago)
Author:
vboxsync
Message:

Audio/ValKit: Saving buffer submittions timings for each .wav file, bugref:7673

File:
1 edited

Legend:

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

    r65565 r65606  
    3737    /** Audio file to dump output to or read input from. */
    3838    PDMAUDIOFILE       File;
     39    /** Text file to store timing of audio buffers submittions**/
     40    RTFILE             hFileTiming;
     41    /** Timestamp of the first play or record request**/
     42    uint64_t           tsStarted;
     43    /** Total number of samples played or recorded so far**/
     44    uint32_t           uSamplesSinceStarted;
    3945    union
    4046    {
     
    152158    if (RT_SUCCESS(rc))
    153159    {
     160        pDbgStream->tsStarted                   = 0;
     161        pDbgStream->uSamplesSinceStarted        = 0;
    154162        pDbgStream->Out.tsLastPlayed            = 0;
    155         pDbgStream->Out.cMaxSamplesInPlayBuffer = _1K;
     163        pDbgStream->Out.cMaxSamplesInPlayBuffer = 16 * _1K;
    156164        pDbgStream->Out.pu8PlayBuffer           = (uint8_t *)RTMemAlloc(pDbgStream->Out.cMaxSamplesInPlayBuffer << Props.cShift);
    157165        if (!pDbgStream->Out.pu8PlayBuffer)
     
    163171        char szTemp[RTPATH_MAX];
    164172        rc = RTPathTemp(szTemp, sizeof(szTemp));
     173
     174        RTPathAppend(szTemp, sizeof(szTemp), "VBoxAudioValKit");
     175
    165176        if (RT_SUCCESS(rc))
    166177        {
     
    175186                if (RT_FAILURE(rc))
    176187                    LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
     188
     189                RTStrCat(szFile, sizeof(szFile), ".timing");
     190                rc = RTFileOpen(&pDbgStream->hFileTiming, szFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE);
     191               
     192
     193                if (RT_FAILURE(rc))
     194                    LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
    177195            }
    178196            else
     
    245263        cSamplesPlayed = cLive;*/
    246264
     265    uint64_t tsSinceStart;
     266    size_t cch;
     267    char szTimingInfo[128];
     268
     269    if (pDbgStream->tsStarted == 0)
     270    {
     271        pDbgStream->tsStarted = RTTimeNanoTS();
     272        tsSinceStart = 0;
     273    }
     274    else
     275    {
     276        tsSinceStart = RTTimeNanoTS() - pDbgStream->tsStarted;
     277    }
     278
     279    uint32_t uSamplesReady = AudioMixBufUsed(&pStream->MixBuf);
     280    cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "%d %d %d %d\n",
     281        // Host time (in mcs) elapsed since Guest submitted the first buffer for playback
     282        (uint32_t)(tsSinceStart / 1000),
     283        // how long (in mcs) all the samples submitted previously were played
     284        (uint32_t)(pDbgStream->uSamplesSinceStarted * 1.0E6 / pStream->Cfg.uHz),
     285        // how long (in mcs) a new uSamplesReady samples should\will be played
     286        (uint32_t)(uSamplesReady * 1.0E6 / pStream->Cfg.uHz),
     287        uSamplesReady);
     288    RTFileWrite(pDbgStream->hFileTiming, szTimingInfo, cch, NULL);
     289    pDbgStream->uSamplesSinceStarted += uSamplesReady;
     290
    247291    uint32_t cSamplesPlayed = 0;
    248292    uint32_t cSamplesAvail  = RT_MIN(AudioMixBufUsed(&pStream->MixBuf), pDbgStream->Out.cMaxSamplesInPlayBuffer);
     293
    249294    while (cSamplesAvail)
    250295    {
     
    327372
    328373    int rc = DrvAudioHlpWAVFileClose(&pDbgStream->File);
     374
     375    RTFileClose(pDbgStream->hFileTiming);
     376
    329377    if (RT_SUCCESS(rc))
    330378    {
     
    335383            && fDeleteEmptyFiles)
    336384        {
    337             rc = RTFileDelete(pDbgStream->File.szName);
     385            char szFile[RTPATH_MAX];
     386
     387            RTStrCopy(szFile, sizeof(szFile), pDbgStream->File.szName);
     388            rc = RTFileDelete(szFile);
     389
     390            RTStrCat(szFile, sizeof(szFile), ".timing");
     391            rc = RTFileDelete(szFile);
    338392        }
    339393        else
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