Changeset 55387 in vbox
- Timestamp:
- Apr 22, 2015 4:49:20 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99726
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp
r55380 r55387 1139 1139 1140 1140 pMixBuf->Volume.fMuted = pVol->fMuted; 1141 pMixBuf->Volume.uLeft = (UINT64_C(0x 100000000) * pVol->uLeft) / 255;1142 pMixBuf->Volume.uRight = (UINT64_C(0x 100000000) * pVol->uRight) / 255;1141 pMixBuf->Volume.uLeft = (UINT64_C(0x80000000) * pVol->uLeft) / 255; 1142 pMixBuf->Volume.uRight = (UINT64_C(0x80000000) * pVol->uRight) / 255; 1143 1143 1144 1144 LogFlowFunc(("\t-> lVol=%RU32, rVol=%RU32\n", pMixBuf->Volume.uLeft, pMixBuf->Volume.uRight)); -
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r55379 r55387 38 38 39 39 40 static int audioMixerUpdateSinkVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster , const PPDMAUDIOVOLUME pVolSink);40 static int audioMixerUpdateSinkVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster); 41 41 42 42 … … 276 276 RTListForEach(&pMixer->lstSinks, pSink, AUDMIXSINK, Node) 277 277 { 278 int rc2 = audioMixerUpdateSinkVolume(pSink, &pMixer->VolMaster , &pSink->Volume);278 int rc2 = audioMixerUpdateSinkVolume(pSink, &pMixer->VolMaster); 279 279 AssertRC(rc2); 280 280 } … … 411 411 } 412 412 413 static inline PDMAUDIOVOLUME audioMixerVolCalc(PPDMAUDIOVOLUME pVol) 414 { 415 uint32_t u32VolumeLeft = pVol->uLeft; 416 uint32_t u32VolumeRight = pVol->uRight; 417 /* 0x00..0xff => 0x01..0x100 */ 418 if (u32VolumeLeft) 419 u32VolumeLeft++; 420 if (u32VolumeRight) 421 u32VolumeRight++; 422 423 PDMAUDIOVOLUME volOut; 424 volOut.fMuted = pVol->fMuted; 425 volOut.uLeft = u32VolumeLeft * 0x80000000; /* Maximum is 0x80000000 */ 426 volOut.uRight = u32VolumeRight * 0x80000000; /* Maximum is 0x80000000 */ 427 428 return volOut; 429 } 430 431 static inline PDMAUDIOVOLUME audioMixerVolMix(const PPDMAUDIOVOLUME pVolMaster, PPDMAUDIOVOLUME pVol) 432 { 433 PDMAUDIOVOLUME volOut; 434 volOut.fMuted = pVolMaster->fMuted || pVol->fMuted; 435 volOut.uLeft = ASMMultU64ByU32DivByU32(pVolMaster->uLeft, pVol->uLeft, 0x80000000U); /* Maximum is 0x80000000U */ 436 volOut.uRight = ASMMultU64ByU32DivByU32(pVolMaster->uRight, pVol->uRight, 0x80000000U); /* Maximum is 0x80000000U */ 437 438 LogFlowFunc(("pMaster=%p, fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", 439 pVolMaster, pVolMaster->fMuted, pVolMaster->uLeft, pVolMaster->uRight)); 440 LogFlowFunc(("pVol=%p, fMuted=%RTbool, lVol=%RU32, rVol=%RU32 => fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", 441 pVol, pVol->fMuted, pVol->uLeft, pVol->uRight, volOut.fMuted, volOut.uLeft, volOut.uRight)); 442 443 return volOut; 444 } 445 446 static int audioMixerUpdateSinkVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster, const PPDMAUDIOVOLUME pVolSink) 413 static int audioMixerUpdateSinkVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster) 447 414 { 448 415 AssertPtrReturn(pSink, VERR_INVALID_POINTER); 449 416 AssertPtrReturn(pVolMaster, VERR_INVALID_POINTER); 450 AssertPtrReturn(pVolSink, VERR_INVALID_POINTER);451 417 452 418 LogFlowFunc(("Master fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", … … 458 424 459 425 PDMAUDIOVOLUME volSink; 460 volSink.fMuted = pVolMaster->fMuted || p VolSink->fMuted;461 volSink.uLeft = (p VolSink->uLeft * pVolMaster->uLeft) / UINT8_MAX;462 volSink.uRight = (p VolSink->uRight * pVolMaster->uRight) / UINT8_MAX;426 volSink.fMuted = pVolMaster->fMuted || pSink->Volume.fMuted; 427 volSink.uLeft = (pSink->Volume.uLeft * pVolMaster->uLeft) / UINT8_MAX; 428 volSink.uRight = (pSink->Volume.uRight * pVolMaster->uRight) / UINT8_MAX; 463 429 464 430 LogFlowFunc(("\t-> fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", … … 480 446 } 481 447 448 /** Set the master volume of the mixer. */ 482 449 int audioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol) 483 450 { … … 485 452 AssertPtrReturn(pVol, VERR_INVALID_POINTER); 486 453 487 pMixer->VolMaster = *pVol; //= audioMixerVolCalc(pVol);454 pMixer->VolMaster = *pVol; 488 455 489 456 LogFlowFunc(("%s: lVol=%RU32, rVol=%RU32 => fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", … … 495 462 } 496 463 464 /** Set the volume of an individual sink. */ 497 465 int audioMixerSetSinkVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol) 498 466 { 499 467 AssertPtrReturn(pSink, VERR_INVALID_POINTER); 500 468 AssertPtrReturn(pVol, VERR_INVALID_POINTER); 469 AssertPtr(pSink->pParent); 501 470 502 471 LogFlowFunc(("%s: fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", pSink->pszName, pVol->fMuted, pVol->uLeft, pVol->uRight)); 503 472 504 AssertPtr(pSink->pParent);505 return audioMixerUpdateSinkVolume(pSink, &pSink->pParent->VolMaster, pVol); 506 } 507 473 pSink->Volume = *pVol; 474 475 return audioMixerUpdateSinkVolume(pSink, &pSink->pParent->VolMaster); 476 }
Note:
See TracChangeset
for help on using the changeset viewer.