VirtualBox

Changeset 89643 in vbox


Ignore:
Timestamp:
Jun 13, 2021 1:59:53 PM (3 years ago)
Author:
vboxsync
Message:

ValKit/Audio: Don't define g_aBackends in a header file. bugref:10008

Location:
trunk/src/VBox/ValidationKit/utils/audio
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp

    r89642 r89643  
    9494*   Global Variables                                                                                                             *
    9595*********************************************************************************************************************************/
     96/**
     97 * Backends.
     98 *
     99 * @note The first backend in the array is the default one for the platform.
     100 */
     101struct
     102{
     103    /** The driver registration structure. */
     104    PCPDMDRVREG pDrvReg;
     105    /** The backend name.
     106     * Aliases are implemented by having multiple entries for the same backend.  */
     107    const char *pszName;
     108} const g_aBackends[] =
     109{
     110#if defined(VBOX_WITH_AUDIO_ALSA) && defined(RT_OS_LINUX)
     111    {   &g_DrvHostALSAAudio,          "alsa" },
     112#endif
     113#ifdef VBOX_WITH_AUDIO_PULSE
     114    {   &g_DrvHostPulseAudio,         "pulseaudio" },
     115    {   &g_DrvHostPulseAudio,         "pulse" },
     116    {   &g_DrvHostPulseAudio,         "pa" },
     117#endif
     118#ifdef VBOX_WITH_AUDIO_OSS
     119    {   &g_DrvHostOSSAudio,           "oss" },
     120#endif
     121#if defined(RT_OS_DARWIN)
     122    {   &g_DrvHostCoreAudio,          "coreaudio" },
     123    {   &g_DrvHostCoreAudio,          "core" },
     124    {   &g_DrvHostCoreAudio,          "ca" },
     125#endif
     126#if defined(RT_OS_WINDOWS)
     127    {   &g_DrvHostAudioWas,           "wasapi" },
     128    {   &g_DrvHostAudioWas,           "was" },
     129    {   &g_DrvHostDSound,             "directsound" },
     130    {   &g_DrvHostDSound,             "dsound" },
     131    {   &g_DrvHostDSound,             "ds" },
     132#endif
     133    {   &g_DrvHostValidationKitAudio, "valkit" }
     134};
     135AssertCompile(sizeof(g_aBackends) > 0 /* port me */);
    96136
    97137/**
     
    188228
    189229/**
     230 * Get default backend.
     231 */
     232PCPDMDRVREG AudioTestGetDefaultBackend(void)
     233{
     234    return g_aBackends[0].pDrvReg;
     235}
     236
     237
     238/**
    190239 * Helper for handling --backend options.
    191240 *
     
    194243 * @param   pszBackend      The backend option value.
    195244 */
    196 PCPDMDRVREG audioTestFindBackendOpt(const char *pszBackend)
     245PCPDMDRVREG AudioTestFindBackendOpt(const char *pszBackend)
    197246{
    198247    for (uintptr_t i = 0; i < RT_ELEMENTS(g_aBackends); i++)
     
    573622    const char *pszDevice     = NULL; /* Custom device to use. Can be NULL if not being used. */
    574623    const char *pszTag        = NULL; /* Custom tag to use. Can be NULL if not being used. */
    575     PCPDMDRVREG pDrvReg       = g_aBackends[0].pDrvReg;
     624    PCPDMDRVREG pDrvReg       = AudioTestGetDefaultBackend();
    576625    bool        fWithDrvAudio = false;
    577626    uint8_t     cPcmSampleBit = 0;
     
    597646
    598647            case 'b':
    599                 pDrvReg = audioTestFindBackendOpt(ValueUnion.psz);
     648                pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
    600649                if (pDrvReg == NULL)
    601650                    return RTEXITCODE_SYNTAX;
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdGeneric.cpp

    r89642 r89643  
    7272     */
    7373    /* Option values: */
    74     PCPDMDRVREG pDrvReg = g_aBackends[0].pDrvReg;
     74    PCPDMDRVREG pDrvReg = AudioTestGetDefaultBackend();
    7575
    7676    /* Argument processing loop: */
     
    8282        {
    8383            case 'b':
    84                 pDrvReg = audioTestFindBackendOpt(ValueUnion.psz);
     84                pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
    8585                if (pDrvReg == NULL)
    8686                    return RTEXITCODE_SYNTAX;
     
    408408{
    409409    /* Option values: */
    410     PCPDMDRVREG pDrvReg             = g_aBackends[0].pDrvReg;
     410    PCPDMDRVREG pDrvReg             = AudioTestGetDefaultBackend();
    411411    uint32_t    cMsBufferSize       = UINT32_MAX;
    412412    uint32_t    cMsPreBuffer        = UINT32_MAX;
     
    427427        {
    428428            case 'b':
    429                 pDrvReg = audioTestFindBackendOpt(ValueUnion.psz);
     429                pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
    430430                if (pDrvReg == NULL)
    431431                    return RTEXITCODE_SYNTAX;
     
    753753{
    754754    /* Option values: */
    755     PCPDMDRVREG pDrvReg             = g_aBackends[0].pDrvReg;
     755    PCPDMDRVREG pDrvReg             = AudioTestGetDefaultBackend();
    756756    uint32_t    cMsBufferSize       = UINT32_MAX;
    757757    uint32_t    cMsPreBuffer        = UINT32_MAX;
     
    777777        {
    778778            case 'b':
    779                 pDrvReg = audioTestFindBackendOpt(ValueUnion.psz);
     779                pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
    780780                if (pDrvReg == NULL)
    781781                    return RTEXITCODE_SYNTAX;
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCmdSelfTest.cpp

    r89642 r89643  
    255255
    256256    /* Go with the platform's default bakcend if nothing else is specified. */
    257     Ctx.Guest.pDrvReg = g_aBackends[0].pDrvReg;
     257    Ctx.Guest.pDrvReg = AudioTestGetDefaultBackend();
    258258
    259259    /* Argument processing loop: */
     
    286286
    287287            case 'b':
    288                 Ctx.Guest.pDrvReg = audioTestFindBackendOpt(ValueUnion.psz);
     288                Ctx.Guest.pDrvReg = AudioTestFindBackendOpt(ValueUnion.psz);
    289289                if (Ctx.Guest.pDrvReg == NULL)
    290290                    return RTEXITCODE_SYNTAX;
  • trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp

    r89641 r89643  
    655655            pDrvReg = &g_DrvHostValidationKitAudio;
    656656        else /* Go with the platform's default backend if nothing else is set. */
    657             pDrvReg = g_aBackends[0].pDrvReg;
     657            pDrvReg = AudioTestGetDefaultBackend();
    658658    }
    659659
  • trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h

    r89642 r89643  
    3131#endif
    3232
     33
     34/*********************************************************************************************************************************
     35*   Header Files                                                                                                                 *
     36*********************************************************************************************************************************/
    3337#include <iprt/getopt.h>
    3438
     
    4347
    4448#include "VBoxDD.h"
    45 
    46 
    47 /*********************************************************************************************************************************
    48 *   Externals                                                                                                                    *
    49 *********************************************************************************************************************************/
    50 /** Terminate ASAP if set.  Set on Ctrl-C. */
    51 extern bool volatile    g_fTerminate;
    52 /** The release logger. */
    53 extern PRTLOGGER        g_pRelLogger;
    54 
    55 /** The test handle. */
    56 extern RTTEST         g_hTest;
    57 extern unsigned       g_uVerbosity;
    58 extern bool           g_fDrvAudioDebug;
    59 extern const char    *g_pszDrvAudioDebug;
    60 
    61 /** The test handle. */
    62 extern RTTEST         g_hTest;
    63 /** The current verbosity level. */
    64 extern unsigned       g_uVerbosity;
    65 /** DrvAudio: Enable debug (or not). */
    66 extern bool           g_fDrvAudioDebug;
    67 /** DrvAudio: The debug output path. */
    68 extern const char    *g_pszDrvAudioDebug;
    69 
    70 
    71 /*********************************************************************************************************************************
    72 *   Defined Constants And Macros                                                                                                 *
    73 *********************************************************************************************************************************/
    7449
    7550
     
    136111/** Pointer to mixer setup for a stream. */
    137112typedef AUDIOTESTDRVMIXSTREAM *PAUDIOTESTDRVMIXSTREAM;
    138 
    139 /**
    140  * Backends.
    141  *
    142  * @note The first backend in the array is the default one for the platform.
    143  */
    144 struct
    145 {
    146     /** The driver registration structure. */
    147     PCPDMDRVREG pDrvReg;
    148     /** The backend name.
    149      * Aliases are implemented by having multiple entries for the same backend.  */
    150     const char *pszName;
    151 } const g_aBackends[] =
    152 {
    153 #if defined(VBOX_WITH_AUDIO_ALSA) && defined(RT_OS_LINUX)
    154     {   &g_DrvHostALSAAudio,          "alsa" },
    155 #endif
    156 #ifdef VBOX_WITH_AUDIO_PULSE
    157     {   &g_DrvHostPulseAudio,         "pulseaudio" },
    158     {   &g_DrvHostPulseAudio,         "pulse" },
    159     {   &g_DrvHostPulseAudio,         "pa" },
    160 #endif
    161 #ifdef VBOX_WITH_AUDIO_OSS
    162     {   &g_DrvHostOSSAudio,           "oss" },
    163 #endif
    164 #if defined(RT_OS_DARWIN)
    165     {   &g_DrvHostCoreAudio,          "coreaudio" },
    166     {   &g_DrvHostCoreAudio,          "core" },
    167     {   &g_DrvHostCoreAudio,          "ca" },
    168 #endif
    169 #if defined(RT_OS_WINDOWS)
    170     {   &g_DrvHostAudioWas,           "wasapi" },
    171     {   &g_DrvHostAudioWas,           "was" },
    172     {   &g_DrvHostDSound,             "directsound" },
    173     {   &g_DrvHostDSound,             "dsound" },
    174     {   &g_DrvHostDSound,             "ds" },
    175 #endif
    176     {   &g_DrvHostValidationKitAudio, "valkit" }
    177 };
    178 AssertCompile(sizeof(g_aBackends) > 0 /* port me */);
    179113
    180114/**
     
    366300typedef VKATCMD const *PCVKATCMD;
    367301
    368 extern const VKATCMD g_CmdEnum;
    369 extern const VKATCMD g_CmdPlay;
    370 extern const VKATCMD g_CmdRec;
    371 extern const VKATCMD g_CmdSelfTest;
    372 
    373 extern AUDIOTESTDESC g_aTests[];
    374 extern unsigned      g_cTests;
     302
     303/*********************************************************************************************************************************
     304*   Global Variables                                                                                                             *
     305*********************************************************************************************************************************/
     306/** Terminate ASAP if set.  Set on Ctrl-C. */
     307extern bool volatile    g_fTerminate;
     308/** The release logger. */
     309extern PRTLOGGER        g_pRelLogger;
     310
     311/** The test handle. */
     312extern RTTEST           g_hTest;
     313extern unsigned         g_uVerbosity;
     314extern bool             g_fDrvAudioDebug;
     315extern const char      *g_pszDrvAudioDebug;
     316
     317/** The test handle. */
     318extern RTTEST           g_hTest;
     319/** The current verbosity level. */
     320extern unsigned         g_uVerbosity;
     321/** DrvAudio: Enable debug (or not). */
     322extern bool             g_fDrvAudioDebug;
     323/** DrvAudio: The debug output path. */
     324extern const char      *g_pszDrvAudioDebug;
     325
     326extern const VKATCMD    g_CmdEnum;
     327extern const VKATCMD    g_CmdPlay;
     328extern const VKATCMD    g_CmdRec;
     329extern const VKATCMD    g_CmdSelfTest;
     330
     331extern AUDIOTESTDESC    g_aTests[];
     332extern unsigned         g_cTests;
    375333
    376334
     
    421379/** @name Backend handling
    422380 * @{ */
    423 PCPDMDRVREG audioTestFindBackendOpt(const char *pszBackend);
     381PCPDMDRVREG AudioTestGetDefaultBackend(void);
     382PCPDMDRVREG AudioTestFindBackendOpt(const char *pszBackend);
    424383/** @}  */
    425384
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