Changeset 91451 in vbox for trunk/src/VBox
- Timestamp:
- Sep 29, 2021 8:59:35 AM (3 years ago)
- Location:
- trunk/src/VBox/ValidationKit/utils/audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkatCmdGeneric.cpp
r91088 r91451 283 283 static RTEXITCODE audioTestPlayOne(const char *pszFile, PCPDMDRVREG pDrvReg, const char *pszDevId, uint32_t cMsBufferSize, 284 284 uint32_t cMsPreBuffer, uint32_t cMsSchedulingHint, 285 uint8_t cChannels, uint8_t cbSample, uint32_t uHz, 285 uint8_t cChannels, uint8_t cbSample, uint32_t uHz, uint8_t uVolumePercent, 286 286 bool fWithDrvAudio, bool fWithMixer) 287 287 { … … 343 343 */ 344 344 if ( !fWithMixer 345 && !PDMAudioPropsAreEqual(&WaveFile.Props, &pStream->Cfg.Props)) 345 && ( !PDMAudioPropsAreEqual(&WaveFile.Props, &pStream->Cfg.Props) 346 || uVolumePercent != 100) 347 ) 346 348 { 347 349 RTMsgInfo("Enabling the mixer buffer.\n"); … … 361 363 PDMAudioPropsToString(&pStream->Cfg.Props, szTmp, sizeof(szTmp)), 362 364 pStream->cbBackend, fWithMixer ? " mixed" : ""); 365 366 if (fWithMixer) 367 AudioTestMixStreamSetVolume(&Mix, uVolumePercent); 363 368 364 369 /* … … 439 444 */ 440 445 if ( !fWithMixer 441 && !PDMAudioPropsAreEqual(&pToneParms->Props, &TstStream.pStream->Cfg.Props)) 446 && ( !PDMAudioPropsAreEqual(&pToneParms->Props, &TstStream.pStream->Cfg.Props) 447 || pToneParms->uVolumePercent != 100) 448 ) 442 449 { 443 450 RTMsgInfo("Enabling the mixer buffer.\n"); … … 463 470 if (RT_SUCCESS(rc)) 464 471 { 472 if (fWithMixer) 473 AudioTestMixStreamSetVolume(&TstStream.Mix, pToneParms->uVolumePercent); 474 465 475 rc = audioTestPlayTone(NULL /* pTstEnv */, &TstStream, pToneParms); 466 476 if (RT_SUCCESS(rc)) … … 491 501 492 502 /** 503 * Long option values for the 'play' command. 504 */ 505 enum 506 { 507 VKAT_PLAY_OPT_VOL = 900 508 }; 509 510 511 /** 493 512 * Options for 'play'. 494 513 */ … … 504 523 { "--with-drv-audio", 'd', RTGETOPT_REQ_NOTHING }, 505 524 { "--with-mixer", 'm', RTGETOPT_REQ_NOTHING }, 525 { "--vol", VKAT_PLAY_OPT_VOL, RTGETOPT_REQ_UINT8 }, 506 526 }; 507 527 … … 512 532 switch (pOpt->iShort) 513 533 { 514 case 'b': return "The audio backend to use"; 515 case 'c': return "Number of backend output channels"; 516 case 'd': return "Go via DrvAudio instead of directly interfacing with the backend"; 517 case 'f': return "Output frequency (Hz)"; 518 case 'z': return "Output sample size (bits)"; 519 case 't': return "Plays a test tone. Can be specified multiple times"; 520 case 'm': return "Go via the mixer"; 521 case 'o': return "The ID of the output device to use"; 522 default: return NULL; 534 case 'b': return "The audio backend to use"; 535 case 'c': return "Number of backend output channels"; 536 case 'd': return "Go via DrvAudio instead of directly interfacing with the backend"; 537 case 'f': return "Output frequency (Hz)"; 538 case 'z': return "Output sample size (bits)"; 539 case 't': return "Plays a test tone. Can be specified multiple times"; 540 case 'm': return "Go via the mixer"; 541 case 'o': return "The ID of the output device to use"; 542 case VKAT_PLAY_OPT_VOL: return "Volume (in percent, 0-100) to use"; 543 default: return NULL; 523 544 } 524 545 } … … 545 566 uint8_t cChannels = 0; 546 567 uint32_t uHz = 0; 568 uint8_t uVolumePercent = 100; /* Use maximum volume by default. */ 547 569 548 570 /* Argument processing loop: */ … … 587 609 break; 588 610 611 case VKAT_PLAY_OPT_VOL: 612 uVolumePercent = ValueUnion.u8; 613 if (uVolumePercent > 100) 614 return RTMsgErrorExit(RTEXITCODE_SYNTAX, "Invalid volume (0-100)"); 615 break; 616 589 617 case VINF_GETOPT_NOT_OPTION: 590 618 { … … 593 621 594 622 RTEXITCODE rcExit = audioTestPlayOne(ValueUnion.psz, pDrvReg, pszDevId, cMsBufferSize, cMsPreBuffer, 595 cMsSchedulingHint, cChannels, cbSample, uHz, fWithDrvAudio, fWithMixer); 623 cMsSchedulingHint, cChannels, cbSample, uHz, uVolumePercent, 624 fWithDrvAudio, fWithMixer); 596 625 if (rcExit != RTEXITCODE_SUCCESS) 597 626 return rcExit; … … 624 653 #endif 625 654 ToneParms.msSequel = 0; /** @todo Implement analyzing this first! */ 626 ToneParms.uVolumePercent = 100; /** @todo Implement analyzing this first! */655 ToneParms.uVolumePercent = uVolumePercent; 627 656 628 657 RTEXITCODE rcExit = audioTestPlayTestToneOne(&ToneParms, pDrvReg, pszDevId, cMsBufferSize, cMsPreBuffer, -
trunk/src/VBox/ValidationKit/utils/audio/vkatDriverStack.cpp
r91089 r91451 1557 1557 return VINF_SUCCESS; 1558 1558 } 1559 1560 /** 1561 * Sets the volume of a mixing stream. 1562 * 1563 * @param pMix Mixing stream to set volume for. 1564 * @param uVolumePercent Volume to set (in percent, 0-100). 1565 */ 1566 void AudioTestMixStreamSetVolume(PAUDIOTESTDRVMIXSTREAM pMix, uint8_t uVolumePercent) 1567 { 1568 AssertReturnVoid(pMix->fDoMixing); 1569 1570 PDMAUDIOVOLUME Vol; 1571 RT_ZERO(Vol); 1572 for (size_t i = 0; i < RT_ELEMENTS(Vol.auChannels); i++) 1573 Vol.auChannels[i] = (PDMAUDIO_VOLUME_MAX / 100) * uVolumePercent; 1574 AudioMixBufSetVolume(&pMix->MixBuf, &Vol); 1575 } 1576 -
trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h
r91413 r91451 435 435 uint32_t AudioTestMixStreamGetReadable(PAUDIOTESTDRVMIXSTREAM pMix); 436 436 int AudioTestMixStreamCapture(PAUDIOTESTDRVMIXSTREAM pMix, void *pvBuf, uint32_t cbBuf, uint32_t *pcbCaptured); 437 void AudioTestMixStreamSetVolume(PAUDIOTESTDRVMIXSTREAM pMix, uint8_t uVol); 437 438 /** @} */ 438 439
Note:
See TracChangeset
for help on using the changeset viewer.