Changeset 91665 in vbox
- Timestamp:
- Oct 11, 2021 4:55:35 PM (3 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Devices/Audio/AudioTest.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTest.cpp
r91662 r91665 2205 2205 typedef struct AUDIOTESTFILECMPPARMS 2206 2206 { 2207 /** File name for logging purposes. */ 2208 const char *pszName; 2207 2209 /** File handle to file to compare. */ 2208 RTFILE hFile;2210 RTFILE hFile; 2209 2211 /** Absolute offset (in bytes) to start comparing. 2210 2212 * Ignored when set to 0. */ 2211 uint64_t offStart;2213 uint64_t offStart; 2212 2214 /** Size (in bytes) of area to compare. 2213 2215 * Starts at \a offStart. */ 2214 uint64_t cbSize;2216 uint64_t cbSize; 2215 2217 } AUDIOTESTFILECMPPARMS; 2216 2218 /** Pointer to file comparison parameters for one file. */ … … 2317 2319 } 2318 2320 2321 /** 2322 * Verifies a pre/post beacon of a test tone. 2323 * 2324 * @returns VBox status code. 2325 * @param pVerJob Verification job to verify PCM data for. 2326 * @param fPre Set to \c true to verify a pre beacon, or \c false to verify a post beacon. 2327 * @param pCmp File comparison parameters to file to verify beacon for. 2328 * @param pToneParms Tone parameters to use for verification. 2329 */ 2330 static int audioTestToneVerifyBeacon(PAUDIOTESTVERIFYJOB pVerJob, 2331 bool fPre, PAUDIOTESTFILECMPPARMS pCmp, PAUDIOTESTTONEPARMS pToneParms) 2332 { 2333 int rc = RTFileSeek(pCmp->hFile, pCmp->offStart, RTFILE_SEEK_BEGIN, NULL); 2334 AssertRCReturn(rc, rc); 2335 2336 uint8_t auBuf[64]; 2337 uint64_t cbToCompare = pCmp->cbSize; 2338 uint32_t const cbFrameSize = PDMAudioPropsFrameSize(&pToneParms->Props); /* Use the audio frame size as chunk size. */ 2339 bool fInBeacon = false; 2340 uint32_t cbBeacon = 0; 2341 2342 uint8_t const byBeacon = fPre ? AUDIOTEST_BEACON_BYTE_PRE : AUDIOTEST_BEACON_BYTE_POST; 2343 2344 AssertReturn(cbFrameSize == 4, VERR_NOT_SUPPORTED); /* Otherwise the stuff below won't work. */ 2345 2346 /* Slow as heck, but does the job for now. */ 2347 while (cbToCompare) 2348 { 2349 size_t cbRead; 2350 rc = RTFileRead(pCmp->hFile, auBuf, RT_MIN(cbToCompare, cbFrameSize), &cbRead); 2351 AssertRCBreak(rc); 2352 2353 if (cbRead < cbFrameSize) 2354 break; 2355 2356 for (size_t i = 0; i < cbRead; i += cbFrameSize) 2357 { 2358 if ( auBuf[i] == byBeacon 2359 && auBuf[i + 1] == byBeacon 2360 && auBuf[i + 2] == byBeacon 2361 && auBuf[i + 3] == byBeacon) 2362 { 2363 if (!fInBeacon) 2364 { 2365 cbBeacon = 0; 2366 fInBeacon = true; 2367 } 2368 cbBeacon += cbFrameSize; 2369 } 2370 else 2371 { 2372 if (fInBeacon) 2373 { 2374 fInBeacon = false; 2375 continue; 2376 } 2377 } 2378 } 2379 2380 cbToCompare -= cbRead; 2381 } 2382 2383 uint32_t const cbBeaconExpected = PDMAudioPropsFramesToBytes(&pToneParms->Props, AUDIOTEST_BEACON_SIZE_FRAMES); 2384 bool const fValid = cbBeacon == cbBeaconExpected; 2385 if (!fValid) 2386 { 2387 int rc2 = audioTestErrorDescAddError(pVerJob->pErr, pVerJob->idxTest, "File '%s': %s beacon %s (got %RU32 bytes, expected %RU32)", 2388 pCmp->pszName, 2389 fPre ? "Pre" : "Post", cbBeacon ? "found" : "not found", cbBeacon, cbBeaconExpected); 2390 AssertRC(rc2); 2391 } 2392 2393 return rc; 2394 } 2395 2319 2396 #define CHECK_RC_MAYBE_RET(a_rc, a_pVerJob) \ 2320 2397 if (RT_FAILURE(a_rc)) \ … … 2394 2471 size_t const cbDiffAbs = cbSizeA > cbSizeB ? cbSizeA - cbSizeB : cbSizeB - cbSizeA; 2395 2472 2396 int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s' is%zu bytes (%RU64ms)",2473 int rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s': %zu bytes (%RU64ms)", 2397 2474 ObjA.szName, cbSizeA, PDMAudioPropsBytesToMilli(&pVerJob->PCMProps, cbSizeA)); 2398 2475 AssertRC(rc2); 2399 rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s' is%zu bytes (%RU64ms)",2476 rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File '%s': %zu bytes (%RU64ms)", 2400 2477 ObjB.szName, cbSizeB, PDMAudioPropsBytesToMilli(&pVerJob->PCMProps, cbSizeB)); 2401 2478 AssertRC(rc2); … … 2435 2512 AUDIOTESTFILECMPPARMS FileA; 2436 2513 RT_ZERO(FileA); 2514 FileA.pszName = ObjA.szName; 2437 2515 FileA.hFile = ObjA.File.hFile; 2438 2516 FileA.offStart = audioTestToneFileFind(ObjA.File.hFile, … … 2448 2526 AUDIOTESTFILECMPPARMS FileB; 2449 2527 RT_ZERO(FileB); 2528 FileB.pszName = ObjB.szName; 2450 2529 FileB.hFile = ObjB.File.hFile; 2451 2530 FileB.offStart = audioTestToneFileFind(ObjB.File.hFile, … … 2461 2540 AssertRC(rc2); 2462 2541 2463 rc = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File B ('%s'): uOff=%RU64 (%#x), cbSize=%RU64 (%#x), cbFileSize=%RU64\n",2464 ObjB.szName, FileB.offStart, FileB.offStart, FileB.cbSize, FileB.cbSize, cbSizeB);2542 rc2 = audioTestErrorDescAddInfo(pVerJob->pErr, pVerJob->idxTest, "File B ('%s'): uOff=%RU64 (%#x), cbSize=%RU64 (%#x), cbFileSize=%RU64\n", 2543 ObjB.szName, FileB.offStart, FileB.offStart, FileB.cbSize, FileB.cbSize, cbSizeB); 2465 2544 AssertRC(rc2); 2466 2545 #endif 2467 2546 2547 rc = audioTestToneVerifyBeacon(pVerJob, true /* fPre */, &FileA, &ToneParmsA); 2548 AssertRC(rc); 2549 rc = audioTestToneVerifyBeacon(pVerJob, false /* fPost */, &FileA, &ToneParmsA); 2550 AssertRC(rc); 2551 rc = audioTestToneVerifyBeacon(pVerJob, true /* fPre */, &FileB, &ToneParmsB); 2552 AssertRC(rc); 2553 rc = audioTestToneVerifyBeacon(pVerJob, false /* fPost */, &FileB, &ToneParmsB); 2554 AssertRC(rc); 2555 2556 /* Note! When finding the pre/post beacons fail it's mostly pointless to comparing the files in any way, 2557 * as this would be the strongest hint that testing failed as a whole. We do it anyway for now, to 2558 * just get a clue what's going on. Might be disabled lateron. */ 2468 2559 uint32_t const cDiffs = audioTestFilesFindDiffsBinary(pVerJob, &FileA, &FileB, &ToneParmsA); 2469 2560
Note:
See TracChangeset
for help on using the changeset viewer.

