Changeset 73344 in vbox
- Timestamp:
- Jul 25, 2018 8:12:10 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp
r70013 r73344 7 7 8 8 /* 9 * Copyright (C) 2016-201 7Oracle Corporation9 * Copyright (C) 2016-2018 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 45 45 uint64_t tsLastCaptured; 46 46 } In; 47 struct48 {49 uint8_t *auPlayBuffer;50 uint32_t cbPlayBuffer;51 } Out;52 47 }; 53 48 } DEBUGAUDIOSTREAM, *PDEBUGAUDIOSTREAM; … … 136 131 RT_NOREF(pDrv); 137 132 138 int rc = VINF_SUCCESS; 139 140 pStreamDbg->Out.cbPlayBuffer = _1K * PDMAUDIOSTREAMCFG_F2B(pCfgReq, 1); /** @todo Make this configurable? */ 141 pStreamDbg->Out.auPlayBuffer = (uint8_t *)RTMemAlloc(pStreamDbg->Out.cbPlayBuffer); 142 if (!pStreamDbg->Out.auPlayBuffer) 143 rc = VERR_NO_MEMORY; 144 133 char szTemp[RTPATH_MAX]; 134 int rc = RTPathTemp(szTemp, sizeof(szTemp)); 145 135 if (RT_SUCCESS(rc)) 146 136 { 147 char szTemp[RTPATH_MAX]; 148 rc = RTPathTemp(szTemp, sizeof(szTemp)); 137 char szFile[RTPATH_MAX]; 138 rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, "DebugAudioOut", 139 pDrv->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE); 149 140 if (RT_SUCCESS(rc)) 150 141 { 151 char szFile[RTPATH_MAX]; 152 rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, "DebugAudioOut", 153 pDrv->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE); 142 rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE, &pStreamDbg->pFile); 154 143 if (RT_SUCCESS(rc)) 155 144 { 156 rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE, &pStreamDbg->pFile); 157 if (RT_SUCCESS(rc)) 158 { 159 rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE, 160 &pCfgReq->Props); 161 } 162 163 if (RT_FAILURE(rc)) 164 LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc)); 145 rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE, 146 &pCfgReq->Props); 165 147 } 166 else 167 LogRel(("DebugAudio: Unable to build file name for temp dir '%s': %Rrc\n", szTemp, rc)); 148 149 if (RT_FAILURE(rc)) 150 LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc)); 168 151 } 169 152 else 170 LogRel(("DebugAudio: Unable to retrieve temp dir: %Rrc\n", rc));153 LogRel(("DebugAudio: Unable to build file name for temp dir '%s': %Rrc\n", szTemp, rc)); 171 154 } 155 else 156 LogRel(("DebugAudio: Unable to retrieve temp dir: %Rrc\n", rc)); 172 157 173 158 if (RT_SUCCESS(rc)) … … 223 208 PDEBUGAUDIOSTREAM pStreamDbg = (PDEBUGAUDIOSTREAM)pStream; 224 209 225 uint32_t cbWrittenTotal = 0; 226 227 uint32_t cbAvail = cxBuf; 228 while (cbAvail) 229 { 230 uint32_t cbChunk = RT_MIN(cbAvail, pStreamDbg->Out.cbPlayBuffer); 231 232 memcpy(pStreamDbg->Out.auPlayBuffer, (uint8_t *)pvBuf + cbWrittenTotal, cbChunk); 233 234 int rc2 = DrvAudioHlpFileWrite(pStreamDbg->pFile, pStreamDbg->Out.auPlayBuffer, cbChunk, 0 /* fFlags */); 235 if (RT_FAILURE(rc2)) 236 { 237 LogRel(("DebugAudio: Writing output failed with %Rrc\n", rc2)); 238 break; 239 } 240 241 Assert(cbAvail >= cbChunk); 242 cbAvail -= cbChunk; 243 244 cbWrittenTotal += cbChunk; 210 int rc = DrvAudioHlpFileWrite(pStreamDbg->pFile, pvBuf, cxBuf, 0 /* fFlags */); 211 if (RT_FAILURE(rc)) 212 { 213 LogRel(("DebugAudio: Writing output failed with %Rrc\n", rc)); 214 return rc; 245 215 } 246 216 247 217 if (pcxWritten) 248 *pcxWritten = c bWrittenTotal;218 *pcxWritten = cxBuf; 249 219 250 220 return VINF_SUCCESS; … … 278 248 { 279 249 RT_NOREF(pDrv); 280 281 if (pStreamDbg->Out.auPlayBuffer)282 {283 RTMemFree(pStreamDbg->Out.auPlayBuffer);284 pStreamDbg->Out.auPlayBuffer = NULL;285 }286 250 287 251 DrvAudioHlpFileDestroy(pStreamDbg->pFile);
Note:
See TracChangeset
for help on using the changeset viewer.