VirtualBox

Changeset 55387 in vbox


Ignore:
Timestamp:
Apr 22, 2015 4:49:20 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99726
Message:

Audio: Keep track of sink volume, drop unused routines.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/AudioMixBuffer.cpp

    r55380 r55387  
    11391139
    11401140    pMixBuf->Volume.fMuted = pVol->fMuted;
    1141     pMixBuf->Volume.uLeft  = (UINT64_C(0x100000000) * pVol->uLeft) / 255;
    1142     pMixBuf->Volume.uRight = (UINT64_C(0x100000000) * pVol->uRight) / 255;
     1141    pMixBuf->Volume.uLeft  = (UINT64_C(0x80000000) * pVol->uLeft) / 255;
     1142    pMixBuf->Volume.uRight = (UINT64_C(0x80000000) * pVol->uRight) / 255;
    11431143
    11441144    LogFlowFunc(("\t-> lVol=%RU32, rVol=%RU32\n", pMixBuf->Volume.uLeft, pMixBuf->Volume.uRight));
  • trunk/src/VBox/Devices/Audio/AudioMixer.cpp

    r55379 r55387  
    3838
    3939
    40 static int audioMixerUpdateSinkVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster, const PPDMAUDIOVOLUME pVolSink);
     40static int audioMixerUpdateSinkVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster);
    4141
    4242
     
    276276    RTListForEach(&pMixer->lstSinks, pSink, AUDMIXSINK, Node)
    277277    {
    278         int rc2 = audioMixerUpdateSinkVolume(pSink, &pMixer->VolMaster, &pSink->Volume);
     278        int rc2 = audioMixerUpdateSinkVolume(pSink, &pMixer->VolMaster);
    279279        AssertRC(rc2);
    280280    }
     
    411411}
    412412
    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)
     413static int audioMixerUpdateSinkVolume(PAUDMIXSINK pSink, const PPDMAUDIOVOLUME pVolMaster)
    447414{
    448415    AssertPtrReturn(pSink,      VERR_INVALID_POINTER);
    449416    AssertPtrReturn(pVolMaster, VERR_INVALID_POINTER);
    450     AssertPtrReturn(pVolSink,   VERR_INVALID_POINTER);
    451417
    452418    LogFlowFunc(("Master fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n",
     
    458424
    459425    PDMAUDIOVOLUME volSink;
    460     volSink.fMuted  = pVolMaster->fMuted || pVolSink->fMuted;
    461     volSink.uLeft   = (pVolSink->uLeft  * pVolMaster->uLeft)  / UINT8_MAX;
    462     volSink.uRight  = (pVolSink->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;
    463429
    464430    LogFlowFunc(("\t-> fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n",
     
    480446}
    481447
     448/** Set the master volume of the mixer. */
    482449int audioMixerSetMasterVolume(PAUDIOMIXER pMixer, PPDMAUDIOVOLUME pVol)
    483450{
     
    485452    AssertPtrReturn(pVol,   VERR_INVALID_POINTER);
    486453
    487     pMixer->VolMaster = *pVol; //= audioMixerVolCalc(pVol);
     454    pMixer->VolMaster = *pVol;
    488455
    489456    LogFlowFunc(("%s: lVol=%RU32, rVol=%RU32 => fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n",
     
    495462}
    496463
     464/** Set the volume of an individual sink. */
    497465int audioMixerSetSinkVolume(PAUDMIXSINK pSink, PPDMAUDIOVOLUME pVol)
    498466{
    499467    AssertPtrReturn(pSink, VERR_INVALID_POINTER);
    500468    AssertPtrReturn(pVol,  VERR_INVALID_POINTER);
     469    AssertPtr(pSink->pParent);
    501470
    502471    LogFlowFunc(("%s: fMuted=%RTbool, lVol=%RU32, rVol=%RU32\n", pSink->pszName, pVol->fMuted, pVol->uLeft, pVol->uRight));
    503472
    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.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette