- Timestamp:
- Apr 26, 2021 7:59:37 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88710 r88714 48 48 * Structures and Typedefs * 49 49 *********************************************************************************************************************************/ 50 typedef enum51 {52 AUD_OPT_INT,53 AUD_OPT_FMT,54 AUD_OPT_STR,55 AUD_OPT_BOOL56 } audio_option_tag_e;57 58 typedef struct audio_option59 {60 const char *name;61 audio_option_tag_e tag;62 void *valp;63 const char *descr;64 int *overridenp;65 int overriden;66 } audio_option;67 68 50 /** 69 51 * Audio stream context. … … 362 344 363 345 #ifndef VBOX_AUDIO_TESTCASE 364 365 # if 0 /* unused */ 366 367 static PDMAUDIOFMT drvAudioGetConfFormat(PCFGMNODE pCfgHandle, const char *pszKey, 368 PDMAUDIOFMT enmDefault, bool *pfDefault) 369 { 370 if ( pCfgHandle == NULL 371 || pszKey == NULL) 372 { 373 *pfDefault = true; 374 return enmDefault; 375 } 376 377 char *pszValue = NULL; 378 int rc = CFGMR3QueryStringAlloc(pCfgHandle, pszKey, &pszValue); 379 if (RT_FAILURE(rc)) 380 { 381 *pfDefault = true; 382 return enmDefault; 383 } 384 385 PDMAUDIOFMT fmt = AudioHlpStrToAudFmt(pszValue); 386 if (fmt == PDMAUDIOFMT_INVALID) 387 { 388 *pfDefault = true; 389 return enmDefault; 390 } 391 392 *pfDefault = false; 393 return fmt; 394 } 395 396 static int drvAudioGetConfInt(PCFGMNODE pCfgHandle, const char *pszKey, 397 int iDefault, bool *pfDefault) 398 { 399 400 if ( pCfgHandle == NULL 401 || pszKey == NULL) 402 { 403 *pfDefault = true; 404 return iDefault; 405 } 406 407 uint64_t u64Data = 0; 408 int rc = CFGMR3QueryInteger(pCfgHandle, pszKey, &u64Data); 409 if (RT_FAILURE(rc)) 410 { 411 *pfDefault = true; 412 return iDefault; 413 414 } 415 416 *pfDefault = false; 417 return u64Data; 418 } 419 420 static const char *drvAudioGetConfStr(PCFGMNODE pCfgHandle, const char *pszKey, 421 const char *pszDefault, bool *pfDefault) 422 { 423 if ( pCfgHandle == NULL 424 || pszKey == NULL) 425 { 426 *pfDefault = true; 427 return pszDefault; 428 } 429 430 char *pszValue = NULL; 431 int rc = CFGMR3QueryStringAlloc(pCfgHandle, pszKey, &pszValue); 432 if (RT_FAILURE(rc)) 433 { 434 *pfDefault = true; 435 return pszDefault; 436 } 437 438 *pfDefault = false; 439 return pszValue; 440 } 441 442 # endif /* unused */ 443 444 #ifdef LOG_ENABLED 346 # ifdef LOG_ENABLED 445 347 446 348 /** Buffer size for dbgAudioStreamStatusToStr. */ 447 # define DRVAUDIO_STATUS_STR_MAX sizeof("INITIALIZED ENABLED PAUSED PENDING_DISABLED PENDING_REINIT 0x12345678")349 # define DRVAUDIO_STATUS_STR_MAX sizeof("INITIALIZED ENABLED PAUSED PENDING_DISABLED PENDING_REINIT 0x12345678") 448 350 449 351 /** … … 493 395 } 494 396 495 #endif /* defined(LOG_ENABLED) */ 496 497 # if 0 /* unused */ 498 static int drvAudioProcessOptions(PCFGMNODE pCfgHandle, const char *pszPrefix, audio_option *paOpts, size_t cOpts) 499 { 500 AssertPtrReturn(pCfgHandle, VERR_INVALID_POINTER); 501 AssertPtrReturn(pszPrefix, VERR_INVALID_POINTER); 502 /* oaOpts and cOpts are optional. */ 503 504 PCFGMNODE pCfgChildHandle = NULL; 505 PCFGMNODE pCfgChildChildHandle = NULL; 506 507 /* If pCfgHandle is NULL, let NULL be passed to get int and get string functions.. 508 * The getter function will return default values. 509 */ 510 if (pCfgHandle != NULL) 511 { 512 /* If its audio general setting, need to traverse to one child node. 513 * /Devices/ichac97/0/LUN#0/Config/Audio 514 */ 515 if(!strncmp(pszPrefix, "AUDIO", 5)) /** @todo Use a \#define */ 516 { 517 pCfgChildHandle = CFGMR3GetFirstChild(pCfgHandle); 518 if(pCfgChildHandle) 519 pCfgHandle = pCfgChildHandle; 520 } 521 else 522 { 523 /* If its driver specific configuration , then need to traverse two level deep child 524 * child nodes. for eg. in case of DirectSoundConfiguration item 525 * /Devices/ichac97/0/LUN#0/Config/Audio/DirectSoundConfig 526 */ 527 pCfgChildHandle = CFGMR3GetFirstChild(pCfgHandle); 528 if (pCfgChildHandle) 529 { 530 pCfgChildChildHandle = CFGMR3GetFirstChild(pCfgChildHandle); 531 if (pCfgChildChildHandle) 532 pCfgHandle = pCfgChildChildHandle; 533 } 534 } 535 } 536 537 for (size_t i = 0; i < cOpts; i++) 538 { 539 audio_option *pOpt = &paOpts[i]; 540 if (!pOpt->valp) 541 { 542 LogFlowFunc(("Option value pointer for `%s' is not set\n", pOpt->name)); 543 continue; 544 } 545 546 bool fUseDefault; 547 548 switch (pOpt->tag) 549 { 550 case AUD_OPT_BOOL: 551 case AUD_OPT_INT: 552 { 553 int *intp = (int *)pOpt->valp; 554 *intp = drvAudioGetConfInt(pCfgHandle, pOpt->name, *intp, &fUseDefault); 555 556 break; 557 } 558 559 case AUD_OPT_FMT: 560 { 561 PDMAUDIOFMT *fmtp = (PDMAUDIOFMT *)pOpt->valp; 562 *fmtp = drvAudioGetConfFormat(pCfgHandle, pOpt->name, *fmtp, &fUseDefault); 563 564 break; 565 } 566 567 case AUD_OPT_STR: 568 { 569 const char **strp = (const char **)pOpt->valp; 570 *strp = drvAudioGetConfStr(pCfgHandle, pOpt->name, *strp, &fUseDefault); 571 572 break; 573 } 574 575 default: 576 LogFlowFunc(("Bad value tag for option `%s' - %d\n", pOpt->name, pOpt->tag)); 577 fUseDefault = false; 578 break; 579 } 580 581 if (!pOpt->overridenp) 582 pOpt->overridenp = &pOpt->overriden; 583 584 *pOpt->overridenp = !fUseDefault; 585 } 586 587 return VINF_SUCCESS; 588 } 589 # endif /* unused */ 397 # endif /* defined(LOG_ENABLED) */ 590 398 #endif /* !VBOX_AUDIO_TESTCASE */ 591 399
Note:
See TracChangeset
for help on using the changeset viewer.