VirtualBox

Changeset 40844 in vbox


Ignore:
Timestamp:
Apr 10, 2012 10:37:46 AM (13 years ago)
Author:
vboxsync
Message:

Devices/Audio: Removal of environment variables which acted as audio configuration parameters .
Now the audio configuration parameters can be set through SetExtraData.
Also, as the configuration parameters are no longer environment variables, there nomenclature

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/alsaaudio.c

    r35353 r40844  
    11351135
    11361136static struct audio_option alsa_options[] = {
    1137     {"DAC_SIZE_IN_USEC", AUD_OPT_BOOL, &conf.size_in_usec_out,
     1137    {"DACSizeInUsec", AUD_OPT_BOOL, &conf.size_in_usec_out,
    11381138     "DAC period/buffer size in microseconds (otherwise in frames)", NULL, 0},
    1139     {"DAC_PERIOD_SIZE", AUD_OPT_INT, &conf.period_size_out,
     1139    {"DACPeriodSize", AUD_OPT_INT, &conf.period_size_out,
    11401140     "DAC period size", &conf.period_size_out_overriden, 0},
    1141     {"DAC_BUFFER_SIZE", AUD_OPT_INT, &conf.buffer_size_out,
     1141    {"DACBufferSize", AUD_OPT_INT, &conf.buffer_size_out,
    11421142     "DAC buffer size", &conf.buffer_size_out_overriden, 0},
    11431143
    1144     {"ADC_SIZE_IN_USEC", AUD_OPT_BOOL, &conf.size_in_usec_in,
     1144    {"ADCSizeInUsec", AUD_OPT_BOOL, &conf.size_in_usec_in,
    11451145     "ADC period/buffer size in microseconds (otherwise in frames)", NULL, 0},
    1146     {"ADC_PERIOD_SIZE", AUD_OPT_INT, &conf.period_size_in,
     1146    {"ADCPeriodSize", AUD_OPT_INT, &conf.period_size_in,
    11471147     "ADC period size", &conf.period_size_in_overriden, 0},
    1148     {"ADC_BUFFER_SIZE", AUD_OPT_INT, &conf.buffer_size_in,
     1148    {"ADCBufferSize", AUD_OPT_INT, &conf.buffer_size_in,
    11491149     "ADC buffer size", &conf.buffer_size_in_overriden, 0},
    11501150
    1151     {"THRESHOLD", AUD_OPT_INT, &conf.threshold,
     1151    {"Threshold", AUD_OPT_INT, &conf.threshold,
    11521152     "(undocumented)", NULL, 0},
    11531153
    1154     {"DAC_DEV", AUD_OPT_STR, &conf.pcm_name_out,
     1154    {"DACDev", AUD_OPT_STR, &conf.pcm_name_out,
    11551155     "DAC device name (for instance dmix)", NULL, 0},
    11561156
    1157     {"ADC_DEV", AUD_OPT_STR, &conf.pcm_name_in,
     1157    {"ADCDev", AUD_OPT_STR, &conf.pcm_name_in,
    11581158     "ADC device name", NULL, 0},
    11591159
    1160     {"VERBOSE", AUD_OPT_BOOL, &conf.verbose,
     1160    {"Verbose", AUD_OPT_BOOL, &conf.verbose,
    11611161     "Behave in a more verbose way", NULL, 0},
    11621162
  • trunk/src/VBox/Devices/Audio/audio.c

    r35582 r40844  
    362362}
    363363
    364 static audfmt_e audio_get_conf_fmt (const char *envname,
     364static audfmt_e audio_get_conf_fmt (PCFGMNODE pCfgHandle, const char *envname,
    365365                                    audfmt_e defval,
    366366                                    int *defaultp)
    367367{
    368     const char *var = getenv (envname);
    369     if (!var) {
     368    char *var = NULL;
     369    int rc;
     370
     371    if(pCfgHandle == NULL || envname == NULL) {
    370372        *defaultp = 1;
    371373        return defval;
    372374    }
    373     return audio_string_to_audfmt (var, defval, defaultp);
    374 }
    375 
    376 static int audio_get_conf_int (const char *key, int defval, int *defaultp)
    377 {
    378     int val;
    379     char *strval;
    380 
    381     strval = getenv (key);
    382     if (strval) {
    383         *defaultp = 0;
    384         val = atoi (strval);
    385         return val;
    386     }
    387     else {
     375
     376    rc = CFGMR3QueryStringAlloc(pCfgHandle, envname, &var);
     377    if (RT_FAILURE (rc)) {
    388378        *defaultp = 1;
    389379        return defval;
    390380    }
    391 }
    392 
    393 static const char *audio_get_conf_str (const char *key,
     381    return audio_string_to_audfmt (var, defval, defaultp);
     382}
     383
     384static int audio_get_conf_int (PCFGMNODE  pCfgHandle, const char *key, int defval, int *defaultp)
     385{
     386    int rc;
     387    uint64_t u64Data = 0;
     388    if(pCfgHandle == NULL || key == NULL) {
     389        *defaultp = 1;
     390        return defval;
     391    }
     392
     393    *defaultp = 0;
     394    rc = CFGMR3QueryInteger(pCfgHandle, key, &u64Data);
     395    if (RT_FAILURE (rc))
     396    {
     397        *defaultp = 1;
     398        return defval;
     399
     400    }
     401    else
     402    {
     403        LogFlow(("%s, Value = %d\n", key, u64Data));
     404        *defaultp = 0;
     405        return u64Data;
     406    }
     407}
     408
     409static const char *audio_get_conf_str (PCFGMNODE  pCfgHandle, const char *key,
    394410                                       const char *defval,
    395411                                       int *defaultp)
    396412{
    397     const char *val = getenv (key);
    398     if (!val) {
     413    char *val = NULL;
     414    int rc;
     415    if(pCfgHandle == NULL || key == NULL) {
     416        *defaultp = 1;
     417        return defval;
     418    }
     419
     420    rc = CFGMR3QueryStringAlloc(pCfgHandle, key, &val);
     421    if (RT_FAILURE (rc)) {
    399422        *defaultp = 1;
    400423        return defval;
     
    428451}
    429452
    430 static void audio_process_options (const char *prefix,
     453static void audio_process_options (PCFGMNODE pCfgHandle, const char *prefix,
    431454                                   struct audio_option *opt)
    432455{
    433     char *optname;
    434     const char vbox_prefix[] = "VBOX_";
    435     size_t preflen;
     456    int def;
     457    PCFGMNODE pCfgChildHandle = NULL;
     458    PCFGMNODE pCfgChildChildHandle = NULL;
    436459
    437460    if (audio_bug (AUDIO_FUNC, !prefix)) {
     
    445468    }
    446469
    447     preflen = strlen (prefix);
     470   /* if pCfgHandle is NULL, let NULL be passed to get int and get string functions..
     471    * The getter function will return default values.
     472    */
     473   if(pCfgHandle != NULL) {
     474       /* If its audio general setting, need to traverse to one child node.
     475        * /Devices/ihac97/0/LUN#0/Config/Audio
     476        */
     477       if(!strncmp(prefix, "AUDIO", 5)) {
     478            pCfgChildHandle = CFGMR3GetFirstChild(pCfgHandle);
     479            if(pCfgChildHandle) {
     480                pCfgHandle = pCfgChildHandle;
     481            }
     482        }
     483        else
     484        {
     485            /* If its driver specific configuration , then need to traverse two level deep child
     486             * child nodes. for eg. in case of DirectSoundConfiguration item
     487             * /Devices/ihac97/0/LUN#0/Config/Audio/DirectSoundConfig
     488             */
     489            pCfgChildHandle = CFGMR3GetFirstChild(pCfgHandle);
     490            if (pCfgChildHandle) {
     491                pCfgChildChildHandle = CFGMR3GetFirstChild(pCfgChildHandle);
     492                if(pCfgChildChildHandle) {
     493                   pCfgHandle = pCfgChildChildHandle;
     494                }
     495            }
     496        }
     497   }
     498
    448499
    449500    for (; opt->name; opt++) {
    450         size_t len, i;
    451         int def;
    452 
    453501        if (!opt->valp) {
    454502            dolog ("Option value pointer for `%s' is not set\n",
     
    456504            continue;
    457505        }
    458 
    459         len = strlen (opt->name);
    460         /* len of opt->name + len of prefix + size of vbox_prefix
    461          * (includes trailing zero) + zero + underscore (on behalf of
    462          * sizeof) */
    463         optname = qemu_malloc (len + preflen + sizeof (vbox_prefix) + 1);
    464         if (!optname) {
    465             dolog ("Could not allocate memory for option name `%s'\n",
    466                    opt->name);
    467             continue;
    468         }
    469 
    470         strcpy (optname, vbox_prefix);
    471 
    472         /* copy while upcasing, including trailing zero */
    473         for (i = 0; i <= preflen; ++i) {
    474             optname[i + sizeof (vbox_prefix) - 1] = toupper (prefix[i]);
    475         }
    476         strcat (optname, "_");
    477         strcat (optname, opt->name);
    478 
    479506        def = 1;
    480507        switch (opt->tag) {
     
    483510            {
    484511                int *intp = opt->valp;
    485                 *intp = audio_get_conf_int (optname, *intp, &def);
     512                *intp =   audio_get_conf_int(pCfgHandle, opt->name, *intp, &def);
    486513            }
    487514            break;
     
    490517            {
    491518                audfmt_e *fmtp = opt->valp;
    492                 *fmtp = audio_get_conf_fmt (optname, *fmtp, &def);
     519                *fmtp = audio_get_conf_fmt (pCfgHandle, opt->name, *fmtp, &def);
    493520            }
    494521            break;
     
    497524            {
    498525                const char **strp = opt->valp;
    499                 *strp = audio_get_conf_str (optname, *strp, &def);
     526                *strp = audio_get_conf_str (pCfgHandle, opt->name, *strp, &def);
    500527            }
    501528            break;
     
    503530        default:
    504531            dolog ("Bad value tag for option `%s' - %d\n",
    505                    optname, opt->tag);
     532                   opt->name, opt->tag);
    506533            break;
    507534        }
     
    511538        }
    512539        *opt->overridenp = !def;
    513         qemu_free (optname);
    514540    }
    515541}
     
    15051531static struct audio_option audio_options[] = {
    15061532    /* DAC */
    1507     {"DAC_FIXED_SETTINGS", AUD_OPT_BOOL, &conf.fixed_out.enabled,
     1533    {"DACFixedSettings", AUD_OPT_BOOL, &conf.fixed_out.enabled,
    15081534     "Use fixed settings for host DAC", NULL, 0},
    15091535
    1510     {"DAC_FIXED_FREQ", AUD_OPT_INT, &conf.fixed_out.settings.freq,
     1536    {"DACFixedFreq", AUD_OPT_INT, &conf.fixed_out.settings.freq,
    15111537     "Frequency for fixed host DAC", NULL, 0},
    15121538
    1513     {"DAC_FIXED_FMT", AUD_OPT_FMT, &conf.fixed_out.settings.fmt,
     1539    {"DACFixedFmt", AUD_OPT_FMT, &conf.fixed_out.settings.fmt,
    15141540     "Format for fixed host DAC", NULL, 0},
    15151541
    1516     {"DAC_FIXED_CHANNELS", AUD_OPT_INT, &conf.fixed_out.settings.nchannels,
     1542    {"DACFixedChannels", AUD_OPT_INT, &conf.fixed_out.settings.nchannels,
    15171543     "Number of channels for fixed DAC (1 - mono, 2 - stereo)", NULL, 0},
    15181544
    1519     {"DAC_VOICES", AUD_OPT_INT, &conf.fixed_out.nb_voices,
     1545    {"DACVoices", AUD_OPT_INT, &conf.fixed_out.nb_voices,
    15201546     "Number of voices for DAC", NULL, 0},
    15211547
    15221548    /* ADC */
    1523     {"ADC_FIXED_SETTINGS", AUD_OPT_BOOL, &conf.fixed_in.enabled,
     1549    {"ADCFixedSettings", AUD_OPT_BOOL, &conf.fixed_in.enabled,
    15241550     "Use fixed settings for host ADC", NULL, 0},
    15251551
    1526     {"ADC_FIXED_FREQ", AUD_OPT_INT, &conf.fixed_in.settings.freq,
     1552    {"ADCFixedFreq", AUD_OPT_INT, &conf.fixed_in.settings.freq,
    15271553     "Frequency for fixed host ADC", NULL, 0},
    15281554
    1529     {"ADC_FIXED_FMT", AUD_OPT_FMT, &conf.fixed_in.settings.fmt,
     1555    {"ADCFixedFmt", AUD_OPT_FMT, &conf.fixed_in.settings.fmt,
    15301556     "Format for fixed host ADC", NULL, 0},
    15311557
    1532     {"ADC_FIXED_CHANNELS", AUD_OPT_INT, &conf.fixed_in.settings.nchannels,
     1558    {"ADCFixedChannels", AUD_OPT_INT, &conf.fixed_in.settings.nchannels,
    15331559     "Number of channels for fixed ADC (1 - mono, 2 - stereo)", NULL, 0},
    15341560
    1535     {"ADC_VOICES", AUD_OPT_INT, &conf.fixed_in.nb_voices,
     1561    {"ADCVoices", AUD_OPT_INT, &conf.fixed_in.nb_voices,
    15361562     "Number of voices for ADC", NULL, 0},
    15371563
    15381564    /* Misc */
    1539     {"TIMER_FREQ", AUD_OPT_INT, &conf.period.hz,
     1565    {"TimreFreq", AUD_OPT_INT, &conf.period.hz,
    15401566     "Timer frequency in Hz (0 - use lowest possible)", NULL, 0},
    15411567
     
    15461572};
    15471573
    1548 static int audio_driver_init (AudioState *s, struct audio_driver *drv)
     1574static int audio_driver_init (PCFGMNODE pCfgHandle, AudioState *s, struct audio_driver *drv)
    15491575{
    15501576    if (drv->options) {
    1551         audio_process_options (drv->name, drv->options);
     1577        audio_process_options (pCfgHandle, drv->name, drv->options);
    15521578    }
    15531579    s->drv_opaque = drv->init ();
     
    16391665}
    16401666
    1641 static int AUD_init (PPDMDRVINS pDrvIns, const char *drvname)
     1667static int AUD_init (PCFGMNODE pCfgHandle, PPDMDRVINS pDrvIns, const char *drvname)
    16421668{
    16431669    size_t i;
     
    16551681        return rc;
    16561682
    1657     audio_process_options ("AUDIO", audio_options);
     1683    audio_process_options (pCfgHandle, "AUDIO", audio_options);
    16581684
    16591685    s->nb_hw_voices_out = conf.fixed_out.nb_voices;
     
    16791705        for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
    16801706            if (!strcmp (drvname, drvtab[i]->name)) {
    1681                 done = !audio_driver_init (s, drvtab[i]);
     1707                done = !audio_driver_init (pCfgHandle, s, drvtab[i]);
    16821708                found = 1;
    16831709                break;
     
    16961722                       drvname, drvtab[i]->name));
    16971723                drvname = drvtab[i]->name;
    1698                 done = !audio_driver_init (s, drvtab[i]);
     1724                done = !audio_driver_init (pCfgHandle, s, drvtab[i]);
    16991725            }
    17001726        }
     
    17021728
    17031729    if (!done) {
    1704         done = !audio_driver_init (s, &no_audio_driver);
     1730        done = !audio_driver_init (pCfgHandle, s, &no_audio_driver);
    17051731        if (!done) {
    17061732            dolog ("Could not initialize audio subsystem\n");
     
    17471773
    17481774    LogRel(("Audio: Using NULL audio driver\n"));
    1749     return audio_driver_init (s, &no_audio_driver);
     1775    return audio_driver_init (NULL, s, &no_audio_driver);
    17501776}
    17511777
     
    20482074        audio_streamname = NULL;
    20492075
    2050     rc = AUD_init (pDrvIns, drvname);
     2076    rc = AUD_init (pCfgHandle, pDrvIns, drvname);
    20512077    if (RT_FAILURE (rc))
    20522078        return rc;
  • trunk/src/VBox/Devices/Audio/coreaudio.c

    r39469 r40844  
    21402140static struct audio_option coreaudio_options[] =
    21412141{
    2142     {"OUTPUT_DEVICE_UID", AUD_OPT_STR, &conf.pszOutputDeviceUID,
     2142    {"OutputDeviceUID", AUD_OPT_STR, &conf.pszOutputDeviceUID,
    21432143     "UID of the output device to use", NULL, 0},
    2144     {"INPUT_DEVICE_UID", AUD_OPT_STR, &conf.pszInputDeviceUID,
     2144    {"InputDeviceUID", AUD_OPT_STR, &conf.pszInputDeviceUID,
    21452145     "UID of the input device to use", NULL, 0},
    21462146    {NULL, 0, NULL, NULL, NULL, 0}
  • trunk/src/VBox/Devices/Audio/dsoundaudio.c

    r36391 r40844  
    11091109
    11101110static struct audio_option dsound_options[] = {
    1111     {"LOCK_RETRIES", AUD_OPT_INT, &conf.lock_retries,
     1111    {"LockRetries", AUD_OPT_INT, &conf.lock_retries,
    11121112     "Number of times to attempt locking the buffer", NULL, 0},
    1113     {"RESTOURE_RETRIES", AUD_OPT_INT, &conf.restore_retries,
     1113    {"RestoreRetries", AUD_OPT_INT, &conf.restore_retries,
    11141114     "Number of times to attempt restoring the buffer", NULL, 0},
    1115     {"GETSTATUS_RETRIES", AUD_OPT_INT, &conf.getstatus_retries,
     1115    {"GetStatusRetries", AUD_OPT_INT, &conf.getstatus_retries,
    11161116     "Number of times to attempt getting status of the buffer", NULL, 0},
    1117     {"SET_PRIMARY", AUD_OPT_BOOL, &conf.set_primary,
     1117    {"SetPrimary", AUD_OPT_BOOL, &conf.set_primary,
    11181118     "Set the parameters of primary buffer", NULL, 0},
    1119     {"LATENCY_MILLIS", AUD_OPT_INT, &conf.latency_millis,
     1119    {"LatencyMillis", AUD_OPT_INT, &conf.latency_millis,
    11201120     "(undocumented)", NULL, 0},
    1121     {"PRIMARY_FREQ", AUD_OPT_INT, &conf.settings.freq,
     1121    {"PrimaryFreq", AUD_OPT_INT, &conf.settings.freq,
    11221122     "Primary buffer frequency", NULL, 0},
    1123     {"PRIMARY_CHANNELS", AUD_OPT_INT, &conf.settings.nchannels,
     1123    {"PrimaryChannels", AUD_OPT_INT, &conf.settings.nchannels,
    11241124     "Primary buffer number of channels (1 - mono, 2 - stereo)", NULL, 0},
    1125     {"PRIMARY_FMT", AUD_OPT_FMT, &conf.settings.fmt,
     1125    {"PrimaryFmt", AUD_OPT_FMT, &conf.settings.fmt,
    11261126     "Primary buffer format", NULL, 0},
    1127     {"BUFSIZE_OUT", AUD_OPT_INT, &conf.bufsize_out,
     1127    {"BufsizeOut", AUD_OPT_INT, &conf.bufsize_out,
    11281128     "(undocumented)", NULL, 0},
    1129     {"BUFSIZE_IN", AUD_OPT_INT, &conf.bufsize_in,
     1129    {"BufsizeIn", AUD_OPT_INT, &conf.bufsize_in,
    11301130     "(undocumented)", NULL, 0},
    11311131    {NULL, 0, NULL, NULL, NULL, 0}
  • trunk/src/VBox/Devices/Audio/ossaudio.c

    r35353 r40844  
    852852
    853853static struct audio_option oss_options[] = {
    854     {"FRAGSIZE", AUD_OPT_INT, &conf.fragsize,
     854    {"Fragsize", AUD_OPT_INT, &conf.fragsize,
    855855     "Fragment size in bytes", NULL, 0},
    856     {"NFRAGS", AUD_OPT_INT, &conf.nfrags,
     856    {"NFrags", AUD_OPT_INT, &conf.nfrags,
    857857     "Number of fragments", NULL, 0},
    858858#ifndef RT_OS_L4
    859     {"MMAP", AUD_OPT_BOOL, &conf.try_mmap,
     859    {"MMap", AUD_OPT_BOOL, &conf.try_mmap,
    860860     "Try using memory mapped access", NULL, 0},
    861861#endif
    862     {"DAC_DEV", AUD_OPT_STR, &conf.devpath_out,
     862    {"DACDev", AUD_OPT_STR, &conf.devpath_out,
    863863     "Path to DAC device", NULL, 0},
    864     {"ADC_DEV", AUD_OPT_STR, &conf.devpath_in,
     864    {"ADCDev", AUD_OPT_STR, &conf.devpath_in,
    865865     "Path to ADC device", NULL, 0},
    866     {"DEBUG", AUD_OPT_BOOL, &conf.debug,
     866    {"Debug", AUD_OPT_BOOL, &conf.debug,
    867867     "Turn on some debugging messages", NULL, 0},
    868868    {NULL, 0, NULL, NULL, NULL, 0}
  • trunk/src/VBox/Devices/Audio/solaudio.c

    r35353 r40844  
    844844static struct audio_option solaudio_options[] =
    845845{
    846     {"PLAY_BUFFER_SIZE", AUD_OPT_INT, &conf.cbPlayBuffer,
     846    {"PlayBufferSize", AUD_OPT_INT, &conf.cbPlayBuffer,
    847847     "Size of the buffer in bytes", NULL, 0},
    848848#if 0
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