VirtualBox

Changeset 89054 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
May 15, 2021 2:14:57 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144394
Message:

ValKit/Audio: Command line parsing fixes. Tag inconsistencies and crashes. bugref:10008

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioTest.cpp

    r89053 r89054  
    242242
    243243/**
     244 * Generates a tag.
     245 *
     246 * @returns VBox status code.
     247 * @param   pszTag              The output buffer.
     248 * @param   cbTag               The size of the output buffer.
     249 *                              AUDIOTEST_TAG_MAX is a good size.
     250 */
     251int AudioTestGenTag(char *pszTag, size_t cbTag)
     252{
     253    RTUUID UUID;
     254    int rc = RTUuidCreate(&UUID);
     255    AssertRCReturn(rc, rc);
     256    rc = RTUuidToStr(&UUID, pszTag, cbTag);
     257    AssertRCReturn(rc, rc);
     258    return rc;
     259}
     260
     261
     262/**
     263 * Return the tag to use in the given buffer, generating one if needed.
     264 *
     265 * @returns VBox status code.
     266 * @param   pszTag              The output buffer.
     267 * @param   cbTag               The size of the output buffer.
     268 *                              AUDIOTEST_TAG_MAX is a good size.
     269 * @param   pszTagUser          User specified tag, optional.
     270 */
     271int AudioTestCopyOrGenTag(char *pszTag, size_t cbTag, const char *pszTagUser)
     272{
     273    if (pszTagUser && *pszTagUser)
     274        return RTStrCopy(pszTag, cbTag, pszTagUser);
     275    return AudioTestGenTag(pszTag, cbTag);
     276}
     277
     278
     279/**
    244280 * Creates a new path (directory) for a specific audio test set tag.
    245281 *
     
    255291int AudioTestPathCreate(char *pszPath, size_t cbPath, const char *pszTag)
    256292{
    257     AssertReturn(strlen(pszTag) <= AUDIOTEST_TAG_MAX, VERR_INVALID_PARAMETER);
    258 
    259     int rc;
    260 
    261     char szTag[RTUUID_STR_LENGTH + 1];
    262     if (pszTag)
    263     {
    264         rc = RTStrCopy(szTag, sizeof(szTag), pszTag);
    265         AssertRCReturn(rc, rc);
    266     }
    267     else /* Create an UUID if no tag is specified. */
    268     {
    269         RTUUID UUID;
    270         rc = RTUuidCreate(&UUID);
    271         AssertRCReturn(rc, rc);
    272         rc = RTUuidToStr(&UUID, szTag, sizeof(szTag));
    273         AssertRCReturn(rc, rc);
    274     }
     293    char szTag[AUDIOTEST_TAG_MAX];
     294    int rc = AudioTestCopyOrGenTag(szTag, sizeof(szTag), pszTag);
     295    AssertRCReturn(rc, rc);
    275296
    276297    char szName[RT_ELEMENTS(AUDIOTEST_PATH_PREFIX_STR) + AUDIOTEST_TAG_MAX + 4];
     
    523544int AudioTestPathCreateTemp(char *pszPath, size_t cbPath, const char *pszTag)
    524545{
    525     AssertReturn(strlen(pszTag) <= AUDIOTEST_TAG_MAX, VERR_INVALID_PARAMETER);
     546    AssertReturn(pszTag && strlen(pszTag) <= AUDIOTEST_TAG_MAX, VERR_INVALID_PARAMETER);
    526547
    527548    char szPath[RTPATH_MAX];
     
    546567int AudioTestSetCreate(PAUDIOTESTSET pSet, const char *pszPath, const char *pszTag)
    547568{
    548     AssertReturn(strlen(pszTag) <= AUDIOTEST_TAG_MAX, VERR_INVALID_PARAMETER);
    549 
    550     int rc;
    551 
    552569    audioTestSetInitInternal(pSet);
     570
     571    int rc = AudioTestCopyOrGenTag(pSet->szTag, sizeof(pSet->szTag), pszTag);
     572    AssertRCReturn(rc, rc);
    553573
    554574    if (pszPath)
     
    557577        AssertRCReturn(rc, rc);
    558578
    559         rc = AudioTestPathCreate(pSet->szPathAbs, sizeof(pSet->szPathAbs), pszTag);
     579        rc = AudioTestPathCreate(pSet->szPathAbs, sizeof(pSet->szPathAbs), pSet->szTag);
    560580    }
    561581    else
    562         rc = AudioTestPathCreateTemp(pSet->szPathAbs, sizeof(pSet->szPathAbs), pszTag);
     582        rc = AudioTestPathCreateTemp(pSet->szPathAbs, sizeof(pSet->szPathAbs), pSet->szTag);
    563583    AssertRCReturn(rc, rc);
    564584
     
    583603        rc = audioTestManifestWriteLn(pSet, "ver=%d", AUDIOTEST_MANIFEST_VER);
    584604        AssertRCReturn(rc, rc);
    585         rc = audioTestManifestWriteLn(pSet, "tag=%s", pszTag);
     605        rc = audioTestManifestWriteLn(pSet, "tag=%s", pSet->szTag);
    586606        AssertRCReturn(rc, rc);
    587607
     
    613633
    614634        pSet->enmMode = AUDIOTESTSETMODE_TEST;
    615 
    616         rc = RTStrCopy(pSet->szTag, sizeof(pSet->szTag), pszTag);
    617         AssertRCReturn(rc, rc);
    618635    }
    619636
     
    676693
    677694    char szManifest[RTPATH_MAX];
    678     int rc = RTStrCopy(szManifest, sizeof(szManifest), pszPath);
    679     AssertRCReturn(rc, rc);
    680 
    681     rc = RTPathAppend(szManifest, sizeof(szManifest), AUDIOTEST_MANIFEST_FILE_STR);
     695    int rc = RTPathJoin(szManifest, sizeof(szManifest), pszPath, AUDIOTEST_MANIFEST_FILE_STR);
    682696    AssertRCReturn(rc, rc);
    683697
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette