Changeset 40844 in vbox
- Timestamp:
- Apr 10, 2012 10:37:46 AM (13 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/alsaaudio.c
r35353 r40844 1135 1135 1136 1136 static 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, 1138 1138 "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, 1140 1140 "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, 1142 1142 "DAC buffer size", &conf.buffer_size_out_overriden, 0}, 1143 1143 1144 {"ADC _SIZE_IN_USEC", AUD_OPT_BOOL, &conf.size_in_usec_in,1144 {"ADCSizeInUsec", AUD_OPT_BOOL, &conf.size_in_usec_in, 1145 1145 "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, 1147 1147 "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, 1149 1149 "ADC buffer size", &conf.buffer_size_in_overriden, 0}, 1150 1150 1151 {"T HRESHOLD", AUD_OPT_INT, &conf.threshold,1151 {"Threshold", AUD_OPT_INT, &conf.threshold, 1152 1152 "(undocumented)", NULL, 0}, 1153 1153 1154 {"DAC _DEV", AUD_OPT_STR, &conf.pcm_name_out,1154 {"DACDev", AUD_OPT_STR, &conf.pcm_name_out, 1155 1155 "DAC device name (for instance dmix)", NULL, 0}, 1156 1156 1157 {"ADC _DEV", AUD_OPT_STR, &conf.pcm_name_in,1157 {"ADCDev", AUD_OPT_STR, &conf.pcm_name_in, 1158 1158 "ADC device name", NULL, 0}, 1159 1159 1160 {"V ERBOSE", AUD_OPT_BOOL, &conf.verbose,1160 {"Verbose", AUD_OPT_BOOL, &conf.verbose, 1161 1161 "Behave in a more verbose way", NULL, 0}, 1162 1162 -
trunk/src/VBox/Devices/Audio/audio.c
r35582 r40844 362 362 } 363 363 364 static audfmt_e audio_get_conf_fmt ( const char *envname,364 static audfmt_e audio_get_conf_fmt (PCFGMNODE pCfgHandle, const char *envname, 365 365 audfmt_e defval, 366 366 int *defaultp) 367 367 { 368 const char *var = getenv (envname); 369 if (!var) { 368 char *var = NULL; 369 int rc; 370 371 if(pCfgHandle == NULL || envname == NULL) { 370 372 *defaultp = 1; 371 373 return defval; 372 374 } 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)) { 388 378 *defaultp = 1; 389 379 return defval; 390 380 } 391 } 392 393 static const char *audio_get_conf_str (const char *key, 381 return audio_string_to_audfmt (var, defval, defaultp); 382 } 383 384 static 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 409 static const char *audio_get_conf_str (PCFGMNODE pCfgHandle, const char *key, 394 410 const char *defval, 395 411 int *defaultp) 396 412 { 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)) { 399 422 *defaultp = 1; 400 423 return defval; … … 428 451 } 429 452 430 static void audio_process_options ( const char *prefix,453 static void audio_process_options (PCFGMNODE pCfgHandle, const char *prefix, 431 454 struct audio_option *opt) 432 455 { 433 char *optname;434 const char vbox_prefix[] = "VBOX_";435 size_t preflen;456 int def; 457 PCFGMNODE pCfgChildHandle = NULL; 458 PCFGMNODE pCfgChildChildHandle = NULL; 436 459 437 460 if (audio_bug (AUDIO_FUNC, !prefix)) { … … 445 468 } 446 469 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 448 499 449 500 for (; opt->name; opt++) { 450 size_t len, i;451 int def;452 453 501 if (!opt->valp) { 454 502 dolog ("Option value pointer for `%s' is not set\n", … … 456 504 continue; 457 505 } 458 459 len = strlen (opt->name);460 /* len of opt->name + len of prefix + size of vbox_prefix461 * (includes trailing zero) + zero + underscore (on behalf of462 * 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 479 506 def = 1; 480 507 switch (opt->tag) { … … 483 510 { 484 511 int *intp = opt->valp; 485 *intp = audio_get_conf_int (optname, *intp, &def);512 *intp = audio_get_conf_int(pCfgHandle, opt->name, *intp, &def); 486 513 } 487 514 break; … … 490 517 { 491 518 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); 493 520 } 494 521 break; … … 497 524 { 498 525 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); 500 527 } 501 528 break; … … 503 530 default: 504 531 dolog ("Bad value tag for option `%s' - %d\n", 505 opt name, opt->tag);532 opt->name, opt->tag); 506 533 break; 507 534 } … … 511 538 } 512 539 *opt->overridenp = !def; 513 qemu_free (optname);514 540 } 515 541 } … … 1505 1531 static struct audio_option audio_options[] = { 1506 1532 /* DAC */ 1507 {"DAC _FIXED_SETTINGS", AUD_OPT_BOOL, &conf.fixed_out.enabled,1533 {"DACFixedSettings", AUD_OPT_BOOL, &conf.fixed_out.enabled, 1508 1534 "Use fixed settings for host DAC", NULL, 0}, 1509 1535 1510 {"DAC _FIXED_FREQ", AUD_OPT_INT, &conf.fixed_out.settings.freq,1536 {"DACFixedFreq", AUD_OPT_INT, &conf.fixed_out.settings.freq, 1511 1537 "Frequency for fixed host DAC", NULL, 0}, 1512 1538 1513 {"DAC _FIXED_FMT", AUD_OPT_FMT, &conf.fixed_out.settings.fmt,1539 {"DACFixedFmt", AUD_OPT_FMT, &conf.fixed_out.settings.fmt, 1514 1540 "Format for fixed host DAC", NULL, 0}, 1515 1541 1516 {"DAC _FIXED_CHANNELS", AUD_OPT_INT, &conf.fixed_out.settings.nchannels,1542 {"DACFixedChannels", AUD_OPT_INT, &conf.fixed_out.settings.nchannels, 1517 1543 "Number of channels for fixed DAC (1 - mono, 2 - stereo)", NULL, 0}, 1518 1544 1519 {"DAC _VOICES", AUD_OPT_INT, &conf.fixed_out.nb_voices,1545 {"DACVoices", AUD_OPT_INT, &conf.fixed_out.nb_voices, 1520 1546 "Number of voices for DAC", NULL, 0}, 1521 1547 1522 1548 /* ADC */ 1523 {"ADC _FIXED_SETTINGS", AUD_OPT_BOOL, &conf.fixed_in.enabled,1549 {"ADCFixedSettings", AUD_OPT_BOOL, &conf.fixed_in.enabled, 1524 1550 "Use fixed settings for host ADC", NULL, 0}, 1525 1551 1526 {"ADC _FIXED_FREQ", AUD_OPT_INT, &conf.fixed_in.settings.freq,1552 {"ADCFixedFreq", AUD_OPT_INT, &conf.fixed_in.settings.freq, 1527 1553 "Frequency for fixed host ADC", NULL, 0}, 1528 1554 1529 {"ADC _FIXED_FMT", AUD_OPT_FMT, &conf.fixed_in.settings.fmt,1555 {"ADCFixedFmt", AUD_OPT_FMT, &conf.fixed_in.settings.fmt, 1530 1556 "Format for fixed host ADC", NULL, 0}, 1531 1557 1532 {"ADC _FIXED_CHANNELS", AUD_OPT_INT, &conf.fixed_in.settings.nchannels,1558 {"ADCFixedChannels", AUD_OPT_INT, &conf.fixed_in.settings.nchannels, 1533 1559 "Number of channels for fixed ADC (1 - mono, 2 - stereo)", NULL, 0}, 1534 1560 1535 {"ADC _VOICES", AUD_OPT_INT, &conf.fixed_in.nb_voices,1561 {"ADCVoices", AUD_OPT_INT, &conf.fixed_in.nb_voices, 1536 1562 "Number of voices for ADC", NULL, 0}, 1537 1563 1538 1564 /* Misc */ 1539 {"T IMER_FREQ", AUD_OPT_INT, &conf.period.hz,1565 {"TimreFreq", AUD_OPT_INT, &conf.period.hz, 1540 1566 "Timer frequency in Hz (0 - use lowest possible)", NULL, 0}, 1541 1567 … … 1546 1572 }; 1547 1573 1548 static int audio_driver_init ( AudioState *s, struct audio_driver *drv)1574 static int audio_driver_init (PCFGMNODE pCfgHandle, AudioState *s, struct audio_driver *drv) 1549 1575 { 1550 1576 if (drv->options) { 1551 audio_process_options ( drv->name, drv->options);1577 audio_process_options (pCfgHandle, drv->name, drv->options); 1552 1578 } 1553 1579 s->drv_opaque = drv->init (); … … 1639 1665 } 1640 1666 1641 static int AUD_init (P PDMDRVINS pDrvIns, const char *drvname)1667 static int AUD_init (PCFGMNODE pCfgHandle, PPDMDRVINS pDrvIns, const char *drvname) 1642 1668 { 1643 1669 size_t i; … … 1655 1681 return rc; 1656 1682 1657 audio_process_options ( "AUDIO", audio_options);1683 audio_process_options (pCfgHandle, "AUDIO", audio_options); 1658 1684 1659 1685 s->nb_hw_voices_out = conf.fixed_out.nb_voices; … … 1679 1705 for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) { 1680 1706 if (!strcmp (drvname, drvtab[i]->name)) { 1681 done = !audio_driver_init ( s, drvtab[i]);1707 done = !audio_driver_init (pCfgHandle, s, drvtab[i]); 1682 1708 found = 1; 1683 1709 break; … … 1696 1722 drvname, drvtab[i]->name)); 1697 1723 drvname = drvtab[i]->name; 1698 done = !audio_driver_init ( s, drvtab[i]);1724 done = !audio_driver_init (pCfgHandle, s, drvtab[i]); 1699 1725 } 1700 1726 } … … 1702 1728 1703 1729 if (!done) { 1704 done = !audio_driver_init ( s, &no_audio_driver);1730 done = !audio_driver_init (pCfgHandle, s, &no_audio_driver); 1705 1731 if (!done) { 1706 1732 dolog ("Could not initialize audio subsystem\n"); … … 1747 1773 1748 1774 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); 1750 1776 } 1751 1777 … … 2048 2074 audio_streamname = NULL; 2049 2075 2050 rc = AUD_init (p DrvIns, drvname);2076 rc = AUD_init (pCfgHandle, pDrvIns, drvname); 2051 2077 if (RT_FAILURE (rc)) 2052 2078 return rc; -
trunk/src/VBox/Devices/Audio/coreaudio.c
r39469 r40844 2140 2140 static struct audio_option coreaudio_options[] = 2141 2141 { 2142 {"O UTPUT_DEVICE_UID", AUD_OPT_STR, &conf.pszOutputDeviceUID,2142 {"OutputDeviceUID", AUD_OPT_STR, &conf.pszOutputDeviceUID, 2143 2143 "UID of the output device to use", NULL, 0}, 2144 {"I NPUT_DEVICE_UID", AUD_OPT_STR, &conf.pszInputDeviceUID,2144 {"InputDeviceUID", AUD_OPT_STR, &conf.pszInputDeviceUID, 2145 2145 "UID of the input device to use", NULL, 0}, 2146 2146 {NULL, 0, NULL, NULL, NULL, 0} -
trunk/src/VBox/Devices/Audio/dsoundaudio.c
r36391 r40844 1109 1109 1110 1110 static struct audio_option dsound_options[] = { 1111 {"L OCK_RETRIES", AUD_OPT_INT, &conf.lock_retries,1111 {"LockRetries", AUD_OPT_INT, &conf.lock_retries, 1112 1112 "Number of times to attempt locking the buffer", NULL, 0}, 1113 {"R ESTOURE_RETRIES", AUD_OPT_INT, &conf.restore_retries,1113 {"RestoreRetries", AUD_OPT_INT, &conf.restore_retries, 1114 1114 "Number of times to attempt restoring the buffer", NULL, 0}, 1115 {"G ETSTATUS_RETRIES", AUD_OPT_INT, &conf.getstatus_retries,1115 {"GetStatusRetries", AUD_OPT_INT, &conf.getstatus_retries, 1116 1116 "Number of times to attempt getting status of the buffer", NULL, 0}, 1117 {"S ET_PRIMARY", AUD_OPT_BOOL, &conf.set_primary,1117 {"SetPrimary", AUD_OPT_BOOL, &conf.set_primary, 1118 1118 "Set the parameters of primary buffer", NULL, 0}, 1119 {"L ATENCY_MILLIS", AUD_OPT_INT, &conf.latency_millis,1119 {"LatencyMillis", AUD_OPT_INT, &conf.latency_millis, 1120 1120 "(undocumented)", NULL, 0}, 1121 {"P RIMARY_FREQ", AUD_OPT_INT, &conf.settings.freq,1121 {"PrimaryFreq", AUD_OPT_INT, &conf.settings.freq, 1122 1122 "Primary buffer frequency", NULL, 0}, 1123 {"P RIMARY_CHANNELS", AUD_OPT_INT, &conf.settings.nchannels,1123 {"PrimaryChannels", AUD_OPT_INT, &conf.settings.nchannels, 1124 1124 "Primary buffer number of channels (1 - mono, 2 - stereo)", NULL, 0}, 1125 {"P RIMARY_FMT", AUD_OPT_FMT, &conf.settings.fmt,1125 {"PrimaryFmt", AUD_OPT_FMT, &conf.settings.fmt, 1126 1126 "Primary buffer format", NULL, 0}, 1127 {"B UFSIZE_OUT", AUD_OPT_INT, &conf.bufsize_out,1127 {"BufsizeOut", AUD_OPT_INT, &conf.bufsize_out, 1128 1128 "(undocumented)", NULL, 0}, 1129 {"B UFSIZE_IN", AUD_OPT_INT, &conf.bufsize_in,1129 {"BufsizeIn", AUD_OPT_INT, &conf.bufsize_in, 1130 1130 "(undocumented)", NULL, 0}, 1131 1131 {NULL, 0, NULL, NULL, NULL, 0} -
trunk/src/VBox/Devices/Audio/ossaudio.c
r35353 r40844 852 852 853 853 static struct audio_option oss_options[] = { 854 {"F RAGSIZE", AUD_OPT_INT, &conf.fragsize,854 {"Fragsize", AUD_OPT_INT, &conf.fragsize, 855 855 "Fragment size in bytes", NULL, 0}, 856 {"NF RAGS", AUD_OPT_INT, &conf.nfrags,856 {"NFrags", AUD_OPT_INT, &conf.nfrags, 857 857 "Number of fragments", NULL, 0}, 858 858 #ifndef RT_OS_L4 859 {"MM AP", AUD_OPT_BOOL, &conf.try_mmap,859 {"MMap", AUD_OPT_BOOL, &conf.try_mmap, 860 860 "Try using memory mapped access", NULL, 0}, 861 861 #endif 862 {"DAC _DEV", AUD_OPT_STR, &conf.devpath_out,862 {"DACDev", AUD_OPT_STR, &conf.devpath_out, 863 863 "Path to DAC device", NULL, 0}, 864 {"ADC _DEV", AUD_OPT_STR, &conf.devpath_in,864 {"ADCDev", AUD_OPT_STR, &conf.devpath_in, 865 865 "Path to ADC device", NULL, 0}, 866 {"D EBUG", AUD_OPT_BOOL, &conf.debug,866 {"Debug", AUD_OPT_BOOL, &conf.debug, 867 867 "Turn on some debugging messages", NULL, 0}, 868 868 {NULL, 0, NULL, NULL, NULL, 0} -
trunk/src/VBox/Devices/Audio/solaudio.c
r35353 r40844 844 844 static struct audio_option solaudio_options[] = 845 845 { 846 {"P LAY_BUFFER_SIZE", AUD_OPT_INT, &conf.cbPlayBuffer,846 {"PlayBufferSize", AUD_OPT_INT, &conf.cbPlayBuffer, 847 847 "Size of the buffer in bytes", NULL, 0}, 848 848 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.