Changeset 92379 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Nov 11, 2021 5:32:37 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTest.cpp
r92378 r92379 2242 2242 2243 2243 /** 2244 * Determines if a given file chunk contains all silence (i.e. non-audible audio data) or not. 2245 * 2246 * What "silence" means depends on the given PCM parameters. 2247 * 2248 * @returns VBox status code. 2249 * @param phFile File handle of file to determine silence for. 2250 * @param pProps PCM properties to use. 2251 * @param offStart Start offset (absolute, in bytes) to start at. 2252 * @param cbSize Size (in bytes) to process. 2253 * @param pfIsSilence Where to return the result. 2254 * 2255 * @note Does *not* modify the file's current position. 2256 */ 2257 static int audioTestFileChunkIsSilence(PRTFILE phFile, PPDMAUDIOPCMPROPS pProps, uint64_t offStart, size_t cbSize, 2258 bool *pfIsSilence) 2259 { 2260 bool fIsSilence = true; 2261 2262 int rc = RTFileSeek(*phFile, offStart, RTFILE_SEEK_BEGIN, NULL); 2263 AssertRCReturn(rc, rc); 2264 2265 uint8_t auBuf[_64K]; 2266 while (cbSize) 2267 { 2268 size_t cbRead; 2269 rc = RTFileRead(*phFile, auBuf, RT_MIN(cbSize, sizeof(auBuf)), &cbRead); 2270 AssertRC(rc); 2271 2272 if (!PDMAudioPropsIsBufferSilence(pProps, auBuf, cbRead)) 2273 { 2274 fIsSilence = false; 2275 break; 2276 } 2277 2278 AssertBreak(cbSize >= cbRead); 2279 cbSize -= cbRead; 2280 } 2281 2282 if (RT_SUCCESS(rc)) 2283 *pfIsSilence = fIsSilence; 2284 2285 return RTFileSeek(*phFile, offStart, RTFILE_SEEK_BEGIN, NULL); 2286 } 2287 2288 /** 2244 2289 * Finds differences in two audio test files by binary comparing chunks. 2245 2290 * … … 2298 2343 if (fInDiff) 2299 2344 { 2300 bool const fIsAllSilenceA = PDMAudioPropsIsBufferSilence(&pToneParms->Props, auBufA, cbToCmp); 2301 bool const fIsAllSilenceB = PDMAudioPropsIsBufferSilence(&pToneParms->Props, auBufB, cbToCmp); 2345 bool fIsAllSilenceA; 2346 rc = audioTestFileChunkIsSilence(&pCmpA->hFile, &pToneParms->Props, 2347 pCmpA->offStart + offDiffStart, offCur - offDiffStart, &fIsAllSilenceA); 2348 AssertRCBreak(rc); 2349 2350 bool fIsAllSilenceB; 2351 rc = audioTestFileChunkIsSilence(&pCmpB->hFile, &pToneParms->Props, 2352 pCmpB->offStart + offDiffStart, offCur - offDiffStart, &fIsAllSilenceB); 2353 AssertRCBreak(rc); 2302 2354 2303 2355 uint32_t const cbDiff = offCur - offDiffStart; 2304 int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Chunks differ: A @ %#x [%08RU64-%08RU64] vs. B@ %#x [%08RU64-%08RU64] (%RU64 bytes, %RU64ms)",2305 pCmpA-> offStart + offDiffStart, pCmpA->offStart + offDiffStart, pCmpA->offStart + offCur,2306 pCmpB-> offStart + offDiffStart, pCmpB->offStart + offDiffStart, pCmpB->offStart + offCur,2356 int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Chunks differ: '%s' @ %#x [%08RU64-%08RU64] vs. '%s' @ %#x [%08RU64-%08RU64] (%RU64 bytes, %RU64ms)", 2357 pCmpA->pszName, pCmpA->offStart + offDiffStart, pCmpA->offStart + offDiffStart, pCmpA->offStart + offCur, 2358 pCmpB->pszName, pCmpB->offStart + offDiffStart, pCmpB->offStart + offDiffStart, pCmpB->offStart + offCur, 2307 2359 cbDiff, PDMAudioPropsBytesToMilli(&pToneParms->Props, cbDiff)); 2308 2360 AssertRC(rc2); … … 2311 2363 { 2312 2364 rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Chunk %s @ %#x (%RU64 bytes, %RU64ms) is all silence", 2313 fIsAllSilenceA ? "A" : "B",2365 fIsAllSilenceA ? pCmpA->pszName : pCmpB->pszName, 2314 2366 offDiffStart, cbDiff, PDMAudioPropsBytesToMilli(&pToneParms->Props, cbDiff)); 2315 2367 AssertRC(rc2); … … 2330 2382 { 2331 2383 uint32_t const cbDiff = offCur - offDiffStart; 2332 int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Chunks differ: A @ %#x [%08RU64-%08RU64] vs. B@ %#x [%08RU64-%08RU64] (%RU64 bytes, %RU64ms)",2333 pCmpA-> offStart + offDiffStart, pCmpA->offStart + offDiffStart, pCmpA->offStart + offCur,2334 pCmpB-> offStart + offDiffStart, pCmpB->offStart + offDiffStart, pCmpB->offStart + offCur,2384 int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "Chunks differ: '%s' @ %#x [%08RU64-%08RU64] vs. '%s' @ %#x [%08RU64-%08RU64] (%RU64 bytes, %RU64ms)", 2385 pCmpA->pszName, pCmpA->offStart + offDiffStart, pCmpA->offStart + offDiffStart, pCmpA->offStart + offCur, 2386 pCmpB->pszName, pCmpB->offStart + offDiffStart, pCmpB->offStart + offDiffStart, pCmpB->offStart + offCur, 2335 2387 cbDiff, PDMAudioPropsBytesToMilli(&pToneParms->Props, cbDiff)); 2336 2388 AssertRC(rc2);
Note:
See TracChangeset
for help on using the changeset viewer.