- Timestamp:
- Jan 9, 2018 12:24:31 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120107
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostValidationKit.cpp
r70013 r70493 36 36 PPDMAUDIOSTREAMCFG pCfg; 37 37 /** Audio file to dump output to or read input from. */ 38 P DMAUDIOFILEFile;38 PPDMAUDIOFILE pFile; 39 39 /** Text file to store timing of audio buffers submittions**/ 40 40 RTFILE hFileTiming; … … 162 162 if (RT_SUCCESS(rc)) 163 163 { 164 char szFile[RTPATH_MAX]; 165 rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, NULL, PDMAUDIOFILETYPE_WAV); 164 char szFile[RTPATH_MAX + 1]; 165 166 rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, "VaKit", 167 0 /* Instance */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE); 166 168 if (RT_SUCCESS(rc)) 167 169 { 168 LogFlowFunc(("%s\n", szFile)); 169 rc = DrvAudioHlpFileOpen(&pStreamDbg->File, PDMAUDIOFILETYPE_WAV, szFile, 170 RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE, 171 &pCfgReq->Props, PDMAUDIOFILE_FLAG_NONE); 172 if (RT_FAILURE(rc)) 173 LogRel(("VaKitAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc)); 174 175 RTStrCat(szFile, sizeof(szFile), ".timing"); 176 rc = RTFileOpen(&pStreamDbg->hFileTiming, szFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE); 177 178 if (RT_FAILURE(rc)) 179 { 180 LogRel(("VaKitAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc)); 181 } 182 else 183 { 184 size_t cch; 185 char szTimingInfo[128]; 186 cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "# %dHz %dch %dbps\n", 187 pCfgReq->Props.uHz, pCfgReq->Props.cChannels, pCfgReq->Props.cBits); 188 189 RTFileWrite(pStreamDbg->hFileTiming, szTimingInfo, cch, NULL); 190 } 170 rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE, &pStreamDbg->pFile); 171 if (RT_SUCCESS(rc)) 172 rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, &pCfgReq->Props); 173 } 174 175 if (RT_FAILURE(rc)) 176 { 177 LogRel(("VaKitAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc)); 191 178 } 192 179 else 193 LogRel(("VaKitAudio: Unable to build file name for temp dir '%s': %Rrc\n", szTemp, rc)); 180 { 181 size_t cch; 182 char szTimingInfo[128]; 183 cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "# %dHz %dch %dbps\n", 184 pCfgReq->Props.uHz, pCfgReq->Props.cChannels, pCfgReq->Props.cBits); 185 186 RTFileWrite(pStreamDbg->hFileTiming, szTimingInfo, cch, NULL); 187 } 194 188 } 195 189 else … … 277 271 // pStreamDbg->Out.tsLastPlayed = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);; 278 272 279 int rc2 = DrvAudioHlpFileWrite( &pStreamDbg->File, pvBuf, cxBuf, 0 /* fFlags */);273 int rc2 = DrvAudioHlpFileWrite(pStreamDbg->pFile, pvBuf, cxBuf, 0 /* fFlags */); 280 274 if (RT_FAILURE(rc2)) 281 275 LogRel(("DebugAudio: Writing output failed with %Rrc\n", rc2)); … … 321 315 } 322 316 323 size_t cbDataSize = DrvAudioHlpFileGetDataSize(&pStreamDbg->File); 324 325 int rc = DrvAudioHlpFileClose(&pStreamDbg->File); 326 RTFileClose(pStreamDbg->hFileTiming); 327 328 if (RT_SUCCESS(rc)) 329 { 330 /* Delete the file again if nothing but the header was written to it. */ 331 bool fDeleteEmptyFiles = true; /** @todo Make deletion configurable? */ 332 333 if ( !cbDataSize 334 && fDeleteEmptyFiles) 335 { 336 char szFile[RTPATH_MAX]; 337 338 RTStrCopy(szFile, sizeof(szFile), pStreamDbg->File.szName); 339 RTFileDelete(szFile); 340 341 RTStrCat(szFile, sizeof(szFile), ".timing"); 342 RTFileDelete(szFile); 343 } 344 else 345 LogRel(("VaKitAudio: Created output file '%s' (%zu bytes)\n", pStreamDbg->File.szName, cbDataSize)); 346 } 347 348 return rc; 317 if (pStreamDbg->pFile) 318 { 319 size_t cbDataSize = DrvAudioHlpFileGetDataSize(pStreamDbg->pFile); 320 if (cbDataSize) 321 LogRel(("VaKitAudio: Created output file '%s' (%zu bytes)\n", pStreamDbg->pFile->szName, cbDataSize)); 322 323 DrvAudioHlpFileDestroy(pStreamDbg->pFile); 324 pStreamDbg->pFile = NULL; 325 } 326 327 return VINF_SUCCESS; 349 328 } 350 329
Note:
See TracChangeset
for help on using the changeset viewer.