Changeset 65606 in vbox for trunk/src/VBox/Devices/Audio/DrvHostValidationKit.cpp
- Timestamp:
- Feb 3, 2017 7:00:44 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostValidationKit.cpp
r65565 r65606 37 37 /** Audio file to dump output to or read input from. */ 38 38 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; 39 45 union 40 46 { … … 152 158 if (RT_SUCCESS(rc)) 153 159 { 160 pDbgStream->tsStarted = 0; 161 pDbgStream->uSamplesSinceStarted = 0; 154 162 pDbgStream->Out.tsLastPlayed = 0; 155 pDbgStream->Out.cMaxSamplesInPlayBuffer = _1K;163 pDbgStream->Out.cMaxSamplesInPlayBuffer = 16 * _1K; 156 164 pDbgStream->Out.pu8PlayBuffer = (uint8_t *)RTMemAlloc(pDbgStream->Out.cMaxSamplesInPlayBuffer << Props.cShift); 157 165 if (!pDbgStream->Out.pu8PlayBuffer) … … 163 171 char szTemp[RTPATH_MAX]; 164 172 rc = RTPathTemp(szTemp, sizeof(szTemp)); 173 174 RTPathAppend(szTemp, sizeof(szTemp), "VBoxAudioValKit"); 175 165 176 if (RT_SUCCESS(rc)) 166 177 { … … 175 186 if (RT_FAILURE(rc)) 176 187 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)); 177 195 } 178 196 else … … 245 263 cSamplesPlayed = cLive;*/ 246 264 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 247 291 uint32_t cSamplesPlayed = 0; 248 292 uint32_t cSamplesAvail = RT_MIN(AudioMixBufUsed(&pStream->MixBuf), pDbgStream->Out.cMaxSamplesInPlayBuffer); 293 249 294 while (cSamplesAvail) 250 295 { … … 327 372 328 373 int rc = DrvAudioHlpWAVFileClose(&pDbgStream->File); 374 375 RTFileClose(pDbgStream->hFileTiming); 376 329 377 if (RT_SUCCESS(rc)) 330 378 { … … 335 383 && fDeleteEmptyFiles) 336 384 { 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); 338 392 } 339 393 else
Note:
See TracChangeset
for help on using the changeset viewer.