VirtualBox

Changeset 69956 in vbox


Ignore:
Timestamp:
Dec 6, 2017 12:28:48 PM (7 years ago)
Author:
vboxsync
Message:

Audio: Implemented support for dumping raw PCM data if debug mode is enabled.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmaudioifs.h

    r69686 r69956  
    148148 */
    149149
     150#ifndef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH
     151# ifdef RT_OS_WINDOWS
     152#  define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "c:\\temp\\"
     153# else
     154#  define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "/tmp/"
     155# endif
     156#endif
     157
    150158/** PDM audio driver instance flags. */
    151159typedef uint32_t PDMAUDIODRVFLAGS;
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r69119 r69956  
    138138# endif /* unused */
    139139
    140 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    141140static char *drvAudioDbgGetFileNameA(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix);
    142141static void  drvAudioDbgPCMDelete(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix);
    143142static void  drvAudioDbgPCMDump(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix, const void *pvData, size_t cbData);
    144 #endif
    145143
    146144#ifdef LOG_ENABLED
     
    967965        }
    968966
    969 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    970         drvAudioDbgPCMDump(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "StreamWrite.pcm", pvBuf, cbBuf);
    971 #endif
     967        if (pThis->fDebugEnabled)
     968            drvAudioDbgPCMDump(pThis, pThis->szDebugPathOut, "StreamWrite.pcm", pvBuf, cbBuf);
    972969
    973970#ifdef VBOX_WITH_STATISTICS
     
    13361333                }
    13371334
    1338 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    1339                 drvAudioDbgPCMDump(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "PlayNonInterleaved.pcm",
    1340                                    auBuf, cbPlayed);
    1341 #endif
     1335                if (pThis->fDebugEnabled)
     1336                    drvAudioDbgPCMDump(pThis, pThis->szDebugPathOut, "PlayNonInterleaved.pcm", auBuf, cbPlayed);
     1337
    13421338                AssertMsg(cbPlayed <= cbRead, ("Played more than available (%RU32 available but got %RU32)\n", cbRead, cbPlayed));
    13431339#if 0 /** @todo Also handle mono channels. Needs fixing */
     
    16391635        else if (cbCaptured)
    16401636        {
    1641 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    1642             drvAudioDbgPCMDump(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "CaptureNonInterleaved.pcm",
    1643                                auBuf, cbCaptured);
    1644 #endif
     1637            if (pThis->fDebugEnabled)
     1638                drvAudioDbgPCMDump(pThis, pThis->szDebugPathOut, "CaptureNonInterleaved.pcm", auBuf, cbCaptured);
     1639
    16451640            Assert(cbCaptured <= cbBuf);
    16461641            if (cbCaptured > cbBuf) /* Paranoia. */
     
    20952090#endif /* VBOX_WITH_AUDIO_ENUM */
    20962091
    2097 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    20982092/**
    20992093 * Returns an unique file name for this given audio connector instance.
     
    21672161    RTStrFree(pszFileName);
    21682162}
    2169 #endif /* VBOX_AUDIO_DEBUG_DUMP_PCM_DATA */
    21702163
    21712164/**
     
    23012294
    23022295    /* By default we don't enable anything if wrongly / not set-up. */
    2303     pThis->In.fEnabled  = false;
    2304     pThis->Out.fEnabled = false;
    2305 
    2306     uint64_t u64Temp;
    2307     rc2 = CFGMR3QueryInteger(pCfgHandle, "InputEnabled",  &u64Temp);
    2308     if (RT_SUCCESS(rc2))
    2309         pThis->In.fEnabled  = RT_BOOL(u64Temp);
    2310 
    2311     rc2 = CFGMR3QueryInteger(pCfgHandle, "OutputEnabled", &u64Temp);
    2312     if (RT_SUCCESS(rc2))
    2313         pThis->Out.fEnabled = RT_BOOL(u64Temp);
     2296    CFGMR3QueryBoolDef(pCfgHandle, "InputEnabled",  &pThis->In.fEnabled,   false);
     2297    CFGMR3QueryBoolDef(pCfgHandle, "OutputEnabled", &pThis->Out.fEnabled,  false);
     2298
     2299    CFGMR3QueryBoolDef(pCfgHandle, "DebugEnabled",      &pThis->fDebugEnabled,  false);
     2300    rc2 = CFGMR3QueryString(pCfgHandle, "DebugPathOut", pThis->szDebugPathOut, sizeof(pThis->szDebugPathOut));
     2301    if (RT_FAILURE(rc2))
     2302        RTStrPrintf(pThis->szDebugPathOut, sizeof(pThis->szDebugPathOut), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     2303
     2304    if (pThis->fDebugEnabled)
     2305        LogRel(("Audio: Debugging enabled (audio data written to '%s')\n", pThis->szDebugPathOut));
    23142306
    23152307    LogRel2(("Audio: Initial status for driver '%s': Input is %s, output is %s\n",
     
    24072399        if (cReadTotal)
    24082400        {
    2409 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    2410             drvAudioDbgPCMDump(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "StreamRead.pcm",
    2411                                pvBuf, AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cReadTotal));
    2412 #endif
     2401            if (pThis->fDebugEnabled)
     2402                drvAudioDbgPCMDump(pThis, pThis->szDebugPathOut, "StreamRead.pcm",
     2403                                   pvBuf, AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cReadTotal));
     2404
    24132405            AudioMixBufFinish(&pGstStream->MixBuf, cReadTotal);
    24142406
     
    33613353#endif
    33623354
    3363 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    3364         drvAudioDbgPCMDelete(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "StreamRead.pcm");
    3365         drvAudioDbgPCMDelete(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "StreamWrite.pcm");
    3366         drvAudioDbgPCMDelete(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "PlayNonInterleaved.pcm");
    3367         drvAudioDbgPCMDelete(pThis, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH, "CaptureNonInterleaved.pcm");
    3368 #endif
     3355        if (pThis->fDebugEnabled)
     3356        {
     3357            drvAudioDbgPCMDelete(pThis, pThis->szDebugPathOut, "StreamRead.pcm");
     3358            drvAudioDbgPCMDelete(pThis, pThis->szDebugPathOut, "StreamWrite.pcm");
     3359            drvAudioDbgPCMDelete(pThis, pThis->szDebugPathOut, "PlayNonInterleaved.pcm");
     3360            drvAudioDbgPCMDelete(pThis, pThis->szDebugPathOut, "CaptureNonInterleaved.pcm");
     3361        }
    33693362    }
    33703363
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r69119 r69956  
    2929#include <VBox/vmm/pdm.h>
    3030#include <VBox/vmm/pdmaudioifs.h>
    31 
    32 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    33 # ifdef RT_OS_WINDOWS
    34 #  define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "c:\\temp\\"
    35 # else
    36 #  define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "/tmp/"
    37 # endif
    38 #endif
    3931
    4032typedef enum
     
    115107    DRVAUDIOSTATS           Stats;
    116108#endif
     109    /** Whether audio debugging is enabled or not. */
     110    bool                    fDebugEnabled;
     111    /** Where to store the debugging files.
     112     *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH if not set. */
     113    char                    szDebugPathOut[RTPATH_MAX + 1];
    117114    struct
    118115    {
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r69054 r69956  
    7272#include <VBox/param.h>
    7373#include <VBox/vmm/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach. */
     74#include <VBox/vmm/pdmaudioifs.h>
    7475#include <VBox/vmm/pdmusb.h> /* For PDMR3UsbCreateEmulatedDevice. */
    7576#include <VBox/vmm/pdmdev.h> /* For PDMAPICMODE enum. */
     
    29062907            }
    29072908
     2909            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Debug/Enabled", &strTmp);
     2910            bool fDebugEnabled = strTmp.equalsIgnoreCase("true") || strTmp.equalsIgnoreCase("1");
     2911
     2912            Utf8Str strDebugPathOut;
     2913            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Debug/PathOut", &strDebugPathOut);
     2914            if (strDebugPathOut.isEmpty())
     2915                strDebugPathOut = VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH;
     2916
    29082917            /*
    29092918             * The audio driver.
     
    29802989            uint8_t u8AudioLUN = 0;
    29812990
     2991            BOOL fAudioEnabledIn = FALSE;
     2992            hrc = audioAdapter->COMGETTER(EnabledIn)(&fAudioEnabledIn);                     H();
     2993            BOOL fAudioEnabledOut = FALSE;
     2994            hrc = audioAdapter->COMGETTER(EnabledOut)(&fAudioEnabledOut);                   H();
     2995
    29822996            CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%RU8", u8AudioLUN++);
    29832997            InsertConfigString(pLunL0, "Driver", "AUDIO");
    29842998            InsertConfigNode(pLunL0,   "Config", &pCfg);
    29852999
    2986                 InsertConfigString(pCfg, "DriverName", strAudioDriver.c_str());
    2987 
    2988                 BOOL fAudioEnabledIn = FALSE;
    2989                 hrc = audioAdapter->COMGETTER(EnabledIn)(&fAudioEnabledIn);                     H();
     3000                InsertConfigString (pCfg, "DriverName",    strAudioDriver.c_str());
    29903001                InsertConfigInteger(pCfg, "InputEnabled",  fAudioEnabledIn);
    2991 
    2992                 BOOL fAudioEnabledOut = FALSE;
    2993                 hrc = audioAdapter->COMGETTER(EnabledOut)(&fAudioEnabledOut);                   H();
    29943002                InsertConfigInteger(pCfg, "OutputEnabled", fAudioEnabledOut);
     3003                InsertConfigInteger(pCfg, "DebugEnabled",  fDebugEnabled);
     3004                InsertConfigString (pCfg, "DebugPathOut",  strDebugPathOut);
    29953005
    29963006                InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
     
    30143024                InsertConfigInteger(pCfg, "InputEnabled",  fAudioEnabledIn);
    30153025                InsertConfigInteger(pCfg, "OutputEnabled", fAudioEnabledOut);
     3026                InsertConfigInteger(pCfg, "DebugEnabled",  fDebugEnabled);
     3027                InsertConfigString (pCfg, "DebugPathOut",  strDebugPathOut);
    30163028
    30173029            InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
     
    30363048            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Debug/Enabled", &strTmp);
    30373049
    3038             if (!strTmp.isEmpty())
    3039             {
    3040                 LogRel(("Audio: Debugging enabled\n"));
    3041 
     3050            if (fDebugEnabled)
     3051            {
    30423052#ifdef VBOX_WITH_AUDIO_DEBUG
    30433053                /*
     
    30503060                    InsertConfigInteger(pCfg, "InputEnabled",  fAudioEnabledIn);
    30513061                    InsertConfigInteger(pCfg, "OutputEnabled", fAudioEnabledOut);
     3062                    InsertConfigInteger(pCfg, "DebugEnabled",  fDebugEnabled);
     3063                    InsertConfigString (pCfg, "DebugPathOut",  strDebugPathOut);
    30523064
    30533065                InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
     
    30853097                InsertConfigInteger(pCfg, "InputEnabled",  fAudioEnabledIn);
    30863098                InsertConfigInteger(pCfg, "OutputEnabled", fAudioEnabledOut);
     3099                InsertConfigInteger(pCfg, "DebugEnabled",  fDebugEnabled);
     3100                InsertConfigString (pCfg, "DebugPathOut",  strDebugPathOut);
    30873101
    30883102            InsertConfigNode(pLunL0, "AttachedDriver", &pLunL1);
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