VirtualBox

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


Ignore:
Timestamp:
Jun 16, 2017 2:01:05 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116172
Message:

Audio/DrvAudio.cpp: Added drvAudioDbgPCMDumpA() + dumping playback & capturing .PCM data when VBOX_AUDIO_DEBUG_DUMP_PCM_DATA is set.

File:
1 edited

Legend:

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

    r65742 r67441  
    137137
    138138# endif /* unused */
     139
     140static void drvAudioDbgPCMDumpA(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix, const void *pvData, size_t cbData);
    139141
    140142#ifdef LOG_ENABLED
     
    13161318                    break;
    13171319
     1320#ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
     1321                drvAudioDbgPCMDumpA(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "PlayNonInterleaved.pcm",
     1322                                    auBuf, cbPlayed);
     1323#endif
    13181324                AssertMsg(cbPlayed <= cbRead, ("Played more than available (%RU32 available but got %RU32)\n", cbRead, cbPlayed));
    13191325                AssertMsg(cbPlayed % 2 == 0,
     
    15961602        else if (cbCaptured)
    15971603        {
     1604#ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
     1605            drvAudioDbgPCMDumpA(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "CaptureNonInterleaved.pcm",
     1606                                auBuf, cbCaptured);
     1607#endif
    15981608            Assert(cbCaptured <= cbBuf);
    15991609            if (cbCaptured > cbBuf) /* Paranoia. */
     
    20592069}
    20602070#endif /* VBOX_WITH_AUDIO_ENUM */
     2071
     2072#ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
     2073/**
     2074 * Dumps (raw) PCM audio data into a file by appending.
     2075 *
     2076 * @returns IPRT status code.
     2077 * @param   pThis               Driver inststance.
     2078 * @param   pszPath             Path name to save file to. The path must exist.
     2079 * @param   pszFileName         File name suffix to use.
     2080 * @param   pvData              Pointer to PCM data to dump.
     2081 * @param   cbData              Size (in bytes) of PCM data to dump.
     2082 */
     2083static void drvAudioDbgPCMDumpA(PDRVAUDIO pThis,
     2084                                const char *pszPath, const char *pszSuffix, const void *pvData, size_t cbData)
     2085{
     2086    if (!pvData || !cbData)
     2087        return;
     2088
     2089    AssertPtr(pThis->pDrvIns);
     2090
     2091    char szFileName[64];
     2092    RTStrPrintf(szFileName, sizeof(szFileName), "drvAudio%RU32-%s", pThis->pDrvIns->iInstance, pszSuffix);
     2093
     2094    char szFilePath[RTPATH_MAX];
     2095    int rc2 = RTStrCopy(szFilePath, sizeof(szFilePath), pszPath);
     2096    AssertRC(rc2);
     2097    rc2 = RTPathAppend(szFilePath, sizeof(szFilePath), szFileName);
     2098    AssertRC(rc2);
     2099
     2100    RTFILE fh;
     2101    rc2 = RTFileOpen(&fh, szFilePath,
     2102                     RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
     2103    AssertRC(rc2);
     2104    if (RT_SUCCESS(rc2))
     2105    {
     2106        RTFileWrite(fh, pvData, cbData, NULL);
     2107        RTFileClose(fh);
     2108    }
     2109}
     2110#endif /* VBOX_AUDIO_DEBUG_DUMP_PCM_DATA */
    20612111
    20622112/**
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