VirtualBox

Changeset 87861 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Feb 24, 2021 3:04:02 PM (4 years ago)
Author:
vboxsync
Message:

Audio: Unified debug .WAV path file generation so that all data lands at the same place.

Location:
trunk/src/VBox/Devices/Audio
Files:
8 edited

Legend:

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

    r87857 r87861  
    15101510        DrvAudioHlpFileClose(pSink->Dbg.pFile);
    15111511
    1512         char szTemp[RTPATH_MAX];
    1513         int rc2 = RTPathTemp(szTemp, sizeof(szTemp));
     1512        char szName[64];
     1513        RTStrPrintf(szName, sizeof(szName), "MixerSink-%s", pSink->pszName);
     1514
     1515        char szFile[RTPATH_MAX];
     1516        int rc2 = DrvAudioHlpFileNameGet(szFile, RT_ELEMENTS(szFile), NULL /* Use temporary directory */, szName,
     1517                                         0 /* Instance */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE);
    15141518        if (RT_SUCCESS(rc2))
    15151519        {
    1516             /** @todo Sanitize sink name. */
    1517 
    1518             char szName[64];
    1519             RTStrPrintf(szName, sizeof(szName), "MixerSink-%s", pSink->pszName);
    1520 
    1521             char szFile[RTPATH_MAX];
    1522             rc2 = DrvAudioHlpFileNameGet(szFile, RT_ELEMENTS(szFile), szTemp, szName,
    1523                                          0 /* Instance */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE);
     1520            rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAGS_NONE,
     1521                                        &pSink->Dbg.pFile);
    15241522            if (RT_SUCCESS(rc2))
    1525             {
    1526                 rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAGS_NONE,
    1527                                             &pSink->Dbg.pFile);
    1528                 if (RT_SUCCESS(rc2))
    1529                     rc2 = DrvAudioHlpFileOpen(pSink->Dbg.pFile, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, &pSink->PCMProps);
    1530             }
     1523                rc2 = DrvAudioHlpFileOpen(pSink->Dbg.pFile, PDMAUDIOFILE_DEFAULT_OPEN_FLAGS, &pSink->PCMProps);
    15311524        }
    15321525    }
  • trunk/src/VBox/Devices/Audio/DevHDA.cpp

    r87852 r87861  
    29342934#  endif
    29352935
     2936#  ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    29362937            if (pThis->fDebugEnabled)
    29372938            {
     
    29422943                RTFileClose(fh);
    29432944            }
     2945#  endif
    29442946
    29452947#  ifdef HDA_USE_DMA_ACCESS_HANDLER_WRITING
     
    48234825                                N_("HDA configuration error: failed to read debugging enabled flag as boolean"));
    48244826
    4825     rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "DebugPathOut", &pThisCC->Dbg.pszOutPath, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     4827    rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "DebugPathOut", &pThisCC->Dbg.pszOutPath, NULL);
    48264828    if (RT_FAILURE(rc))
    48274829        return PDMDEV_SET_ERROR(pDevIns, rc,
  • trunk/src/VBox/Devices/Audio/DevHDA.h

    r87836 r87861  
    271271        bool                    fEnabled;
    272272        /** Path where to dump the debug output to.
    273          *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH. */
     273         *  Can be NULL, in which the system's temporary directory will be used then. */
    274274        R3PTRTYPE(char *)       pszOutPath;
    275275    } Dbg;
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r87852 r87861  
    525525    bool                    afAlignment[7];
    526526    /** Path where to dump the debug output to.
    527      *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH. */
     527     *  Can be NULL, in which the system's temporary directory will be used then. */
    528528    R3PTRTYPE(char *)       pszOutPath;
    529529} AC97STATEDEBUG;
     
    41774177                                N_("AC97 configuration error: failed to read debugging enabled flag as boolean"));
    41784178
    4179     rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "DebugPathOut", &pThisCC->Dbg.pszOutPath, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     4179    rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "DebugPathOut", &pThisCC->Dbg.pszOutPath, NULL);
    41804180    if (RT_FAILURE(rc))
    41814181        return PDMDEV_SET_ERROR(pDevIns, rc,
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r87854 r87861  
    23272327        || !strlen(pCfg->Dbg.szPathOut))
    23282328    {
    2329         RTStrPrintf(pCfg->Dbg.szPathOut, sizeof(pCfg->Dbg.szPathOut), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     2329        rc2 = RTPathTemp(pCfg->Dbg.szPathOut, sizeof(pCfg->Dbg.szPathOut));
     2330        if (RT_FAILURE(rc2))
     2331            LogRel(("Audio: Error retrieving temporary directory, rc=%Rrc\n", rc2));
    23302332    }
    23312333
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r87438 r87861  
    109109        /** Whether audio debugging is enabled or not. */
    110110        bool             fEnabled;
    111         /** Where to store the debugging files.
    112          *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH if not set. */
     111        /** Where to store the debugging files. */
    113112        char             szPathOut[RTPATH_MAX];
    114113    } Dbg;
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r87438 r87861  
    15021502 * @param   cchFile             Size (in characters) of the file name buffer.
    15031503 * @param   pszPath             Base path to use.
     1504 *                              If NULL or empty, the system's temporary directory will be used.
    15041505 * @param   pszName             A name for better identifying the file.
    15051506 * @param   uInstance           Device / driver instance which is using this file.
     
    15121513    AssertPtrReturn(pszFile, VERR_INVALID_POINTER);
    15131514    AssertReturn(cchFile,    VERR_INVALID_PARAMETER);
    1514     AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
     1515    /* pszPath can be NULL. */
    15151516    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
    15161517    /** @todo Validate fFlags. */
     
    15181519    int rc;
    15191520
     1521    char *pszPathTmp = NULL;
     1522
    15201523    do
    15211524    {
     1525        if (   pszPath == NULL
     1526            || !strlen(pszPath))
     1527        {
     1528            char szTemp[RTPATH_MAX];
     1529            rc = RTPathTemp(szTemp, sizeof(szTemp));
     1530            if (RT_SUCCESS(rc))
     1531            {
     1532                pszPathTmp = RTStrDup(szTemp);
     1533            }
     1534            else
     1535                break;
     1536        }
     1537        else
     1538            pszPathTmp = RTStrDup(pszPath);
     1539
     1540        AssertPtrBreakStmt(pszPathTmp, rc = VERR_NO_MEMORY);
     1541
    15221542        char szFilePath[RTPATH_MAX];
    1523         rc = RTStrCopy(szFilePath, sizeof(szFilePath), pszPath);
     1543        rc = RTStrCopy(szFilePath, sizeof(szFilePath), pszPathTmp);
    15241544        AssertRCBreak(rc);
    15251545
     
    15921612
    15931613    } while (0);
     1614
     1615    RTStrFree(pszPathTmp);
    15941616
    15951617    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp

    r87853 r87861  
    134134static int debugCreateFile(PDRVHOSTDEBUGAUDIO pDrv, PDEBUGAUDIOSTREAM pStreamDbg, bool fIn, PPDMAUDIOSTREAMCFG pCfg)
    135135{
    136     char szTemp[RTPATH_MAX];
    137     int rc = RTPathTemp(szTemp, sizeof(szTemp));
     136    char szFile[RTPATH_MAX];
     137    int rc = DrvAudioHlpFileNameGet(szFile, RT_ELEMENTS(szFile), NULL /* Use temporary directory */, fIn ? "DebugAudioIn" : "DebugAudioOut",
     138                                    pDrv->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE);
    138139    if (RT_SUCCESS(rc))
    139140    {
    140         char szFile[RTPATH_MAX];
    141         rc = DrvAudioHlpFileNameGet(szFile, RT_ELEMENTS(szFile), szTemp, fIn ? "DebugAudioIn" : "DebugAudioOut",
    142                                     pDrv->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAGS_NONE);
     141        rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAGS_NONE, &pStreamDbg->pFile);
    143142        if (RT_SUCCESS(rc))
    144143        {
    145             rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAGS_NONE, &pStreamDbg->pFile);
    146             if (RT_SUCCESS(rc))
    147             {
    148                 rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
    149                                          &pCfg->Props);
    150             }
    151 
    152             if (RT_FAILURE(rc))
    153                 LogRel(("DebugAudio: Creating %sput file '%s' failed with %Rrc\n", fIn ? "in" : "out", szFile, rc));
     144            rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
     145                                     &pCfg->Props);
    154146        }
    155         else
    156             LogRel(("DebugAudio: Unable to build file name for temp dir '%s': %Rrc\n", szTemp, rc));
     147
     148        if (RT_FAILURE(rc))
     149            LogRel(("DebugAudio: Creating %sput file '%s' failed with %Rrc\n", fIn ? "in" : "out", szFile, rc));
    157150    }
    158151    else
    159         LogRel(("DebugAudio: Unable to retrieve temp dir: %Rrc\n", rc));
     152        LogRel(("DebugAudio: Unable to build file name: %Rrc\n", rc));
    160153
    161154    return rc;
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