VirtualBox

Changeset 73230 in vbox


Ignore:
Timestamp:
Jul 19, 2018 9:53:50 AM (7 years ago)
Author:
vboxsync
Message:

Audio/DrvAudio: Added DRVAUDIOCFG to allow tweaking an audio driver via CFGM and added support for separate configurations for both, input and output streams. See comments for actual tweakables.

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

Legend:

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

    r72110 r73230  
    961961        }
    962962
    963         if (pThis->Dbg.fEnabled)
     963        if (pThis->Out.Cfg.Dbg.fEnabled)
    964964            DrvAudioHlpFileWrite(pHstStream->Out.Dbg.pFileStreamWrite, pvBuf, cbBuf, 0 /* fFlags */);
    965965
     
    13261326                    && cbPlayed)
    13271327                {
    1328                     if (pThis->Dbg.fEnabled)
     1328                    if (pThis->Out.Cfg.Dbg.fEnabled)
    13291329                        DrvAudioHlpFileWrite(pHstStream->Out.Dbg.pFilePlayNonInterleaved, auBuf, cbPlayed, 0 /* fFlags */);
    13301330
     
    16341634        else if (cbCaptured)
    16351635        {
    1636             if (pThis->Dbg.fEnabled)
     1636            if (pThis->In.Cfg.Dbg.fEnabled)
    16371637                DrvAudioHlpFileWrite(pHstStream->In.Dbg.pFileCaptureNonInterleaved, auBuf, cbCaptured, 0 /* fFlags */);
    16381638
     
    22102210
    22112211    /*
    2212      * Configure driver from CFGM stuff.
     2212     * Configure driver from CFGM.
    22132213     */
    22142214#ifdef DEBUG
     
    22272227    CFGMR3QueryBoolDef(pThis->pCFGMNode, "OutputEnabled", &pThis->Out.fEnabled,  false);
    22282228
    2229     CFGMR3QueryBoolDef(pThis->pCFGMNode, "DebugEnabled",      &pThis->Dbg.fEnabled,  false);
    2230     rc2 = CFGMR3QueryString(pThis->pCFGMNode, "DebugPathOut", pThis->Dbg.szPathOut, sizeof(pThis->Dbg.szPathOut));
     2229    /* Input configuration. */
     2230    /** @todo Separate debugging stuff if needed. Later. */
     2231    CFGMR3QueryBoolDef(pThis->pCFGMNode, "DebugEnabled",      &pThis->In.Cfg.Dbg.fEnabled,  false);
     2232    rc2 = CFGMR3QueryString(pThis->pCFGMNode, "DebugPathOut", pThis->In.Cfg.Dbg.szPathOut, sizeof(pThis->In.Cfg.Dbg.szPathOut));
    22312233    if (   RT_FAILURE(rc2)
    2232         || !strlen(pThis->Dbg.szPathOut))
    2233     {
    2234         RTStrPrintf(pThis->Dbg.szPathOut, sizeof(pThis->Dbg.szPathOut), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
    2235     }
    2236 
    2237     if (pThis->Dbg.fEnabled)
    2238         LogRel(("Audio: Debugging enabled (audio data written to '%s')\n", pThis->Dbg.szPathOut));
     2234        || !strlen(pThis->In.Cfg.Dbg.szPathOut))
     2235    {
     2236        RTStrPrintf(pThis->In.Cfg.Dbg.szPathOut, sizeof(pThis->In.Cfg.Dbg.szPathOut), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     2237    }
     2238
     2239    if (pThis->In.Cfg.Dbg.fEnabled)
     2240        LogRel(("Audio: Debugging input enabled (audio data written to '%s')\n", pThis->In.Cfg.Dbg.szPathOut));
     2241
     2242    /* Output configuration. */
     2243    CFGMR3QueryBoolDef(pThis->pCFGMNode, "DebugEnabled",      &pThis->Out.Cfg.Dbg.fEnabled, false);
     2244    rc2 = CFGMR3QueryString(pThis->pCFGMNode, "DebugPathOut", pThis->Out.Cfg.Dbg.szPathOut, sizeof(pThis->Out.Cfg.Dbg.szPathOut));
     2245    if (   RT_FAILURE(rc2)
     2246        || !strlen(pThis->Out.Cfg.Dbg.szPathOut))
     2247    {
     2248        RTStrPrintf(pThis->Out.Cfg.Dbg.szPathOut, sizeof(pThis->Out.Cfg.Dbg.szPathOut), VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH);
     2249    }
     2250
     2251    if (pThis->Out.Cfg.Dbg.fEnabled)
     2252        LogRel(("Audio: Debugging output enabled (audio data written to '%s')\n", pThis->Out.Cfg.Dbg.szPathOut));
    22392253
    22402254    LogRel2(("Audio: Initial status for driver '%s': Input is %s, output is %s\n",
     
    23272341        if (cReadTotal)
    23282342        {
    2329             if (pThis->Dbg.fEnabled)
     2343            if (pThis->In.Cfg.Dbg.fEnabled)
    23302344                DrvAudioHlpFileWrite(pHstStream->In.Dbg.pFileStreamRead,
    23312345                                     pvBuf, AUDIOMIXBUF_F2B(&pGstStream->MixBuf, cReadTotal), 0 /* fFlags */);
     
    25582572        if (pCfgHost->enmDir == PDMAUDIODIR_IN)
    25592573        {
    2560             if (pThis->Dbg.fEnabled)
     2574            if (pThis->In.Cfg.Dbg.fEnabled)
    25612575            {
    25622576                char szFile[RTPATH_MAX + 1];
    25632577
    2564                 int rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Dbg.szPathOut, "CaptureNonInterleaved",
     2578                int rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->In.Cfg.Dbg.szPathOut, "CaptureNonInterleaved",
    25652579                                                 pThis->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
    25662580                if (RT_SUCCESS(rc2))
     
    25752589                if (RT_SUCCESS(rc2))
    25762590                {
    2577                     rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Dbg.szPathOut, "StreamRead",
     2591                    rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->In.Cfg.Dbg.szPathOut, "StreamRead",
    25782592                                                 pThis->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
    25792593                    if (RT_SUCCESS(rc2))
     
    25932607        else /* Out */
    25942608        {
    2595             if (pThis->Dbg.fEnabled)
     2609            if (pThis->Out.Cfg.Dbg.fEnabled)
    25962610            {
    25972611                char szFile[RTPATH_MAX + 1];
    25982612
    2599                 int rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Dbg.szPathOut, "PlayNonInterleaved",
     2613                int rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Out.Cfg.Dbg.szPathOut, "PlayNonInterleaved",
    26002614                                                 pThis->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
    26012615                if (RT_SUCCESS(rc2))
     
    26102624                if (RT_SUCCESS(rc2))
    26112625                {
    2612                     rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Dbg.szPathOut, "StreamWrite",
     2626                    rc2 = DrvAudioHlpGetFileName(szFile, RT_ELEMENTS(szFile), pThis->Out.Cfg.Dbg.szPathOut, "StreamWrite",
    26132627                                                 pThis->pDrvIns->iInstance, PDMAUDIOFILETYPE_WAV, PDMAUDIOFILENAME_FLAG_NONE);
    26142628                    if (RT_SUCCESS(rc2))
     
    29612975                    PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pHstStream->In.StatFramesCaptured);
    29622976#endif
    2963                     if (pThis->Dbg.fEnabled)
     2977                    if (pThis->In.Cfg.Dbg.fEnabled)
    29642978                    {
    29652979                        DrvAudioHlpFileDestroy(pHstStream->In.Dbg.pFileCaptureNonInterleaved);
     
    29722986                    PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pHstStream->Out.StatFramesPlayed);
    29732987#endif
    2974                     if (pThis->Dbg.fEnabled)
     2988                    if (pThis->Out.Cfg.Dbg.fEnabled)
    29752989                    {
    29762990                        DrvAudioHlpFileDestroy(pHstStream->Out.Dbg.pFilePlayNonInterleaved);
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r73220 r73230  
    7373} DRVAUDIOSTATS, *PDRVAUDIOSTATS;
    7474#endif
     75
     76/**
     77 * Audio driver configuration data, tweakable via CFGM.
     78 */
     79typedef struct DRVAUDIOCFG
     80{
     81    /** Configures the period size (in audio frames).
     82     *  This value reflects the number of audio frames in between each hardware interrupt on the
     83     *  backend (host) side. */
     84    uint32_t             cfPeriod;
     85    /** Configures the (ring) buffer size (in audio frames). Often is a multiple of cfPeriod. */
     86    uint32_t             cfBufferSize;
     87    /** Configures the pre-buffering size (in audio frames).
     88     *  Frames needed in buffer before the stream becomes active (pre buffering).
     89     *  The bigger this value is, the more latency for the stream will occur. */
     90    uint32_t             cfPreBuf;
     91    /** The driver's debugging configuration. */
     92    struct
     93    {
     94        /** Whether audio debugging is enabled or not. */
     95        bool             fEnabled;
     96        /** Where to store the debugging files.
     97         *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH if not set. */
     98        char             szPathOut[RTPATH_MAX + 1];
     99    } Dbg;
     100} DRVAUDIOCFG, *PDRVAUDIOCFG;
    75101
    76102/**
     
    120146        RTLISTANCHOR        lstCB;
    121147#endif
     148        /** The driver's input confguration (tweakable via CFGM). */
     149        DRVAUDIOCFG         Cfg;
    122150    } In;
    123151    struct
     
    132160        RTLISTANCHOR        lstCB;
    133161#endif
     162        /** The driver's output confguration (tweakable via CFGM). */
     163        DRVAUDIOCFG         Cfg;
    134164    } Out;
    135     struct
    136     {
    137         /** Whether audio debugging is enabled or not. */
    138         bool                    fEnabled;
    139         /** Where to store the debugging files.
    140          *  Defaults to VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH if not set. */
    141         char                    szPathOut[RTPATH_MAX + 1];
    142     } Dbg;
    143165} DRVAUDIO, *PDRVAUDIO;
    144166
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