- Timestamp:
- May 14, 2021 6:58:11 PM (4 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTest.cpp
r89045 r89051 34 34 #include <iprt/uuid.h> 35 35 #include <iprt/vfs.h> 36 #include <iprt/zip.h> 36 37 37 38 #define _USE_MATH_DEFINES … … 110 111 * @param pcbWritten How many bytes were written on success. 111 112 */ 112 int AudioTestTone Write(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten)113 int AudioTestToneGenerate(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 113 114 { 114 115 /* 115 * Clear the buffer first so we don't need to thin gabout additional channels.116 * Clear the buffer first so we don't need to think about additional channels. 116 117 */ 117 uint32_t cFrames = PDMAudioPropsBytesToFrames(&pTone->Props, cbBuf); 118 uint32_t cFrames = PDMAudioPropsBytesToFrames(&pTone->Props, cbBuf); 119 120 /* Input cbBuf not necessarily is aligned to the frames, so re-calculate it. */ 121 const uint32_t cbToWrite = PDMAudioPropsFramesToBytes(&pTone->Props, cFrames); 122 118 123 PDMAudioPropsClearBuffer(&pTone->Props, pvBuf, cbBuf, cFrames); 119 124 … … 206 211 207 212 if (pcbWritten) 208 *pcbWritten = PDMAudioPropsFramesToBytes(&pTone->Props, cFrames);213 *pcbWritten = cbToWrite; 209 214 210 215 return VINF_SUCCESS; … … 225 230 226 231 pToneParams->msPrequel = RTRandU32Ex(0, RT_MS_5SEC); 232 #ifdef DEBUG_andy 233 pToneParams->msDuration = RTRandU32Ex(0, RT_MS_1SEC); 234 #else 227 235 pToneParams->msDuration = RTRandU32Ex(0, RT_MS_10SEC); /** @todo Probably a bit too long, but let's see. */ 236 #endif 228 237 pToneParams->msSequel = RTRandU32Ex(0, RT_MS_5SEC); 229 238 pToneParams->uVolumePercent = RTRandU32Ex(0, 100); … … 246 255 int AudioTestPathCreate(char *pszPath, size_t cbPath, const char *pszTag) 247 256 { 257 AssertReturn(strlen(pszTag) <= AUDIOTEST_TAG_MAX, VERR_INVALID_PARAMETER); 258 248 259 int rc; 249 260 … … 263 274 } 264 275 265 char szName[ 128];266 if (RTStrPrintf2(szName, sizeof(szName), "%s %s", AUDIOTEST_PATH_PREFIX_STR, szTag) < 0)276 char szName[RT_ELEMENTS(AUDIOTEST_PATH_PREFIX_STR) + AUDIOTEST_TAG_MAX + 4]; 277 if (RTStrPrintf2(szName, sizeof(szName), "%s-%s", AUDIOTEST_PATH_PREFIX_STR, szTag) < 0) 267 278 AssertFailedReturn(VERR_BUFFER_OVERFLOW); 268 279 … … 365 376 { 366 377 pSet->f.hFile = NIL_RTFILE; 378 379 RTListInit(&pSet->lstObj); 367 380 } 368 381 … … 510 523 int AudioTestPathCreateTemp(char *pszPath, size_t cbPath, const char *pszTag) 511 524 { 525 AssertReturn(strlen(pszTag) <= AUDIOTEST_TAG_MAX, VERR_INVALID_PARAMETER); 526 512 527 char szPath[RTPATH_MAX]; 513 528 … … 531 546 int AudioTestSetCreate(PAUDIOTESTSET pSet, const char *pszPath, const char *pszTag) 532 547 { 548 AssertReturn(strlen(pszTag) <= AUDIOTEST_TAG_MAX, VERR_INVALID_PARAMETER); 549 533 550 int rc; 534 551 … … 596 613 597 614 pSet->enmMode = AUDIOTESTSETMODE_TEST; 615 616 rc = RTStrCopy(pSet->szTag, sizeof(pSet->szTag), pszTag); 617 AssertRCReturn(rc, rc); 598 618 } 599 619 … … 604 624 * Destroys a test set. 605 625 * 626 * @returns VBox status code. 606 627 * @param pSet Test set to destroy. 607 628 */ 608 voidAudioTestSetDestroy(PAUDIOTESTSET pSet)629 int AudioTestSetDestroy(PAUDIOTESTSET pSet) 609 630 { 610 631 if (!pSet) 611 return; 632 return VINF_SUCCESS; 633 634 int rc = VINF_SUCCESS; 635 636 PAUDIOTESTOBJ pObj, pObjNext; 637 RTListForEachSafe(&pSet->lstObj, pObj, pObjNext, AUDIOTESTOBJ, Node) 638 { 639 rc = AudioTestSetObjClose(pObj); 640 if (RT_SUCCESS(rc)) 641 { 642 RTListNodeRemove(&pObj->Node); 643 RTMemFree(pObj); 644 645 Assert(pSet->cObj); 646 pSet->cObj--; 647 } 648 else 649 break; 650 } 651 652 if (RT_FAILURE(rc)) 653 return rc; 654 655 Assert(pSet->cObj == 0); 612 656 613 657 if (RTFileIsValid(pSet->f.hFile)) … … 616 660 pSet->f.hFile = NIL_RTFILE; 617 661 } 662 663 return rc; 618 664 } 619 665 … … 661 707 662 708 /** 709 * Physically wipes all related test set files off the disk. 710 * 711 * @param pSet Test set to wipe. 712 */ 713 void AudioTestSetWipe(PAUDIOTESTSET pSet) 714 { 715 RT_NOREF(pSet); 716 } 717 718 /** 719 * Creates and registers a new audio test object to a test set. 720 * 721 * @returns VBox status code. 722 * @param pSet Test set to create and register new object for. 723 * @param pszName Name of new object to create. 724 * @param ppObj Where to return the pointer to the newly created object on success. 725 */ 726 int AudioTestSetObjCreateAndRegister(PAUDIOTESTSET pSet, const char *pszName, PAUDIOTESTOBJ *ppObj) 727 { 728 AssertPtrReturn(pszName, VERR_INVALID_POINTER); 729 730 PAUDIOTESTOBJ pObj = (PAUDIOTESTOBJ)RTMemAlloc(sizeof(AUDIOTESTOBJ)); 731 AssertPtrReturn(pObj, VERR_NO_MEMORY); 732 733 int rc = RTStrPrintf(pObj->szName, sizeof(pObj->szName), "%04RU32-%s", pSet->cObj, pszName); 734 AssertRCReturn(rc, rc); 735 736 /** @todo Generalize this function more once we have more object types. */ 737 738 char szFilePath[RTPATH_MAX]; 739 rc = RTPathJoin(szFilePath, sizeof(szFilePath), pSet->szPathAbs, pObj->szName); 740 AssertRCReturn(rc, rc); 741 742 rc = RTFileOpen(&pObj->File.hFile, szFilePath, RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE); 743 if (RT_SUCCESS(rc)) 744 { 745 pObj->enmType = AUDIOTESTOBJTYPE_FILE; 746 747 RTListAppend(&pSet->lstObj, &pObj->Node); 748 pSet->cObj++; 749 750 *ppObj = pObj; 751 } 752 753 if (RT_FAILURE(rc)) 754 RTMemFree(pObj); 755 756 return rc; 757 } 758 759 /** 760 * Writes to a created audio test object. 761 * 762 * @returns VBox status code. 763 * @param pObj Audio test object to write to. 764 */ 765 int AudioTestSetObjWrite(PAUDIOTESTOBJ pObj, void *pvBuf, size_t cbBuf) 766 { 767 /** @todo Generalize this function more once we have more object types. */ 768 AssertReturn(pObj->enmType == AUDIOTESTOBJTYPE_FILE, VERR_INVALID_PARAMETER); 769 770 return RTFileWrite(pObj->File.hFile, pvBuf, cbBuf, NULL); 771 } 772 773 /** 774 * Closes an opened audio test object. 775 * 776 * @returns VBox status code. 777 * @param pObj Audio test object to close. 778 */ 779 int AudioTestSetObjClose(PAUDIOTESTOBJ pObj) 780 { 781 if (!pObj) 782 return VINF_SUCCESS; 783 784 /** @todo Generalize this function more once we have more object types. */ 785 AssertReturn(pObj->enmType == AUDIOTESTOBJTYPE_FILE, VERR_INVALID_PARAMETER); 786 787 int rc = VINF_SUCCESS; 788 789 if (RTFileIsValid(pObj->File.hFile)) 790 { 791 rc = RTFileClose(pObj->File.hFile); 792 pObj->File.hFile = NIL_RTFILE; 793 } 794 795 return rc; 796 } 797 798 /** 663 799 * Packs an audio test so that it's ready for transmission. 664 800 * 665 801 * @returns VBox status code. 666 802 * @param pSet Test set to pack. 667 * @param pszOutDir Where to store the packed test set. 668 */ 669 int AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir) 670 { 671 RT_NOREF(pSet, pszOutDir); 672 803 * @param pszOutDir Directory where to store the packed test set. 804 * @param pszFileName Where to return the final name of the packed test set. Optional and can be NULL. 805 * @param cbFileName Size (in bytes) of \a pszFileName. 806 */ 807 int AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir, char *pszFileName, size_t cbFileName) 808 { 809 AssertReturn(!pszFileName || cbFileName, VERR_INVALID_PARAMETER); 673 810 AssertReturn(audioTestManifestIsOpen(pSet), VERR_WRONG_ORDER); 674 // RTZipTarCmd() 675 676 return VERR_NOT_IMPLEMENTED; 811 812 /** @todo Check and deny if \a pszOutDir is part of the set's path. */ 813 814 char szOutName[RT_ELEMENTS(AUDIOTEST_PATH_PREFIX_STR) + AUDIOTEST_TAG_MAX + 16]; 815 int rc = RTStrPrintf(szOutName, sizeof(szOutName), "%s-%s.tar.gz", AUDIOTEST_PATH_PREFIX_STR, pSet->szTag); 816 AssertRCReturn(rc, rc); 817 818 char szOutPath[RTPATH_MAX]; 819 rc = RTPathJoin(szOutPath, sizeof(szOutPath), pszOutDir, szOutName); 820 AssertRCReturn(rc, rc); 821 822 const char *apszArgs[10]; 823 unsigned cArgs = 0; 824 825 apszArgs[cArgs++] = "AudioTest"; 826 apszArgs[cArgs++] = "--create"; 827 apszArgs[cArgs++] = "--gzip"; 828 apszArgs[cArgs++] = "--directory"; 829 apszArgs[cArgs++] = pSet->szPathAbs; 830 apszArgs[cArgs++] = "--file"; 831 apszArgs[cArgs++] = szOutPath; 832 apszArgs[cArgs++] = "."; 833 834 RTEXITCODE rcExit = RTZipTarCmd(cArgs, (char **)apszArgs); 835 if (rcExit != RTEXITCODE_SUCCESS) 836 rc = VERR_GENERAL_FAILURE; /** @todo Fudge! */ 837 838 if (RT_SUCCESS(rc)) 839 { 840 if (pszFileName) 841 rc = RTStrCopy(pszFileName, cbFileName, szOutPath); 842 } 843 844 return rc; 677 845 } 678 846 -
trunk/src/VBox/Devices/Audio/AudioTest.h
r89043 r89051 24 24 #endif 25 25 26 /** @todo Some stuff here can be private-only to the implementation. */ 27 28 /** Maximum length in characters an audio test tag can have. */ 29 #define AUDIOTEST_TAG_MAX 64 30 /** Maximum length in characters a single audio test error description can have. */ 31 #define AUDIOTEST_ERROR_DESC_MAX 128 26 32 /** Prefix for audio test (set) directories. */ 27 #define AUDIOTEST_PATH_PREFIX_STR " audio-test-"33 #define AUDIOTEST_PATH_PREFIX_STR "vkat" 28 34 29 35 /** … … 131 137 typedef struct AUDIOTESTPARMS 132 138 { 133 /** Specifies the test to run. */134 uint32_t idx Test;139 /** Specifies the current test iteration. */ 140 uint32_t idxCurrent; 135 141 /** How many iterations the test should be executed. */ 136 142 uint32_t cIterations; … … 152 158 typedef AUDIOTESTPARMS *PAUDIOTESTPARMS; 153 159 160 typedef enum AUDIOTESTOBJTYPE 161 { 162 AUDIOTESTOBJTYPE_UNKNOWN = 0, 163 AUDIOTESTOBJTYPE_FILE, 164 /** The usual 32-bit hack. */ 165 AUDIOTESTOBJTYPE_32BIT_HACK = 0x7fffffff 166 } AUDIOTESTOBJTYPE; 167 168 typedef struct AUDIOTESTOBJFILE 169 { 170 RTFILE hFile; 171 } AUDIOTESTOBJFILE; 172 173 typedef struct AUDIOTESTOBJ 174 { 175 RTLISTNODE Node; 176 char szName[64]; 177 AUDIOTESTOBJTYPE enmType; 178 union 179 { 180 AUDIOTESTOBJFILE File; 181 }; 182 } AUDIOTESTOBJ; 183 /** Pointer to an audio test object. */ 184 typedef AUDIOTESTOBJ *PAUDIOTESTOBJ; 185 154 186 /** 155 187 * Structure specifying an audio test set. … … 157 189 typedef struct AUDIOTESTSET 158 190 { 191 /** The set's tag. */ 192 char szTag[AUDIOTEST_TAG_MAX]; 159 193 /** Absolute path where to store the test audio data. */ 160 194 char szPathAbs[RTPATH_MAX]; … … 166 200 RTINIFILE hIniFile; 167 201 } f; 202 uint32_t cObj; 203 RTLISTANCHOR lstObj; 168 204 } AUDIOTESTSET; 169 205 /** Pointer to an audio test set. */ … … 180 216 int rc; 181 217 /** Actual error description. */ 182 char szDesc[ 128];218 char szDesc[AUDIOTEST_ERROR_DESC_MAX]; 183 219 } AUDIOTESTERRORENTRY; 184 220 /** Pointer to an audio test error description. */ … … 201 237 202 238 double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps); 203 int AudioTestTone Write(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten);239 int AudioTestToneGenerate(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten); 204 240 205 241 int AudioTestToneParamsInitRandom(PAUDIOTESTTONEPARMS pToneParams, PPDMAUDIOPCMPROPS pProps); … … 208 244 int AudioTestPathCreate(char *pszPath, size_t cbPath, const char *pszUUID); 209 245 246 int AudioTestSetObjCreateAndRegister(PAUDIOTESTSET pSet, const char *pszName, PAUDIOTESTOBJ *ppObj); 247 int AudioTestSetObjWrite(PAUDIOTESTOBJ pObj, void *pvBuf, size_t cbBuf); 248 int AudioTestSetObjClose(PAUDIOTESTOBJ pObj); 249 210 250 int AudioTestSetCreate(PAUDIOTESTSET pSet, const char *pszPath, const char *pszTag); 211 voidAudioTestSetDestroy(PAUDIOTESTSET pSet);251 int AudioTestSetDestroy(PAUDIOTESTSET pSet); 212 252 int AudioTestSetOpen(PAUDIOTESTSET pSet, const char *pszPath); 213 253 void AudioTestSetClose(PAUDIOTESTSET pSet); 214 int AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir); 254 void AudioTestSetWipe(PAUDIOTESTSET pSet); 255 int AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir, char *pszFileName, size_t cbFileName); 215 256 int AudioTestSetUnpack(const char *pszFile, const char *pszOutDir); 216 257 int AudioTestSetVerify(PAUDIOTESTSET pSet, const char *pszTag, PAUDIOTESTERRORDESC pErrDesc); -
trunk/src/VBox/Devices/Audio/DrvHostAudioDebug.cpp
r88923 r89051 264 264 265 265 uint32_t cbWritten; 266 int rc = AudioTestTone Write(&pStreamDbg->In, pvBuf, cbBuf, &cbWritten);266 int rc = AudioTestToneGenerate(&pStreamDbg->In, pvBuf, cbBuf, &cbWritten); 267 267 if (RT_SUCCESS(rc)) 268 268 { -
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r89016 r89051 100 100 typedef struct AUDIOTESTENV 101 101 { 102 /** Output path for storing the test environment's final test files. */ 103 char szPathOut[RTPATH_MAX]; 104 /** Temporary path for this test environment. */ 105 char szPathTemp[RTPATH_MAX]; 102 106 /** The host (backend) driver to use. */ 103 107 PPDMIHOSTAUDIO pDrvAudio; … … 156 160 VKAT_TEST_OPT_PCM_SIGNED, 157 161 VKAT_TEST_OPT_TAG, 162 VKAT_TEST_OPT_TEMPDIR, 158 163 VKAT_TEST_OPT_VOL 159 164 }; … … 194 199 { "--pcm-signed", VKAT_TEST_OPT_PCM_SIGNED, RTGETOPT_REQ_BOOL }, 195 200 { "--tag", VKAT_TEST_OPT_TAG, RTGETOPT_REQ_STRING }, 201 { "--tempdir", VKAT_TEST_OPT_TEMPDIR, RTGETOPT_REQ_STRING }, 196 202 { "--volume", VKAT_TEST_OPT_VOL, RTGETOPT_REQ_UINT8 } 197 203 }; … … 223 229 * @param pDrvAudio Audio driver to use. 224 230 * @param pszPathOut Output path to use. If NULL, the system's temp directory will be used. 225 * @þaram pszTag Tag name to use. If NULL, a generated UUID will be used. 226 */ 227 static int audioTestEnvInit(PAUDIOTESTENV pTstEnv, PPDMIHOSTAUDIO pDrvAudio, const char *pszPathOut, const char *pszTag) 228 { 229 RT_BZERO(pTstEnv, sizeof(AUDIOTESTENV)); 230 231 * @param pszPathTemp Temporary path to use. If NULL, the system's temp directory will be used. 232 * @param pszTag Tag name to use. If NULL, a generated UUID will be used. 233 */ 234 static int audioTestEnvInit(PAUDIOTESTENV pTstEnv, PPDMIHOSTAUDIO pDrvAudio, const char *pszTag) 235 { 231 236 pTstEnv->pDrvAudio = pDrvAudio; 232 237 PDMAudioHostEnumInit(&pTstEnv->DevEnm); 233 238 234 return AudioTestSetCreate(&pTstEnv->Set, pszPathOut, pszTag); 239 int rc = VINF_SUCCESS; 240 241 char szPathTemp[RTPATH_MAX]; 242 if ( !strlen(pTstEnv->szPathTemp) 243 || !strlen(pTstEnv->szPathOut)) 244 rc = RTPathTemp(szPathTemp, sizeof(szPathTemp)); 245 246 if ( RT_SUCCESS(rc) 247 && !strlen(pTstEnv->szPathTemp)) 248 rc = RTPathJoin(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp), szPathTemp, "vkat-temp"); 249 250 if ( RT_SUCCESS(rc) 251 && !strlen(pTstEnv->szPathOut)) 252 rc = RTPathJoin(pTstEnv->szPathOut, sizeof(pTstEnv->szPathOut), szPathTemp, "vkat"); 253 254 if (RT_SUCCESS(rc)) 255 rc = AudioTestSetCreate(&pTstEnv->Set, pTstEnv->szPathTemp, pszTag); 256 257 if (RT_SUCCESS(rc)) 258 { 259 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using tag '%s'\n", pszTag); 260 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Output directory is '%s'\n", pTstEnv->szPathOut); 261 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Temp directory is '%s'\n", pTstEnv->szPathTemp); 262 } 263 264 return rc; 235 265 } 236 266 … … 585 615 AudioTestToneInitRandom(&TstTone, &pParms->Props); 586 616 587 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing test tone (freq %RU16, %RU32ms)\n", TstTone.rdFreqHz, pParms->msDuration); 588 589 int rc; 617 const char *pcszPathOut = pTstEnv->Set.szPathAbs; 618 619 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing test tone (tone frequency is %RU16Hz, %RU32ms)\n", TstTone.rdFreqHz, pParms->msDuration); 620 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Writing to '%s'\n", pcszPathOut); 621 622 /** @todo Use .WAV here? */ 623 PAUDIOTESTOBJ pObj; 624 int rc = AudioTestSetObjCreateAndRegister(&pTstEnv->Set, "tone.pcm", &pObj); 625 AssertRCReturn(rc, rc); 590 626 591 627 PDMHOSTAUDIOSTREAMSTATE enmState = pTstEnv->pDrvAudio->pfnStreamGetState(pTstEnv->pDrvAudio, &pStream->Backend); … … 601 637 do 602 638 { 603 rc = AudioTestTone Write(&TstTone, abBuf, RT_MIN(cbPerMs, sizeof(abBuf)), &cbBuf);639 rc = AudioTestToneGenerate(&TstTone, abBuf, RT_MIN(cbPerMs, sizeof(abBuf)), &cbBuf); 604 640 if (RT_SUCCESS(rc)) 605 641 { 606 uint32_t cbWritten; 607 rc = pTstEnv->pDrvAudio->pfnStreamPlay(pTstEnv->pDrvAudio, &pStream->Backend, abBuf, cbBuf, &cbWritten); 642 /* Write stuff to disk before trying to play it. Help analysis later. */ 643 rc = AudioTestSetObjWrite(pObj, abBuf, cbBuf); 644 if (RT_SUCCESS(rc)) 645 { 646 uint32_t cbWritten; 647 rc = pTstEnv->pDrvAudio->pfnStreamPlay(pTstEnv->pDrvAudio, &pStream->Backend, abBuf, cbBuf, &cbWritten); 648 } 608 649 } 609 650 610 651 if (RTTimeMilliTS() - tsStartMs >= pParms->msDuration) 652 break; 653 654 if (RT_FAILURE(rc)) 611 655 break; 612 656 … … 617 661 else 618 662 rc = VERR_AUDIO_STREAM_NOT_READY; 663 664 int rc2 = AudioTestSetObjClose(pObj); 665 if (RT_SUCCESS(rc)) 666 rc = rc2; 619 667 620 668 return rc; … … 652 700 PDMAudioPropsInit(&pTstParmsAcq->TestTone.Props, 16 /* bit */ / 8, true /* fSigned */, 2 /* Channels */, 44100 /* Hz */); 653 701 702 #ifdef DEBUG_andy 703 pTstParmsAcq->cIterations = RTRandU32Ex(1, 1); 704 #endif 654 705 pTstParmsAcq->cIterations = RTRandU32Ex(1, 10); 706 pTstParmsAcq->idxCurrent = 0; 655 707 656 708 return VINF_SUCCESS; … … 806 858 int audioTestMain(int argc, char **argv) 807 859 { 808 int rc; 860 AUDIOTESTENV TstEnv; 861 RT_ZERO(TstEnv); 809 862 810 863 AUDIOTESTPARMS TstCust; … … 812 865 813 866 char *pszDevice = NULL; /* Custom device to use. Can be NULL if not being used. */ 814 char *pszPathOut = NULL; /* Custom output path to use. Can be NULL if not being used. */815 867 char *pszTag = NULL; /* Custom tag to use. Can be NULL if not being used. */ 816 868 … … 820 872 RTGETOPTUNION ValueUnion; 821 873 RTGETOPTSTATE GetState; 822 rc = RTGetOptInit(&GetState, argc, argv, g_aCmdTestOptions, RT_ELEMENTS(g_aCmdTestOptions), 0, 0 /* fFlags */);874 int rc = RTGetOptInit(&GetState, argc, argv, g_aCmdTestOptions, RT_ELEMENTS(g_aCmdTestOptions), 0, 0 /* fFlags */); 823 875 AssertRCReturn(rc, RTEXITCODE_INIT); 824 876 … … 915 967 case VKAT_TEST_OPT_OUTDIR: 916 968 { 917 pszPathOut = RTStrDup(ValueUnion.psz); 969 rc = RTStrCopy(TstEnv.szPathOut, sizeof(TstEnv.szPathOut), ValueUnion.psz); 970 if (RT_FAILURE(rc)) 971 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Out dir invalid, rc=%Rrc\n", rc); 918 972 break; 919 973 } … … 946 1000 { 947 1001 pszTag = RTStrDup(ValueUnion.psz); 1002 break; 1003 } 1004 1005 case VKAT_TEST_OPT_TEMPDIR: 1006 { 1007 rc = RTStrCopy(TstEnv.szPathTemp, sizeof(TstEnv.szPathTemp), ValueUnion.psz); 1008 if (RT_FAILURE(rc)) 1009 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Temp dir invalid, rc=%Rrc\n", rc); 948 1010 break; 949 1011 } … … 982 1044 { 983 1045 /* For now all tests have the same test environment. */ 984 AUDIOTESTENV TstEnv; 985 rc = audioTestEnvInit(&TstEnv, pDrvAudio, pszPathOut, pszTag); 1046 rc = audioTestEnvInit(&TstEnv, pDrvAudio, pszTag); 986 1047 if (RT_SUCCESS(rc)) 987 1048 { 988 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Output directory is '%s'\n", TstEnv.Set.szPathAbs);989 990 1049 PPDMAUDIOHOSTDEV pDev; 991 1050 rc = audioTestDevicesEnumerateAndCheck(&TstEnv, pszDevice, &pDev); … … 993 1052 audioTestWorker(&TstEnv, &TstCust); 994 1053 1054 /* Before destroying the test environment, pack up the test set so 1055 * that it's ready for transmission. */ 1056 char szFileOut[RTPATH_MAX]; 1057 rc = AudioTestSetPack(&TstEnv.Set, TstEnv.szPathOut, szFileOut, sizeof(szFileOut)); 1058 if (RT_SUCCESS(rc)) 1059 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set packed up to '%s'\n", szFileOut); 1060 1061 /* Clean up. */ 1062 AudioTestSetWipe(&TstEnv.Set); 1063 995 1064 audioTestEnvDestroy(&TstEnv); 996 1065 } … … 1001 1070 1002 1071 RTStrFree(pszDevice); 1003 RTStrFree(pszPathOut);1004 1072 RTStrFree(pszTag); 1073 1074 if (RT_FAILURE(rc)) /* Let us know that something went wrong in case we forgot to mention it. */ 1075 RTTestFailed(g_hTest, "Tested failed with %Rrc\n", rc); 1005 1076 1006 1077 /*
Note:
See TracChangeset
for help on using the changeset viewer.