VirtualBox

Ignore:
Timestamp:
Dec 6, 2019 1:14:36 PM (5 years ago)
Author:
vboxsync
Message:

Devices/Audio/*: No need to +1 on RTPATH_MAX.

File:
1 edited

Legend:

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

    r82255 r82458  
    142142    RT_NOREF(pDrv, pCfgAcq);
    143143
    144     int rc = VINF_SUCCESS;
    145 
    146144    pStreamDbg->tsStarted = 0;
    147145    pStreamDbg->uSamplesSinceStarted = 0;
     
    149147    pStreamDbg->Out.cbPlayBuffer  = DrvAudioHlpFramesToBytes(pCfgReq->Backend.cFramesBufferSize, &pCfgReq->Props);
    150148    pStreamDbg->Out.pu8PlayBuffer = (uint8_t *)RTMemAlloc(pStreamDbg->Out.cbPlayBuffer);
    151     if (!pStreamDbg->Out.pu8PlayBuffer)
    152         rc = VERR_NO_MEMORY;
    153 
     149    AssertReturn(pStreamDbg->Out.pu8PlayBuffer, VERR_NO_MEMORY);
     150
     151    char szTemp[RTPATH_MAX];
     152    int rc = RTPathTemp(szTemp, sizeof(szTemp));
    154153    if (RT_SUCCESS(rc))
    155     {
    156         char szTemp[RTPATH_MAX];
    157         rc = RTPathTemp(szTemp, sizeof(szTemp));
    158 
    159         RTPathAppend(szTemp, sizeof(szTemp), "VBoxTestTmp\\VBoxAudioValKit");
    160 
     154        rc = RTPathAppend(szTemp, sizeof(szTemp), "VBoxTestTmp\\VBoxAudioValKit");
     155    if (RT_SUCCESS(rc))
     156    {
     157        char szFile[RTPATH_MAX];
     158        rc = DrvAudioHlpFileNameGet(szFile, sizeof(szFile), szTemp, "VaKit",
     159                                    0 /* Instance */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE);
    161160        if (RT_SUCCESS(rc))
    162161        {
    163             char szFile[RTPATH_MAX + 1];
    164 
    165             rc = DrvAudioHlpFileNameGet(szFile, RT_ELEMENTS(szFile), szTemp, "VaKit",
    166                                         0 /* Instance */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE);
     162            rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAGS_NONE, &pStreamDbg->pFile);
    167163            if (RT_SUCCESS(rc))
    168             {
    169                 rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAGS_NONE, &pStreamDbg->pFile);
    170                 if (RT_SUCCESS(rc))
    171                     rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, &pCfgReq->Props);
    172             }
    173 
    174             if (RT_FAILURE(rc))
    175             {
    176                 LogRel(("VaKitAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
    177             }
    178             else
    179             {
    180                 size_t cch;
    181                 char szTimingInfo[128];
    182                 cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "# %uHz %uch %ubit\n",
    183                                   pCfgReq->Props.uHz, pCfgReq->Props.cChannels, pCfgReq->Props.cbSample * 8);
    184 
    185                 RTFileWrite(pStreamDbg->hFileTiming, szTimingInfo, cch, NULL);
    186             }
     164                rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, &pCfgReq->Props);
    187165        }
     166
     167        if (RT_FAILURE(rc))
     168            LogRel(("VaKitAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
    188169        else
    189             LogRel(("VaKitAudio: Unable to retrieve temp dir: %Rrc\n", rc));
    190     }
    191 
     170        {
     171            size_t cch;
     172            char szTimingInfo[128];
     173            cch = RTStrPrintf(szTimingInfo, sizeof(szTimingInfo), "# %uHz %uch %ubit\n",
     174                              pCfgReq->Props.uHz, pCfgReq->Props.cChannels, pCfgReq->Props.cbSample * 8);
     175
     176            RTFileWrite(pStreamDbg->hFileTiming, szTimingInfo, cch, NULL);
     177        }
     178    }
     179    else
     180        LogRel(("VaKitAudio: Unable to retrieve temp dir: %Rrc\n", rc));
    192181    return rc;
    193182}
Note: See TracChangeset for help on using the changeset viewer.

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