VirtualBox

Changeset 70013 in vbox


Ignore:
Timestamp:
Dec 8, 2017 11:52:00 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
119542
Message:

Audio: Unified audio debug / dumping code to also get device DMA data when enabled at runtime.

Location:
trunk
Files:
13 edited

Legend:

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

    r69956 r70013  
    137137#include <iprt/circbuf.h>
    138138#include <iprt/list.h>
     139#include <iprt/path.h>
    139140
    140141#include <VBox/types.h>
     
    741742    uint32_t                  cChildren;
    742743    /** Intermediate structure for buffer conversion tasks. */
    743     PPDMAUDIOSTREAMRATE         pRate;
     744    PPDMAUDIOSTREAMRATE       pRate;
    744745    /** Internal representation of current volume used for mixing. */
    745746    PDMAUDMIXBUFVOL           Volume;
     
    767768typedef uint32_t PDMAUDIOFILEFLAGS;
    768769
    769 /* No flags defined. */
    770 #define PDMAUDIOFILEFLAG_NONE            0
     770/** No flags defined. */
     771#define PDMAUDIOFILE_FLAG_NONE          0
     772/** Keep the audio file even if it contains no audio data. */
     773#define PDMAUDIOFILE_FLAG_KEEP_IF_EMPTY RT_BIT(0)
     774/** Audio file flag validation mask. */
     775#define PDMAUDIOFILE_FLAG_VALID_MASK    0x1
    771776
    772777/**
     
    777782    /** Unknown type, do not use. */
    778783    PDMAUDIOFILETYPE_UNKNOWN = 0,
     784    /** Raw (PCM) file. */
     785    PDMAUDIOFILETYPE_RAW,
    779786    /** Wave (.WAV) file. */
    780787    PDMAUDIOFILETYPE_WAV,
     
    783790} PDMAUDIOFILETYPE;
    784791
     792typedef uint32_t PDMAUDIOFILENAMEFLAGS;
     793
     794/** No flags defined. */
     795#define PDMAUDIOFILENAME_FLAG_NONE          0
     796/** Adds an ISO timestamp to the file name. */
     797#define PDMAUDIOFILENAME_FLAG_TS            RT_BIT(0)
     798
    785799/**
    786800 * Structure for an audio file handle.
     
    789803{
    790804    /** Type of the audio file. */
    791     PDMAUDIOFILETYPE enmType;
    792     /** File name. */
    793     char             szName[255];
     805    PDMAUDIOFILETYPE    enmType;
     806    /** Audio file flags. */
     807    PDMAUDIOFILEFLAGS   fFlags;
     808    /** File name and path. */
     809    char                szName[RTPATH_MAX + 1];
    794810    /** Actual file handle. */
    795     RTFILE           hFile;
     811    RTFILE              hFile;
    796812    /** Data needed for the specific audio file type implemented.
    797813     *  Optional, can be NULL. */
    798     void            *pvData;
     814    void               *pvData;
    799815    /** Data size (in bytes). */
    800     size_t           cbData;
     816    size_t              cbData;
    801817} PDMAUDIOFILE, *PPDMAUDIOFILE;
    802818
     
    875891    STAMCOUNTER StatFramesCaptured;
    876892#endif
     893    struct
     894    {
     895        /** File for writing stream reads. */
     896        PPDMAUDIOFILE           pFileStreamRead;
     897        /** File for writing non-interleaved captures. */
     898        PPDMAUDIOFILE           pFileCaptureNonInterleaved;
     899    } Dbg;
    877900} PDMAUDIOSTREAMIN, *PPDMAUDIOSTREAMIN;
    878901
     
    890913    STAMCOUNTER StatFramesPlayed;
    891914#endif
     915    struct
     916    {
     917        /** File for writing stream writes. */
     918        PPDMAUDIOFILE           pFileStreamWrite;
     919        /** File for writing stream playback. */
     920        PPDMAUDIOFILE           pFilePlayNonInterleaved;
     921    } Dbg;
    892922} PDMAUDIOSTREAMOUT, *PPDMAUDIOSTREAMOUT;
    893923
  • trunk/src/VBox/Devices/Audio/DevHDA.cpp

    r69948 r70013  
    28412841# endif
    28422842
    2843 # ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    2844             RTFILE fh;
    2845             RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaDMAAccessWrite.pcm",
    2846                        RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    2847             RTFileWrite(fh, pvBuf, cbBuf, NULL);
    2848             RTFileClose(fh);
    2849 # endif
     2843            if (pThis->fDebugEnabled)
     2844            {
     2845                RTFILE fh;
     2846                RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaDMAAccessWrite.pcm",
     2847                           RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
     2848                RTFileWrite(fh, pvBuf, cbBuf, NULL);
     2849                RTFileClose(fh);
     2850            }
    28502851
    28512852# ifdef HDA_USE_DMA_ACCESS_HANDLER_WRITING
     
    47574758                                    "TimerHz\0"
    47584759                                    "PosAdjustEnabled\0"
    4759                                     "PosAdjustFrames\0"))
     4760                                    "PosAdjustFrames\0"
     4761                                    "DebugEnabled\0"
     4762                                    "DebugPathOut\0"))
    47604763    {
    47614764        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
     
    47774780                                N_("HDA configuration error: failed to read Hertz (Hz) rate as unsigned integer"));
    47784781
    4779      if (pThis->u16TimerHz != HDA_TIMER_HZ_DEFAULT)
    4780          LogRel(("HDA: Using custom device timer rate (%RU16Hz)\n", pThis->u16TimerHz));
    4781 
    4782      rc = CFGMR3QueryBoolDef(pCfg, "PosAdjustEnabled", &pThis->fPosAdjustEnabled, true);
    4783      if (RT_FAILURE(rc))
    4784          return PDMDEV_SET_ERROR(pDevIns, rc,
     4782    if (pThis->u16TimerHz != HDA_TIMER_HZ_DEFAULT)
     4783        LogRel(("HDA: Using custom device timer rate (%RU16Hz)\n", pThis->u16TimerHz));
     4784
     4785    rc = CFGMR3QueryBoolDef(pCfg, "PosAdjustEnabled", &pThis->fPosAdjustEnabled, true);
     4786    if (RT_FAILURE(rc))
     4787        return PDMDEV_SET_ERROR(pDevIns, rc,
    47854788                                N_("HDA configuration error: failed to read position adjustment enabled as boolean"));
    47864789
    4787      if (!pThis->fPosAdjustEnabled)
    4788          LogRel(("HDA: Position adjustment is disabled\n"));
    4789 
    4790      rc = CFGMR3QueryU16Def(pCfg, "PosAdjustFrames", &pThis->cPosAdjustFrames, HDA_POS_ADJUST_DEFAULT);
    4791      if (RT_FAILURE(rc))
    4792          return PDMDEV_SET_ERROR(pDevIns, rc,
    4793                                  N_("HDA configuration error: failed to read position adjustment frames as unsigned integer"));
    4794 
    4795      if (pThis->cPosAdjustFrames)
    4796          LogRel(("HDA: Using custom position adjustment (%RU16 audio frames)\n", pThis->cPosAdjustFrames));
     4790    if (!pThis->fPosAdjustEnabled)
     4791        LogRel(("HDA: Position adjustment is disabled\n"));
     4792
     4793    rc = CFGMR3QueryU16Def(pCfg, "PosAdjustFrames", &pThis->cPosAdjustFrames, HDA_POS_ADJUST_DEFAULT);
     4794    if (RT_FAILURE(rc))
     4795        return PDMDEV_SET_ERROR(pDevIns, rc,
     4796                                N_("HDA configuration error: failed to read position adjustment frames as unsigned integer"));
     4797
     4798    if (pThis->cPosAdjustFrames)
     4799        LogRel(("HDA: Using custom position adjustment (%RU16 audio frames)\n", pThis->cPosAdjustFrames));
     4800
     4801    rc = CFGMR3QueryBoolDef(pCfg, "DebugEnabled", &pThis->Dbg.fEnabled, false);
     4802    if (RT_FAILURE(rc))
     4803        return PDMDEV_SET_ERROR(pDevIns, rc,
     4804                                N_("HDA configuration error: failed to read debugging enabled flag as boolean"));
     4805
     4806    rc = CFGMR3QueryStringDef(pCfg, "DebugPathOut", pThis->Dbg.szOutPath, sizeof(pThis->Dbg.szOutPath),
     4807                              VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     4808    if (RT_FAILURE(rc))
     4809        return PDMDEV_SET_ERROR(pDevIns, rc,
     4810                                N_("HDA configuration error: failed to read debugging output path flag as string"));
     4811
     4812    if (!strlen(pThis->Dbg.szOutPath))
     4813        RTStrPrintf(pThis->Dbg.szOutPath, sizeof(pThis->Dbg.szOutPath), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     4814
     4815    if (pThis->Dbg.fEnabled)
     4816        LogRel2(("HDA: Debug output will be saved to '%s'\n", pThis->Dbg.szOutPath));
    47974817
    47984818    /*
     
    50285048        for (uint8_t i = 0; i < HDA_MAX_STREAMS; ++i)
    50295049        {
    5030             rc = hdaStreamCreate(&pThis->aStreams[i], pThis);
     5050            rc = hdaStreamCreate(&pThis->aStreams[i], pThis, i /* u8SD */);
    50315051            AssertRC(rc);
    50325052        }
     
    52505270    }
    52515271# endif
    5252 
    5253 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    5254     RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaDMARead.pcm");
    5255     RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaDMAWrite.pcm");
    5256     RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaStreamRead.pcm");
    5257     RTFileDelete(VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaStreamWrite.pcm");
    5258 #endif
    52595272
    52605273    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/Devices/Audio/DevHDA.h

    r69919 r70013  
    2222*   Header Files                                                                                                                 *
    2323*********************************************************************************************************************************/
     24#include <iprt/path.h>
     25
    2426#include <VBox/vmm/pdmdev.h>
    2527
     
    100102        uint64_t                       tsDeassertedTotalNs;
    101103    } IRQ;
     104    /** Whether debugging is enabled or not. */
     105    bool                               fEnabled;
     106    /** Path where to dump the debug output to.
     107     *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH. */
     108    char                               szOutPath[RTPATH_MAX + 1];
    102109} HDASTATEDBGINFO, *PHDASTATEDBGINFO;
    103110#endif
     
    214221    /** Padding for alignment. */
    215222    uint8_t                            au8Padding3[3];
    216 #ifdef DEBUG
    217223    HDASTATEDBGINFO                    Dbg;
    218 #endif
    219224} HDASTATE, *PHDASTATE;
    220225#endif /* !DEV_HDA_H */
  • trunk/src/VBox/Devices/Audio/DevHDACommon.cpp

    r69919 r70013  
    2626#include <VBox/log.h>
    2727
     28#include "DrvAudio.h"
    2829
    2930#include "DevHDA.h"
     
    293294        }
    294295#endif
    295 
    296 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    297         RTFILE fh;
    298         int rc2 = RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaDMARead.pcm",
    299                              RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    300         if (RT_SUCCESS(rc2))
    301         {
    302             RTFileWrite(fh, (uint8_t *)pvBuf + cbReadTotal, cbChunk, NULL);
    303             RTFileClose(fh);
    304         }
    305         else
    306             AssertRC(rc2);
    307 #endif
     296        if (pStream->Dbg.Runtime.fEnabled)
     297            DrvAudioHlpFileWrite(pStream->Dbg.Runtime.pFileDMA, (uint8_t *)pvBuf + cbReadTotal, cbChunk, 0 /* fFlags */);
    308298
    309299#ifdef VBOX_WITH_STATISTICS
     
    375365        Assert((cbChunk >> 1) >= 1);
    376366
    377 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    378         RTFILE fh;
    379         RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaDMAWrite.pcm",
    380                    RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    381         RTFileWrite(fh, pvBuf, cbChunk, NULL);
    382         RTFileClose(fh);
    383 #endif
     367        if (pStream->Dbg.Runtime.fEnabled)
     368            DrvAudioHlpFileWrite(pStream->Dbg.Runtime.pFileDMA, (uint8_t *)pvBuf + cbWrittenTotal, cbChunk, 0 /* fFlags */);
     369
    384370        rc = PDMDevHlpPCIPhysWrite(pThis->CTX_SUFF(pDevIns),
    385371                                   addrChunk, (uint8_t *)pvBuf + cbWrittenTotal, cbChunk);
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r69956 r70013  
    137137
    138138# endif /* unused */
    139 
    140 static char *drvAudioDbgGetFileNameA(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix);
    141 static void  drvAudioDbgPCMDelete(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix);
    142 static void  drvAudioDbgPCMDump(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix, const void *pvData, size_t cbData);
    143139
    144140#ifdef LOG_ENABLED
     
    965961        }
    966962
    967         if (pThis->fDebugEnabled)
    968             drvAudioDbgPCMDump(pThis, pThis->szDebugPathOut, "StreamWrite.pcm", pvBuf, cbBuf);
     963        if (pThis->Dbg.fEnabled)
     964            DrvAudioHlpFileWrite(pHstStream->Out.Dbg.pFileStreamWrite, pvBuf, cbBuf, 0 /* fFlags */);
    969965
    970966#ifdef VBOX_WITH_STATISTICS
     
    13331329                }
    13341330
    1335                 if (pThis->fDebugEnabled)
    1336                     drvAudioDbgPCMDump(pThis, pThis->szDebugPathOut, "PlayNonInterleaved.pcm", auBuf, cbPlayed);
     1331                if (pThis->Dbg.fEnabled)
     1332                    DrvAudioHlpFileWrite(pHstStream->Out.Dbg.pFilePlayNonInterleaved, auBuf, cbPlayed, 0 /* fFlags */);
    13371333
    13381334                AssertMsg(cbPlayed <= cbRead, ("Played more than available (%RU32 available but got %RU32)\n", cbRead, cbPlayed));
     
    16351631        else if (cbCaptured)
    16361632        {
    1637             if (pThis->fDebugEnabled)
    1638                 drvAudioDbgPCMDump(pThis, pThis->szDebugPathOut, "CaptureNonInterleaved.pcm", auBuf, cbCaptured);
     1633            if (pThis->Dbg.fEnabled)
     1634                DrvAudioHlpFileWrite(pHstStream->In.Dbg.pFileCaptureNonInterleaved, auBuf, cbCaptured, 0 /* fFlags */);
    16391635
    16401636            Assert(cbCaptured <= cbBuf);
     
    20892085}
    20902086#endif /* VBOX_WITH_AUDIO_ENUM */
    2091 
    2092 /**
    2093  * Returns an unique file name for this given audio connector instance.
    2094  *
    2095  * @return  Allocated file name. Must be free'd using RTStrFree().
    2096  * @param   pThis               Driver instance.
    2097  * @param   pszPath             Path name of the file to delete. The path must exist.
    2098  * @param   pszSuffix           File name suffix to use.
    2099  */
    2100 static char *drvAudioDbgGetFileNameA(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix)
    2101 {
    2102     char szFileName[64];
    2103     RTStrPrintf(szFileName, sizeof(szFileName), "drvAudio%RU32-%s", pThis->pDrvIns->iInstance, pszSuffix);
    2104 
    2105     char szFilePath[RTPATH_MAX];
    2106     int rc2 = RTStrCopy(szFilePath, sizeof(szFilePath), pszPath);
    2107     AssertRC(rc2);
    2108     rc2 = RTPathAppend(szFilePath, sizeof(szFilePath), szFileName);
    2109     AssertRC(rc2);
    2110 
    2111     return RTStrDup(szFilePath);
    2112 }
    2113 
    2114 /**
    2115  * Deletes a PCM audio dump file.
    2116  *
    2117  * @param   pThis               Driver instance.
    2118  * @param   pszPath             Path name of the file to delete. The path must exist.
    2119  * @param   pszSuffix           File name suffix to use.
    2120  */
    2121 static void drvAudioDbgPCMDelete(PDRVAUDIO pThis, const char *pszPath, const char *pszSuffix)
    2122 {
    2123     char *pszFileName = drvAudioDbgGetFileNameA(pThis, pszPath, pszSuffix);
    2124     AssertPtr(pszFileName);
    2125 
    2126     RTFileDelete(pszFileName);
    2127 
    2128     RTStrFree(pszFileName);
    2129 }
    2130 
    2131 /**
    2132  * Dumps (raw) PCM audio data into a file by appending.
    2133  * Every driver instance will have an own prefix to not introduce writing races.
    2134  *
    2135  * @param   pThis               Driver instance.
    2136  * @param   pszPath             Path name to save file to. The path must exist.
    2137  * @param   pszSuffix           File name suffix to use.
    2138  * @param   pvData              Pointer to PCM data to dump.
    2139  * @param   cbData              Size (in bytes) of PCM data to dump.
    2140  */
    2141 static void drvAudioDbgPCMDump(PDRVAUDIO pThis,
    2142                                const char *pszPath, const char *pszSuffix, const void *pvData, size_t cbData)
    2143 {
    2144     if (!pvData || !cbData)
    2145         return;
    2146 
    2147     AssertPtr(pThis->pDrvIns);
    2148 
    2149     char *pszFileName = drvAudioDbgGetFileNameA(pThis, pszPath, pszSuffix);
    2150     AssertPtr(pszFileName);
    2151 
    2152     RTFILE fh;
    2153     int rc2 = RTFileOpen(&fh, pszFileName, RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    2154     AssertRC(rc2);
    2155     if (RT_SUCCESS(rc2))
    2156     {
    2157         RTFileWrite(fh, pvData, cbData, NULL);
    2158         RTFileClose(fh);
    2159     }
    2160 
    2161     RTStrFree(pszFileName);
    2162 }
    21632087
    21642088/**
     
    22972221    CFGMR3QueryBoolDef(pCfgHandle, "OutputEnabled", &pThis->Out.fEnabled,  false);
    22982222
    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));
     2223    CFGMR3QueryBoolDef(pCfgHandle, "DebugEnabled",      &pThis->Dbg.fEnabled,  false);
     2224    rc2 = CFGMR3QueryString(pCfgHandle, "DebugPathOut", pThis->Dbg.szPathOut, sizeof(pThis->Dbg.szPathOut));
     2225    if (   RT_FAILURE(rc2)
     2226        || !strlen(pThis->Dbg.szPathOut))
     2227    {
     2228        RTStrPrintf(pThis->Dbg.szPathOut, sizeof(pThis->Dbg.szPathOut), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     2229    }
     2230
     2231    if (pThis->Dbg.fEnabled)
     2232        LogRel(("Audio: Debugging enabled (audio data written to '%s')\n", pThis->Dbg.szPathOut));
    23062233
    23072234    LogRel2(("Audio: Initial status for driver '%s': Input is %s, output is %s\n",
     
    23992326        if (cReadTotal)
    24002327        {
    2401             if (pThis->fDebugEnabled)
    2402                 drvAudioDbgPCMDump(pThis, pThis->szDebugPathOut, "StreamRead.pcm",
    2403                                    pvBuf, AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cReadTotal));
     2328            if (pThis->Dbg.fEnabled)
     2329                DrvAudioHlpFileWrite(pHstStream->In.Dbg.pFileStreamRead,
     2330                                     pvBuf, AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cReadTotal), 0 /* fFlags */);
    24042331
    24052332            AudioMixBufFinish(&pGstStream->MixBuf, cReadTotal);
     
    26302557        if (pCfgHost->enmDir == PDMAUDIODIR_IN)
    26312558        {
     2559            if (pThis->Dbg.fEnabled)
     2560            {
     2561                char szFile[RTPATH_MAX + 1];
     2562
     2563                int rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Dbg.szPathOut, "CaptureNonInterleaved",
     2564                                                 pThis->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
     2565                if (RT_SUCCESS(rc2))
     2566                {
     2567                    rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE,
     2568                                                &pHstStrm->In.Dbg.pFileCaptureNonInterleaved);
     2569                    if (RT_SUCCESS(rc2))
     2570                        rc2 = DrvAudioHlpFileOpen(pHstStrm->In.Dbg.pFileCaptureNonInterleaved,
     2571                                                  RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE, &pHstStrm->Cfg.Props);
     2572                }
     2573
     2574                if (RT_SUCCESS(rc2))
     2575                {
     2576                    rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Dbg.szPathOut, "StreamRead",
     2577                                                 pThis->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
     2578                    if (RT_SUCCESS(rc2))
     2579                    {
     2580                        rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE,
     2581                                                    &pHstStrm->In.Dbg.pFileStreamRead);
     2582                        if (RT_SUCCESS(rc2))
     2583                            rc2 = DrvAudioHlpFileOpen(pHstStrm->In.Dbg.pFileStreamRead,
     2584                                                      RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE, &pHstStrm->Cfg.Props);
     2585                    }
     2586                }
     2587            }
     2588
    26322589            if (pThis->In.cStreamsFree)
    26332590                pThis->In.cStreamsFree--;
     
    26352592        else /* Out */
    26362593        {
     2594            if (pThis->Dbg.fEnabled)
     2595            {
     2596                char szFile[RTPATH_MAX + 1];
     2597
     2598                int rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Dbg.szPathOut, "PlayNonInterleaved",
     2599                                                 pThis->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
     2600                if (RT_SUCCESS(rc2))
     2601                {
     2602                    rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE,
     2603                                                &pHstStrm->Out.Dbg.pFilePlayNonInterleaved);
     2604                    if (RT_SUCCESS(rc2))
     2605                        rc = DrvAudioHlpFileOpen(pHstStrm->Out.Dbg.pFilePlayNonInterleaved,
     2606                                                 RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE, &pHstStrm->Cfg.Props);
     2607                }
     2608
     2609                if (RT_SUCCESS(rc2))
     2610                {
     2611                    rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Dbg.szPathOut, "StreamWrite",
     2612                                                 pThis->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
     2613                    if (RT_SUCCESS(rc2))
     2614                    {
     2615                        rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE,
     2616                                                    &pHstStrm->Out.Dbg.pFileStreamWrite);
     2617                        if (RT_SUCCESS(rc2))
     2618                            rc2 = DrvAudioHlpFileOpen(pHstStrm->Out.Dbg.pFileStreamWrite,
     2619                                                      RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE, &pHstStrm->Cfg.Props);
     2620                    }
     2621                }
     2622            }
     2623
    26372624            if (pThis->Out.cStreamsFree)
    26382625                pThis->Out.cStreamsFree--;
     
    29632950            if (RT_SUCCESS(rc))
    29642951            {
    2965 #ifdef VBOX_WITH_STATISTICS
    29662952                if (pHstStream->enmDir == PDMAUDIODIR_IN)
    29672953                {
     2954#ifdef VBOX_WITH_STATISTICS
    29682955                    PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pHstStream->In.StatFramesCaptured);
     2956#endif
     2957                    if (pThis->Dbg.fEnabled)
     2958                    {
     2959                        DrvAudioHlpFileDestroy(pHstStream->In.Dbg.pFileCaptureNonInterleaved);
     2960                        DrvAudioHlpFileDestroy(pHstStream->In.Dbg.pFileStreamRead);
     2961                    }
    29692962                }
    29702963                else if (pHstStream->enmDir == PDMAUDIODIR_OUT)
    29712964                {
     2965#ifdef VBOX_WITH_STATISTICS
    29722966                    PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pHstStream->Out.StatFramesPlayed);
     2967#endif
     2968                    if (pThis->Dbg.fEnabled)
     2969                    {
     2970                        DrvAudioHlpFileDestroy(pHstStream->Out.Dbg.pFilePlayNonInterleaved);
     2971                        DrvAudioHlpFileDestroy(pHstStream->Out.Dbg.pFileStreamWrite);
     2972                    }
    29732973                }
    29742974                else
    29752975                    AssertFailed();
    2976 #endif
     2976
    29772977                RTListNodeRemove(&pHstStream->Node);
    29782978
     
    33523352                                     STAMUNIT_NS_PER_CALL, "Profiling of output data processing.");
    33533353#endif
    3354 
    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         }
    33623354    }
    33633355
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r69956 r70013  
    107107    DRVAUDIOSTATS           Stats;
    108108#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];
    114109    struct
    115110    {
     
    131126        /** Max. number of free output streams.
    132127         *  UINT32_MAX for unlimited streams. */
    133     uint32_t                cStreamsFree;
     128        uint32_t            cStreamsFree;
    134129#ifdef VBOX_WITH_AUDIO_CALLBACKS
    135130        RTLISTANCHOR        lstCB;
    136131#endif
    137132    } Out;
     133    struct
     134    {
     135        /** Whether audio debugging is enabled or not. */
     136        bool                    fEnabled;
     137        /** Where to store the debugging files.
     138         *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH if not set. */
     139        char                    szPathOut[RTPATH_MAX + 1];
     140    } Dbg;
    138141} DRVAUDIO, *PDRVAUDIO;
    139142
     
    164167
    165168int DrvAudioHlpSanitizeFileName(char *pszPath, size_t cbPath);
    166 int DrvAudioHlpGetFileName(char *pszFile, size_t cchFile, const char *pszPath, const char *pszName, PDMAUDIOFILETYPE enmType);
     169int DrvAudioHlpGetFileName(char *pszFile, size_t cchFile, const char *pszPath, const char *pszName, uint32_t uInstance, PDMAUDIOFILETYPE enmType, PDMAUDIOFILENAMEFLAGS fFlags);
    167170
    168171PPDMAUDIODEVICE DrvAudioHlpDeviceAlloc(size_t cbData);
     
    185188char *DrvAudioHlpAudDevFlagsToStrA(PDMAUDIODEVFLAG fFlags);
    186189
    187 int DrvAudioHlpWAVFileOpen(PPDMAUDIOFILE pFile, const char *pszFile, uint32_t fOpen, const PPDMAUDIOPCMPROPS pProps, PDMAUDIOFILEFLAGS fFlags);
    188 int DrvAudioHlpWAVFileClose(PPDMAUDIOFILE pFile);
    189 size_t DrvAudioHlpWAVFileGetDataSize(PPDMAUDIOFILE pFile);
    190 int DrvAudioHlpWAVFileWrite(PPDMAUDIOFILE pFile, const void *pvBuf, size_t cbBuf, uint32_t fFlags);
     190int DrvAudioHlpFileCreate(PDMAUDIOFILETYPE enmType, const char *pszFile, PDMAUDIOFILEFLAGS fFlags, PPDMAUDIOFILE *ppFile);
     191void DrvAudioHlpFileDestroy(PPDMAUDIOFILE pFile);
     192int DrvAudioHlpFileOpen(PPDMAUDIOFILE pFile, uint32_t fOpen, const PPDMAUDIOPCMPROPS pProps);
     193int DrvAudioHlpFileClose(PPDMAUDIOFILE pFile);
     194int DrvAudioHlpFileDelete(PPDMAUDIOFILE pFile);
     195size_t DrvAudioHlpFileGetDataSize(PPDMAUDIOFILE pFile);
     196int DrvAudioHlpFileWrite(PPDMAUDIOFILE pFile, const void *pvBuf, size_t cbBuf, uint32_t fFlags);
    191197
    192198#define AUDIO_MAKE_FOURCC(c0, c1, c2, c3) RT_H2LE_U32_C(RT_MAKE_U32_FROM_U8(c0, c1, c2, c3))
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r69288 r70013  
    195195        }
    196196    }
     197}
     198
     199/**
     200 * Returns an unique file name for this given audio connector instance.
     201 *
     202 * @return  Allocated file name. Must be free'd using RTStrFree().
     203 * @param   uInstance           Driver / device instance.
     204 * @param   pszPath             Path name of the file to delete. The path must exist.
     205 * @param   pszSuffix           File name suffix to use.
     206 */
     207char *DrvAudioDbgGetFileNameA(uint8_t uInstance, const char *pszPath, const char *pszSuffix)
     208{
     209    char szFileName[64];
     210    RTStrPrintf(szFileName, sizeof(szFileName), "drvAudio%RU8-%s", uInstance, pszSuffix);
     211
     212    char szFilePath[RTPATH_MAX];
     213    int rc2 = RTStrCopy(szFilePath, sizeof(szFilePath), pszPath);
     214    AssertRC(rc2);
     215    rc2 = RTPathAppend(szFilePath, sizeof(szFilePath), szFileName);
     216    AssertRC(rc2);
     217
     218    return RTStrDup(szFilePath);
    197219}
    198220
     
    10521074 * @param   cchFile             Size (in characters) of the file name buffer.
    10531075 * @param   pszPath             Base path to use.
    1054  * @param   pszName             A name for better identifying the file. Optional.
     1076 * @param   pszName             A name for better identifying the file.
     1077 * @param   uInstance           Device / driver instance which is using this file.
    10551078 * @param   enmType             Audio file type to construct file name for.
    1056  */
    1057 int DrvAudioHlpGetFileName(char *pszFile, size_t cchFile, const char *pszPath, const char *pszName, PDMAUDIOFILETYPE enmType)
     1079 * @param   fFlags              File naming flags.
     1080 */
     1081int DrvAudioHlpGetFileName(char *pszFile, size_t cchFile, const char *pszPath, const char *pszName,
     1082                           uint32_t uInstance, PDMAUDIOFILETYPE enmType, PDMAUDIOFILENAMEFLAGS fFlags)
    10581083{
    10591084    AssertPtrReturn(pszFile, VERR_INVALID_POINTER);
    10601085    AssertReturn(cchFile,    VERR_INVALID_PARAMETER);
    10611086    AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
    1062     /* pszName is optional. */
     1087    AssertPtrReturn(pszName, VERR_INVALID_POINTER);
     1088    /** @todo Validate fFlags. */
    10631089
    10641090    int rc;
     
    10661092    do
    10671093    {
    1068         char szFilePath[RTPATH_MAX];
    1069         RTStrPrintf(szFilePath, sizeof(szFilePath), "%s", pszPath);
     1094        char szFilePath[RTPATH_MAX + 1];
     1095        RTStrPrintf2(szFilePath, sizeof(szFilePath), "%s", pszPath);
    10701096
    10711097        /* Create it when necessary. */
     
    10771103        }
    10781104
    1079         /* The actually drop directory consist of the current time stamp and a
    1080          * unique number when necessary. */
    1081         char pszTime[64];
    1082         RTTIMESPEC time;
    1083         if (!RTTimeSpecToString(RTTimeNow(&time), pszTime, sizeof(pszTime)))
    1084         {
    1085             rc = VERR_BUFFER_OVERFLOW;
    1086             break;
    1087         }
    1088 
    1089         rc = DrvAudioHlpSanitizeFileName(pszTime, sizeof(pszTime));
    1090         if (RT_FAILURE(rc))
    1091             break;
    1092 
    1093         rc = RTPathAppend(szFilePath, sizeof(szFilePath), pszTime);
    1094         if (RT_FAILURE(rc))
    1095             break;
    1096 
    1097         if (pszName) /* Optional name given? */
    1098         {
     1105        if (fFlags & PDMAUDIOFILENAME_FLAG_TS)
     1106        {
     1107            char szTime[64];
     1108            RTTIMESPEC time;
     1109            if (!RTTimeSpecToString(RTTimeNow(&time), szTime, sizeof(szTime)))
     1110            {
     1111                rc = VERR_BUFFER_OVERFLOW;
     1112                break;
     1113            }
     1114
     1115            rc = DrvAudioHlpSanitizeFileName(szTime, sizeof(szTime));
     1116            if (RT_FAILURE(rc))
     1117                break;
     1118
     1119            rc = RTStrCat(szFilePath, sizeof(szFilePath), szTime);
     1120            if (RT_FAILURE(rc))
     1121                break;
     1122
    10991123            rc = RTStrCat(szFilePath, sizeof(szFilePath), "-");
    11001124            if (RT_FAILURE(rc))
    11011125                break;
    1102 
    1103             rc = RTStrCat(szFilePath, sizeof(szFilePath), pszName);
    1104             if (RT_FAILURE(rc))
     1126        }
     1127
     1128        rc = RTStrCat(szFilePath, sizeof(szFilePath), pszName);
     1129        if (RT_FAILURE(rc))
     1130            break;
     1131
     1132        rc = RTStrCat(szFilePath, sizeof(szFilePath), "-");
     1133        if (RT_FAILURE(rc))
     1134            break;
     1135
     1136        char szInst[16];
     1137        RTStrPrintf2(szInst, sizeof(szInst), "%RU32", uInstance);
     1138        rc = RTStrCat(szFilePath, sizeof(szFilePath), szInst);
     1139        if (RT_FAILURE(rc))
     1140            break;
     1141
     1142        switch (enmType)
     1143        {
     1144            case PDMAUDIOFILETYPE_RAW:
     1145                rc = RTStrCat(szFilePath, sizeof(szFilePath), ".pcm");
    11051146                break;
    1106         }
    1107 
    1108         switch (enmType)
    1109         {
     1147
    11101148            case PDMAUDIOFILETYPE_WAV:
    11111149                rc = RTStrCat(szFilePath, sizeof(szFilePath), ".wav");
     
    11141152            default:
    11151153                AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     1154                break;
    11161155        }
    11171156
     
    11191158            break;
    11201159
    1121         RTStrPrintf(pszFile, cchFile, "%s", szFilePath);
     1160        RTStrPrintf2(pszFile, cchFile, "%s", szFilePath);
    11221161
    11231162    } while (0);
     
    11281167
    11291168/**
    1130  * Opens or creates a wave (.WAV) file.
     1169 * Creates an audio file.
     1170 *
     1171 * @returns IPRT status code.
     1172 * @param   enmType             Audio file type to open / create.
     1173 * @param   pszFile             File path of file to open or create.
     1174 * @param   fFlags              Audio file flags.
     1175 * @param   ppFile              Where to store the created audio file handle.
     1176 *                              Needs to be destroyed with DrvAudioHlpFileDestroy().
     1177 */
     1178int DrvAudioHlpFileCreate(PDMAUDIOFILETYPE enmType, const char *pszFile, PDMAUDIOFILEFLAGS fFlags, PPDMAUDIOFILE *ppFile)
     1179{
     1180    AssertPtrReturn(pszFile, VERR_INVALID_POINTER);
     1181    /** @todo Validate fFlags. */
     1182
     1183    PPDMAUDIOFILE pFile = (PPDMAUDIOFILE)RTMemAlloc(sizeof(PDMAUDIOFILE));
     1184    if (!pFile)
     1185        return VERR_NO_MEMORY;
     1186
     1187    int rc = VINF_SUCCESS;
     1188
     1189    switch (enmType)
     1190    {
     1191        case PDMAUDIOFILETYPE_RAW:
     1192        case PDMAUDIOFILETYPE_WAV:
     1193            pFile->enmType = enmType;
     1194            break;
     1195
     1196        default:
     1197            rc = VERR_INVALID_PARAMETER;
     1198            break;
     1199    }
     1200
     1201    if (RT_SUCCESS(rc))
     1202    {
     1203        RTStrPrintf(pFile->szName, RT_ELEMENTS(pFile->szName), "%s", pszFile);
     1204        pFile->fFlags = fFlags;
     1205    }
     1206
     1207    if (RT_FAILURE(rc))
     1208    {
     1209        RTMemFree(pFile);
     1210        pFile = NULL;
     1211    }
     1212    else
     1213        *ppFile = pFile;
     1214
     1215    return rc;
     1216}
     1217
     1218/**
     1219 * Destroys a formerly created audio file.
     1220 *
     1221 * @param   pFile               Audio file (object) to destroy.
     1222 */
     1223void DrvAudioHlpFileDestroy(PPDMAUDIOFILE pFile)
     1224{
     1225    if (!pFile)
     1226        return;
     1227
     1228    DrvAudioHlpFileClose(pFile);
     1229
     1230    RTMemFree(pFile);
     1231    pFile = NULL;
     1232}
     1233
     1234/**
     1235 * Opens or creates an audio file.
    11311236 *
    11321237 * @returns IPRT status code.
    11331238 * @param   pFile               Pointer to audio file handle to use.
    1134  * @param   pszFile             File path of file to open or create.
    11351239 * @param   fOpen               Open flags.
    11361240 * @param   pProps              PCM properties to use.
    1137  * @param   fFlags              Audio file flags.
    1138  */
    1139 int DrvAudioHlpWAVFileOpen(PPDMAUDIOFILE pFile, const char *pszFile, uint32_t fOpen, const PPDMAUDIOPCMPROPS pProps,
    1140                            PDMAUDIOFILEFLAGS fFlags)
     1241 */
     1242int DrvAudioHlpFileOpen(PPDMAUDIOFILE pFile, uint32_t fOpen, const PPDMAUDIOPCMPROPS pProps)
    11411243{
    11421244    AssertPtrReturn(pFile,   VERR_INVALID_POINTER);
    1143     AssertPtrReturn(pszFile, VERR_INVALID_POINTER);
    11441245    /** @todo Validate fOpen flags. */
    11451246    AssertPtrReturn(pProps,  VERR_INVALID_POINTER);
    1146     RT_NOREF(fFlags); /** @todo Validate fFlags flags. */
    1147 
    1148     Assert(pProps->cChannels);
    1149     Assert(pProps->uHz);
    1150     Assert(pProps->cBits);
    1151 
    1152     pFile->pvData = (PAUDIOWAVFILEDATA)RTMemAllocZ(sizeof(AUDIOWAVFILEDATA));
    1153     if (!pFile->pvData)
    1154         return VERR_NO_MEMORY;
    1155     pFile->cbData = sizeof(PAUDIOWAVFILEDATA);
    1156 
    1157     PAUDIOWAVFILEDATA pData = (PAUDIOWAVFILEDATA)pFile->pvData;
    1158     AssertPtr(pData);
    1159 
    1160     /* Header. */
    1161     pData->Hdr.u32RIFF          = AUDIO_MAKE_FOURCC('R','I','F','F');
    1162     pData->Hdr.u32Size          = 36;
    1163     pData->Hdr.u32WAVE          = AUDIO_MAKE_FOURCC('W','A','V','E');
    1164 
    1165     pData->Hdr.u32Fmt           = AUDIO_MAKE_FOURCC('f','m','t',' ');
    1166     pData->Hdr.u32Size1         = 16; /* Means PCM. */
    1167     pData->Hdr.u16AudioFormat   = 1;  /* PCM, linear quantization. */
    1168     pData->Hdr.u16NumChannels   = pProps->cChannels;
    1169     pData->Hdr.u32SampleRate    = pProps->uHz;
    1170     pData->Hdr.u32ByteRate      = DrvAudioHlpCalcBitrate(pProps->cBits, pProps->uHz, pProps->cChannels) / 8;
    1171     pData->Hdr.u16BlockAlign    = pProps->cChannels * pProps->cBits / 8;
    1172     pData->Hdr.u16BitsPerSample = pProps->cBits;
    1173 
    1174     /* Data chunk. */
    1175     pData->Hdr.u32ID2           = AUDIO_MAKE_FOURCC('d','a','t','a');
    1176     pData->Hdr.u32Size2         = 0;
    1177 
    1178     int rc = RTFileOpen(&pFile->hFile, pszFile, fOpen);
     1247
     1248    int rc;
     1249
     1250    if (pFile->enmType == PDMAUDIOFILETYPE_RAW)
     1251    {
     1252        rc = RTFileOpen(&pFile->hFile, pFile->szName, fOpen);
     1253    }
     1254    else if (pFile->enmType == PDMAUDIOFILETYPE_WAV)
     1255    {
     1256        Assert(pProps->cChannels);
     1257        Assert(pProps->uHz);
     1258        Assert(pProps->cBits);
     1259
     1260        pFile->pvData = (PAUDIOWAVFILEDATA)RTMemAllocZ(sizeof(AUDIOWAVFILEDATA));
     1261        if (pFile->pvData)
     1262        {
     1263            pFile->cbData = sizeof(PAUDIOWAVFILEDATA);
     1264
     1265            PAUDIOWAVFILEDATA pData = (PAUDIOWAVFILEDATA)pFile->pvData;
     1266            AssertPtr(pData);
     1267
     1268            /* Header. */
     1269            pData->Hdr.u32RIFF          = AUDIO_MAKE_FOURCC('R','I','F','F');
     1270            pData->Hdr.u32Size          = 36;
     1271            pData->Hdr.u32WAVE          = AUDIO_MAKE_FOURCC('W','A','V','E');
     1272
     1273            pData->Hdr.u32Fmt           = AUDIO_MAKE_FOURCC('f','m','t',' ');
     1274            pData->Hdr.u32Size1         = 16; /* Means PCM. */
     1275            pData->Hdr.u16AudioFormat   = 1;  /* PCM, linear quantization. */
     1276            pData->Hdr.u16NumChannels   = pProps->cChannels;
     1277            pData->Hdr.u32SampleRate    = pProps->uHz;
     1278            pData->Hdr.u32ByteRate      = DrvAudioHlpCalcBitrate(pProps->cBits, pProps->uHz, pProps->cChannels) / 8;
     1279            pData->Hdr.u16BlockAlign    = pProps->cChannels * pProps->cBits / 8;
     1280            pData->Hdr.u16BitsPerSample = pProps->cBits;
     1281
     1282            /* Data chunk. */
     1283            pData->Hdr.u32ID2           = AUDIO_MAKE_FOURCC('d','a','t','a');
     1284            pData->Hdr.u32Size2         = 0;
     1285
     1286            rc = RTFileOpen(&pFile->hFile, pFile->szName, fOpen);
     1287            if (RT_SUCCESS(rc))
     1288            {
     1289                rc = RTFileWrite(pFile->hFile, &pData->Hdr, sizeof(pData->Hdr), NULL);
     1290                if (RT_FAILURE(rc))
     1291                {
     1292                    RTFileClose(pFile->hFile);
     1293                    pFile->hFile = NIL_RTFILE;
     1294                }
     1295            }
     1296
     1297            if (RT_FAILURE(rc))
     1298            {
     1299                RTMemFree(pFile->pvData);
     1300                pFile->pvData = NULL;
     1301                pFile->cbData = 0;
     1302            }
     1303        }
     1304        else
     1305            rc = VERR_NO_MEMORY;
     1306    }
     1307    else
     1308        rc = VERR_INVALID_PARAMETER;
     1309
    11791310    if (RT_SUCCESS(rc))
    11801311    {
    1181         rc = RTFileWrite(pFile->hFile, &pData->Hdr, sizeof(pData->Hdr), NULL);
    1182         if (RT_FAILURE(rc))
    1183         {
    1184             RTFileClose(pFile->hFile);
    1185             pFile->hFile = NIL_RTFILE;
    1186         }
    1187     }
    1188 
    1189     if (RT_SUCCESS(rc))
    1190     {
    1191         pFile->enmType = PDMAUDIOFILETYPE_WAV;
    1192 
    1193         RTStrPrintf(pFile->szName, RT_ELEMENTS(pFile->szName), "%s", pszFile);
     1312        LogRel2(("Audio: Opened file '%s'\n", pFile->szName));
    11941313    }
    11951314    else
    1196     {
    1197         RTMemFree(pFile->pvData);
    1198         pFile->pvData = NULL;
    1199         pFile->cbData = 0;
    1200     }
     1315        LogRel(("Audio: Failed opening file '%s', rc=%Rrc\n", pFile->szName, rc));
    12011316
    12021317    return rc;
     
    12041319
    12051320/**
    1206  * Closes a wave (.WAV) audio file.
     1321 * Closes an audio file.
    12071322 *
    12081323 * @returns IPRT status code.
    12091324 * @param   pFile               Audio file handle to close.
    12101325 */
    1211 int DrvAudioHlpWAVFileClose(PPDMAUDIOFILE pFile)
     1326int DrvAudioHlpFileClose(PPDMAUDIOFILE pFile)
    12121327{
    12131328    AssertPtrReturn(pFile, VERR_INVALID_POINTER);
    12141329
    1215     Assert(pFile->enmType == PDMAUDIOFILETYPE_WAV);
    1216 
    1217     if (pFile->hFile != NIL_RTFILE)
     1330    size_t cbSize = DrvAudioHlpFileGetDataSize(pFile);
     1331
     1332    int rc;
     1333
     1334    if (pFile->enmType == PDMAUDIOFILETYPE_RAW)
     1335    {
     1336        if (pFile->hFile != NIL_RTFILE)
     1337        {
     1338            rc = RTFileClose(pFile->hFile);
     1339            pFile->hFile = NIL_RTFILE;
     1340        }
     1341    }
     1342    else if (pFile->enmType == PDMAUDIOFILETYPE_WAV)
     1343    {
     1344        if (pFile->hFile != NIL_RTFILE)
     1345        {
     1346            PAUDIOWAVFILEDATA pData = (PAUDIOWAVFILEDATA)pFile->pvData;
     1347            AssertPtr(pData);
     1348
     1349            /* Update the header with the current data size. */
     1350            RTFileWriteAt(pFile->hFile, 0, &pData->Hdr, sizeof(pData->Hdr), NULL);
     1351
     1352            rc = RTFileClose(pFile->hFile);
     1353            pFile->hFile = NIL_RTFILE;
     1354        }
     1355
     1356        if (pFile->pvData)
     1357        {
     1358            RTMemFree(pFile->pvData);
     1359            pFile->pvData = NULL;
     1360        }
     1361    }
     1362    else
     1363        AssertFailedStmt(rc = VERR_NOT_IMPLEMENTED);
     1364
     1365    if (   RT_SUCCESS(rc)
     1366        && !cbSize
     1367        && !(pFile->fFlags & PDMAUDIOFILE_FLAG_KEEP_IF_EMPTY))
     1368    {
     1369        rc = DrvAudioHlpFileDelete(pFile);
     1370    }
     1371
     1372    pFile->cbData = 0;
     1373
     1374    if (RT_SUCCESS(rc))
     1375    {
     1376        LogRel2(("Audio: Closed file '%s' (%zu bytes)\n", pFile->szName, cbSize));
     1377    }
     1378    else
     1379        LogRel(("Audio: Failed closing file '%s', rc=%Rrc\n", pFile->szName, rc));
     1380
     1381    return rc;
     1382}
     1383
     1384/**
     1385 * Deletes an audio file.
     1386 *
     1387 * @returns IPRT status code.
     1388 * @param   pFile               Audio file handle to delete.
     1389 */
     1390int DrvAudioHlpFileDelete(PPDMAUDIOFILE pFile)
     1391{
     1392    AssertPtrReturn(pFile, VERR_INVALID_POINTER);
     1393
     1394    int rc = RTFileDelete(pFile->szName);
     1395    if (RT_FAILURE(rc))
     1396        LogRel(("Audio: Failed deleting file '%s', rc=%Rrc\n", pFile->szName, rc));
     1397
     1398    return rc;
     1399}
     1400
     1401/**
     1402 * Returns the raw audio data size of an audio file.
     1403 *
     1404 * Note: This does *not* include file headers and other data which does
     1405 *       not belong to the actual PCM audio data.
     1406 *
     1407 * @returns Size (in bytes) of the raw PCM audio data.
     1408 * @param   pFile               Audio file handle to retrieve the audio data size for.
     1409 */
     1410size_t DrvAudioHlpFileGetDataSize(PPDMAUDIOFILE pFile)
     1411{
     1412    AssertPtrReturn(pFile, 0);
     1413
     1414    size_t cbSize = 0;
     1415
     1416    if (pFile->enmType == PDMAUDIOFILETYPE_RAW)
     1417    {
     1418        cbSize = RTFileTell(pFile->hFile);
     1419    }
     1420    else if (pFile->enmType == PDMAUDIOFILETYPE_WAV)
    12181421    {
    12191422        PAUDIOWAVFILEDATA pData = (PAUDIOWAVFILEDATA)pFile->pvData;
    12201423        AssertPtr(pData);
    12211424
    1222         /* Update the header with the current data size. */
    1223         RTFileWriteAt(pFile->hFile, 0, &pData->Hdr, sizeof(pData->Hdr), NULL);
    1224 
    1225         RTFileClose(pFile->hFile);
    1226         pFile->hFile = NIL_RTFILE;
    1227     }
    1228 
    1229     if (pFile->pvData)
    1230     {
    1231         RTMemFree(pFile->pvData);
    1232         pFile->pvData = NULL;
    1233     }
    1234 
    1235     pFile->cbData  = 0;
    1236     pFile->enmType = PDMAUDIOFILETYPE_UNKNOWN;
    1237 
    1238     return VINF_SUCCESS;
    1239 }
    1240 
    1241 /**
    1242  * Returns the raw PCM audio data size of a wave file.
    1243  * This does *not* include file headers and other data which does
    1244  * not belong to the actual PCM audio data.
    1245  *
    1246  * @returns Size (in bytes) of the raw PCM audio data.
    1247  * @param   pFile               Audio file handle to retrieve the audio data size for.
    1248  */
    1249 size_t DrvAudioHlpWAVFileGetDataSize(PPDMAUDIOFILE pFile)
    1250 {
    1251     AssertPtrReturn(pFile, 0);
    1252 
    1253     Assert(pFile->enmType == PDMAUDIOFILETYPE_WAV);
    1254 
    1255     PAUDIOWAVFILEDATA pData = (PAUDIOWAVFILEDATA)pFile->pvData;
    1256     AssertPtr(pData);
    1257 
    1258     return pData->Hdr.u32Size2;
     1425        cbSize = pData->Hdr.u32Size2;
     1426    }
     1427
     1428    return cbSize;
    12591429}
    12601430
     
    12681438 * @param   fFlags              Additional write flags. Not being used at the moment and must be 0.
    12691439 */
    1270 int DrvAudioHlpWAVFileWrite(PPDMAUDIOFILE pFile, const void *pvBuf, size_t cbBuf, uint32_t fFlags)
     1440int DrvAudioHlpFileWrite(PPDMAUDIOFILE pFile, const void *pvBuf, size_t cbBuf, uint32_t fFlags)
    12711441{
    12721442    AssertPtrReturn(pFile, VERR_INVALID_POINTER);
     
    12751445    AssertReturn(fFlags == 0, VERR_INVALID_PARAMETER); /** @todo fFlags are currently not implemented. */
    12761446
    1277     Assert(pFile->enmType == PDMAUDIOFILETYPE_WAV);
    1278 
    12791447    if (!cbBuf)
    12801448        return VINF_SUCCESS;
    12811449
    1282     PAUDIOWAVFILEDATA pData = (PAUDIOWAVFILEDATA)pFile->pvData;
    1283     AssertPtr(pData);
    1284 
    1285     int rc = RTFileWrite(pFile->hFile, pvBuf, cbBuf, NULL);
    1286     if (RT_SUCCESS(rc))
    1287     {
    1288         pData->Hdr.u32Size  += (uint32_t)cbBuf;
    1289         pData->Hdr.u32Size2 += (uint32_t)cbBuf;
    1290     }
     1450    int rc;
     1451
     1452    if (pFile->enmType == PDMAUDIOFILETYPE_RAW)
     1453    {
     1454        rc = RTFileWrite(pFile->hFile, pvBuf, cbBuf, NULL);
     1455    }
     1456    else if (pFile->enmType == PDMAUDIOFILETYPE_WAV)
     1457    {
     1458        PAUDIOWAVFILEDATA pData = (PAUDIOWAVFILEDATA)pFile->pvData;
     1459        AssertPtr(pData);
     1460
     1461        rc = RTFileWrite(pFile->hFile, pvBuf, cbBuf, NULL);
     1462        if (RT_SUCCESS(rc))
     1463        {
     1464            pData->Hdr.u32Size  += (uint32_t)cbBuf;
     1465            pData->Hdr.u32Size2 += (uint32_t)cbBuf;
     1466        }
     1467    }
     1468    else
     1469        rc = VERR_NOT_SUPPORTED;
    12911470
    12921471    return rc;
  • trunk/src/VBox/Devices/Audio/DrvHostDebugAudio.cpp

    r69119 r70013  
    3737    PPDMAUDIOSTREAMCFG pCfg;
    3838    /** Audio file to dump output to or read input from. */
    39     PDMAUDIOFILE       File;
     39    PPDMAUDIOFILE      pFile;
    4040    union
    4141    {
     
    150150        {
    151151            char szFile[RTPATH_MAX];
    152             rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, NULL, PDMAUDIOFILETYPE_WAV);
     152            rc = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), szTemp, "DebugAudioOut",
     153                                        pDrv->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
    153154            if (RT_SUCCESS(rc))
    154155            {
    155                 LogFlowFunc(("%s\n", szFile));
    156                 rc = DrvAudioHlpWAVFileOpen(&pStreamDbg->File, szFile,
    157                                             RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
    158                                             &pCfgReq->Props, PDMAUDIOFILEFLAG_NONE);
     156                rc = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szFile, PDMAUDIOFILE_FLAG_NONE, &pStreamDbg->pFile);
     157                if (RT_SUCCESS(rc))
     158                {
     159                    rc = DrvAudioHlpFileOpen(pStreamDbg->pFile, RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
     160                                             &pCfgReq->Props);
     161                }
     162
    159163                if (RT_FAILURE(rc))
    160164                    LogRel(("DebugAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
     
    228232        memcpy(pStreamDbg->Out.auPlayBuffer, (uint8_t *)pvBuf + cbWrittenTotal, cbChunk);
    229233
    230 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    231         RTFILE fh;
    232         RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "AudioDebugOutput.pcm",
    233                    RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    234         RTFileWrite(fh, pStreamDbg->Out.auPlayBuffer, cbChunk, NULL);
    235         RTFileClose(fh);
    236 #endif
    237         int rc2 = DrvAudioHlpWAVFileWrite(&pStreamDbg->File,
    238                                           pStreamDbg->Out.auPlayBuffer, cbChunk, 0 /* fFlags */);
     234        int rc2 = DrvAudioHlpFileWrite(pStreamDbg->pFile, pStreamDbg->Out.auPlayBuffer, cbChunk, 0 /* fFlags */);
    239235        if (RT_FAILURE(rc2))
    240236        {
     
    289285    }
    290286
    291     size_t cbDataSize = DrvAudioHlpWAVFileGetDataSize(&pStreamDbg->File);
    292 
    293     int rc = DrvAudioHlpWAVFileClose(&pStreamDbg->File);
    294     if (RT_SUCCESS(rc))
    295     {
    296         /* Delete the file again if nothing but the header was written to it. */
    297         bool fDeleteEmptyFiles = true; /** @todo Make deletion configurable? */
    298 
    299         if (   !cbDataSize
    300             && fDeleteEmptyFiles)
    301         {
    302             rc = RTFileDelete(pStreamDbg->File.szName);
    303         }
    304         else
    305             LogRel(("DebugAudio: Created output file '%s' (%zu bytes)\n", pStreamDbg->File.szName, cbDataSize));
    306     }
    307 
    308     return rc;
     287    DrvAudioHlpFileDestroy(pStreamDbg->pFile);
     288
     289    return VINF_SUCCESS;
    309290}
    310291
  • trunk/src/VBox/Devices/Audio/DrvHostValidationKit.cpp

    r69119 r70013  
    167167            {
    168168                LogFlowFunc(("%s\n", szFile));
    169                 rc = DrvAudioHlpWAVFileOpen(&pStreamDbg->File, szFile,
    170                                             RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
    171                                             &pCfgReq->Props, PDMAUDIOFILEFLAG_NONE);
     169                rc = DrvAudioHlpFileOpen(&pStreamDbg->File, PDMAUDIOFILETYPE_WAV, szFile,
     170                                         RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
     171                                         &pCfgReq->Props, PDMAUDIOFILE_FLAG_NONE);
    172172                if (RT_FAILURE(rc))
    173173                    LogRel(("VaKitAudio: Creating output file '%s' failed with %Rrc\n", szFile, rc));
     
    277277   // pStreamDbg->Out.tsLastPlayed = PDMDrvHlpTMGetVirtualTime(pDrv->pDrvIns);;
    278278
    279     int rc2 = DrvAudioHlpWAVFileWrite(&pStreamDbg->File, pvBuf, cxBuf, 0 /* fFlags */);
     279    int rc2 = DrvAudioHlpFileWrite(&pStreamDbg->File, pvBuf, cxBuf, 0 /* fFlags */);
    280280    if (RT_FAILURE(rc2))
    281281        LogRel(("DebugAudio: Writing output failed with %Rrc\n", rc2));
     
    321321    }
    322322
    323     size_t cbDataSize = DrvAudioHlpWAVFileGetDataSize(&pStreamDbg->File);
    324 
    325     int rc = DrvAudioHlpWAVFileClose(&pStreamDbg->File);
     323    size_t cbDataSize = DrvAudioHlpFileGetDataSize(&pStreamDbg->File);
     324
     325    int rc = DrvAudioHlpFileClose(&pStreamDbg->File);
    326326    RTFileClose(pStreamDbg->hFileTiming);
    327327
  • trunk/src/VBox/Devices/Audio/HDAStream.cpp

    r69946 r70013  
    4343 * @param   pStream             HDA stream to create.
    4444 * @param   pThis               HDA state to assign the HDA stream to.
    45  */
    46 int hdaStreamCreate(PHDASTREAM pStream, PHDASTATE pThis)
     45 * @param   u8SD                Stream descriptor number to assign.
     46 */
     47int hdaStreamCreate(PHDASTREAM pStream, PHDASTATE pThis, uint8_t u8SD)
    4748{
    4849    RT_NOREF(pThis);
    4950    AssertPtrReturn(pStream, VERR_INVALID_POINTER);
    5051
    51     pStream->u8SD           = UINT8_MAX;
     52    pStream->u8SD           = u8SD;
    5253    pStream->pMixSink       = NULL;
    5354    pStream->pHDAState      = pThis;
     
    7172#endif
    7273
     74    pStream->Dbg.Runtime.fEnabled = pThis->Dbg.fEnabled;
     75
     76    if (pStream->Dbg.Runtime.fEnabled)
     77    {
     78        char szFile[64];
     79
     80        if (pStream->State.Cfg.enmDir == PDMAUDIODIR_IN)
     81            RTStrPrintf(szFile, sizeof(szFile), "hdaStreamWriteSD%RU8", pStream->u8SD);
     82        else
     83            RTStrPrintf(szFile, sizeof(szFile), "hdaStreamReadSD%RU8", pStream->u8SD);
     84
     85        char szPath[RTPATH_MAX + 1];
     86        rc2 = DrvAudioHlpGetFileName(szPath, sizeof(szPath), pThis->Dbg.szOutPath, szFile,
     87                                     0 /* uInst */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
     88        AssertRC(rc2);
     89        rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szPath, PDMAUDIOFILE_FLAG_NONE, &pStream->Dbg.Runtime.pFileStream);
     90        AssertRC(rc2);
     91
     92        if (pStream->State.Cfg.enmDir == PDMAUDIODIR_IN)
     93            RTStrPrintf(szFile, sizeof(szFile), "hdaDMAWriteSD%RU8", pStream->u8SD);
     94        else
     95            RTStrPrintf(szFile, sizeof(szFile), "hdaDMAReadSD%RU8", pStream->u8SD);
     96
     97        rc2 = DrvAudioHlpGetFileName(szPath, sizeof(szPath), pThis->Dbg.szOutPath, szFile,
     98                                     0 /* uInst */, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
     99        AssertRC(rc2);
     100
     101        rc2 = DrvAudioHlpFileCreate(PDMAUDIOFILETYPE_WAV, szPath, PDMAUDIOFILE_FLAG_NONE, &pStream->Dbg.Runtime.pFileDMA);
     102        AssertRC(rc2);
     103
     104        /* Delete stale debugging files from a former run. */
     105        DrvAudioHlpFileDelete(pStream->Dbg.Runtime.pFileStream);
     106        DrvAudioHlpFileDelete(pStream->Dbg.Runtime.pFileDMA);
     107    }
     108
    73109    return rc;
    74110}
     
    109145    AssertRC(rc2);
    110146#endif
     147
     148    if (pStream->Dbg.Runtime.fEnabled)
     149    {
     150        DrvAudioHlpFileDestroy(pStream->Dbg.Runtime.pFileStream);
     151        DrvAudioHlpFileDestroy(pStream->Dbg.Runtime.pFileDMA);
     152    }
    111153
    112154    LogFlowFuncLeave();
     
    394436        if (pStream->pMixSink->pMixSink)
    395437            rc = AudioMixerSinkCtl(pStream->pMixSink->pMixSink, enmCmd);
     438
     439        if (   RT_SUCCESS(rc)
     440            && pStream->Dbg.Runtime.fEnabled)
     441        {
     442            if (fEnable)
     443            {
     444                int rc2 = DrvAudioHlpFileOpen(pStream->Dbg.Runtime.pFileStream,
     445                                              RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
     446                                              &pStream->State.Cfg.Props);
     447                AssertRC(rc2);
     448
     449                rc2 = DrvAudioHlpFileOpen(pStream->Dbg.Runtime.pFileDMA,
     450                                          RTFILE_O_WRITE | RTFILE_O_DENY_WRITE | RTFILE_O_CREATE_REPLACE,
     451                                          &pStream->State.Cfg.Props);
     452                AssertRC(rc2);
     453            }
     454            else
     455            {
     456                int rc2 = DrvAudioHlpFileClose(pStream->Dbg.Runtime.pFileStream);
     457                AssertRC(rc2);
     458
     459                rc2 = DrvAudioHlpFileClose(pStream->Dbg.Runtime.pFileDMA);
     460                AssertRC(rc2);
     461            }
     462        }
    396463    }
    397464
     
    541608            }
    542609
    543 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    544             RTFILE fh;
    545             RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaStreamWrite.pcm",
    546                        RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    547             RTFileWrite(fh, pvDst, cbDst, NULL);
    548             RTFileClose(fh);
    549 #endif
     610            if (pStream->Dbg.Runtime.fEnabled)
     611                DrvAudioHlpFileWrite(pStream->Dbg.Runtime.pFileStream, pvDst, cbDst, 0 /* fFlags */);
    550612        }
    551613
     
    611673        if (cbSrc)
    612674        {
    613 #ifdef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA
    614             RTFILE fh;
    615             RTFileOpen(&fh, VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "hdaStreamRead.pcm",
    616                        RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_NONE);
    617             RTFileWrite(fh, pvSrc, cbSrc, NULL);
    618             RTFileClose(fh);
    619 #endif
     675            if (pStream->Dbg.Runtime.fEnabled)
     676                DrvAudioHlpFileWrite(pStream->Dbg.Runtime.pFileStream, pvSrc, cbSrc, 0 /* fFlags */);
     677
    620678            rc = AudioMixerSinkWrite(pSink->pMixSink, AUDMIXOP_COPY, pvSrc, (uint32_t)cbSrc, &cbWritten);
    621679            AssertRC(rc);
  • trunk/src/VBox/Devices/Audio/HDAStream.h

    r69919 r70013  
    5252#endif
    5353
    54 #if defined (DEBUG) || defined(HDA_USE_DMA_ACCESS_HANDLER)
     54/**
     55 * Structure containing HDA stream debug stuff, configurable at runtime.
     56 */
     57typedef struct HDASTREAMDBGINFORT
     58{
     59    /** Whether debugging is enabled or not. */
     60    bool                     fEnabled;
     61    uint8_t                  Padding[7];
     62    /** File for dumping stream reads / writes.
     63     *  For input streams, this dumps data being written to the device FIFO,
     64     *  whereas for output streams this dumps data being read from the device FIFO. */
     65    R3PTRTYPE(PPDMAUDIOFILE) pFileStream;
     66    /** File for dumping DMA reads / writes.
     67     *  For input streams, this dumps data being written to the device DMA,
     68     *  whereas for output streams this dumps data being read from the device DMA. */
     69    R3PTRTYPE(PPDMAUDIOFILE) pFileDMA;
     70} HDASTREAMDBGINFORT, *PHDASTREAMDBGINFORT;
     71
     72/**
     73 * Structure containing HDA stream debug information.
     74 */
    5575typedef struct HDASTREAMDBGINFO
    5676{
     77#ifdef DEBUG
    5778    /** Critical section to serialize access if needed. */
    5879    RTCRITSECT              CritSect;
    59     uint32_t                Padding1[2];
     80    uint32_t                Padding0[2];
    6081    /** Number of total read accesses. */
    6182    uint64_t                cReadsTotal;
     
    81102     *  (useful for intros and silence at the beginning of a song). */
    82103    uint64_t                cbSilenceReadMin;
     104#endif
     105    /** Runtime debug info. */
     106    HDASTREAMDBGINFORT      Runtime;
    83107} HDASTREAMDBGINFO ,*PHDASTREAMDBGINFO;
    84 #endif /* defined (DEBUG) || defined(HDA_USE_DMA_ACCESS_HANDLER) */
    85108
    86109/**
     
    190213    /** Internal state of this stream. */
    191214    HDASTREAMSTATE           State;
    192 #ifdef DEBUG
    193215    /** Debug information. */
    194216    HDASTREAMDBGINFO         Dbg;
    195 #endif
    196217} HDASTREAM, *PHDASTREAM;
    197218
     
    212233 * @{
    213234 */
    214 int               hdaStreamCreate(PHDASTREAM pStream, PHDASTATE pThis);
     235int               hdaStreamCreate(PHDASTREAM pStream, PHDASTATE pThis, uint8_t u8SD);
    215236void              hdaStreamDestroy(PHDASTREAM pStream);
    216237int               hdaStreamInit(PHDASTREAM pStream, uint8_t uSD);
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r69919 r70013  
    18471847    GEN_CHECK_OFF(HDASTREAMSTATE, pCircBuf);
    18481848
     1849    GEN_CHECK_SIZE(HDASTREAMDBGINFORT);
     1850
     1851    GEN_CHECK_SIZE(HDASTREAMDBGINFO);
     1852    GEN_CHECK_OFF(HDASTREAMDBGINFO, Runtime);
     1853
    18491854    GEN_CHECK_SIZE(HDASTREAM);
    18501855    GEN_CHECK_OFF(HDASTREAM, u8SD);
     
    18541859    GEN_CHECK_OFF(HDASTREAM, u16LVI);
    18551860    GEN_CHECK_OFF(HDASTREAM, State);
     1861    GEN_CHECK_OFF(HDASTREAM, Dbg);
    18561862
    18571863    GEN_CHECK_SIZE(HDASTATE);
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r69956 r70013  
    7272#include <VBox/param.h>
    7373#include <VBox/vmm/pdmapi.h> /* For PDMR3DriverAttach/PDMR3DriverDetach. */
    74 #include <VBox/vmm/pdmaudioifs.h>
    7574#include <VBox/vmm/pdmusb.h> /* For PDMR3UsbCreateEmulatedDevice. */
    7675#include <VBox/vmm/pdmdev.h> /* For PDMAPICMODE enum. */
     
    28392838            hrc = audioAdapter->COMGETTER(AudioCodec)(&audioCodec);                         H();
    28402839
     2840            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Debug/Enabled", &strTmp);
     2841            const bool fDebugEnabled = strTmp.equalsIgnoreCase("true") || strTmp.equalsIgnoreCase("1");
     2842
     2843            Utf8Str strDebugPathOut;
     2844            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Debug/PathOut", &strDebugPathOut);
     2845
    28412846            switch (audioController)
    28422847            {
     
    28892894                    hrc = pBusMgr->assignPCIDevice(strAudioDevice.c_str(), pInst);          H();
    28902895                    InsertConfigNode   (pInst,    "Config",                &pCfg);
     2896
     2897                        InsertConfigInteger(pCfg, "DebugEnabled", fDebugEnabled);
     2898                        InsertConfigString (pCfg, "DebugPathOut", strDebugPathOut);
    28912899                }
    28922900            }
     
    29072915            }
    29082916
    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 
    29172917            /*
    29182918             * The audio driver.
     
    29962996            CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%RU8", u8AudioLUN++);
    29972997            InsertConfigString(pLunL0, "Driver", "AUDIO");
     2998
    29982999            InsertConfigNode(pLunL0,   "Config", &pCfg);
    2999 
    30003000                InsertConfigString (pCfg, "DriverName",    strAudioDriver.c_str());
    30013001                InsertConfigInteger(pCfg, "InputEnabled",  fAudioEnabledIn);
     
    30423042                /* Note: Don't do any driver attaching (fAttachDetach) here, as this will
    30433043                 *       be done automatically as part of the VM startup process. */
    3044                 pDisplay->i_videoRecConfigure(pDisplay, pDisplay->i_videoRecGetConfig(), false /* fAttachDetach */);
     3044                rc = pDisplay->i_videoRecConfigure(pDisplay, pDisplay->i_videoRecGetConfig(), false /* fAttachDetach */);
     3045
     3046                /** @todo Fix this: Figure out what the next LUN might be. */
     3047                u8AudioLUN = 3;
    30453048            }
    30463049#endif /* VBOX_WITH_AUDIO_VIDEOREC */
    3047 
    3048             GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Debug/Enabled", &strTmp);
    30493050
    30503051            if (fDebugEnabled)
     
    30563057                CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%RU8", u8AudioLUN++);
    30573058                InsertConfigString(pLunL0, "Driver", "AUDIO");
     3059
    30583060                InsertConfigNode(pLunL0,   "Config", &pCfg);
    3059                     InsertConfigString (pCfg, "DriverName", "DebugAudio");
     3061                    InsertConfigString (pCfg, "DriverName",    "DebugAudio");
    30603062                    InsertConfigInteger(pCfg, "InputEnabled",  fAudioEnabledIn);
    30613063                    InsertConfigInteger(pCfg, "OutputEnabled", fAudioEnabledOut);
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