|
|
@ -527,6 +527,11 @@ void Mixer::setVolume( int deviceidx, int percentage )
|
|
|
|
void Mixer::commitVolumeChange( MixDevice* md ) {
|
|
|
|
void Mixer::commitVolumeChange( MixDevice* md ) {
|
|
|
|
_mixerBackend->writeVolumeToHW(md->num(), md->getVolume() );
|
|
|
|
_mixerBackend->writeVolumeToHW(md->num(), md->getVolume() );
|
|
|
|
_mixerBackend->setEnumIdHW(md->num(), md->enumId() );
|
|
|
|
_mixerBackend->setEnumIdHW(md->num(), md->enumId() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Muting/unmuting PulseAudio directly does not send back any notification to the mixer
|
|
|
|
|
|
|
|
// so we make sure we always update the tray icon after each operation.
|
|
|
|
|
|
|
|
readSetFromHWforceUpdate();
|
|
|
|
|
|
|
|
TQTimer::singleShot(50, this, TQT_SLOT(readSetFromHW()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @dcop only
|
|
|
|
// @dcop only
|
|
|
@ -624,51 +629,42 @@ int Mixer::masterVolume()
|
|
|
|
void Mixer::increaseVolume( int deviceidx )
|
|
|
|
void Mixer::increaseVolume( int deviceidx )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MixDevice *mixdev= mixDeviceByType( deviceidx );
|
|
|
|
MixDevice *mixdev= mixDeviceByType( deviceidx );
|
|
|
|
if (mixdev != 0) {
|
|
|
|
if (mixdev != 0)
|
|
|
|
Volume vol=mixdev->getVolume();
|
|
|
|
{
|
|
|
|
double fivePercent = (vol.maxVolume()-vol.minVolume()+1) / 20;
|
|
|
|
Volume vol = mixdev->getVolume();
|
|
|
|
for (unsigned int i=Volume::CHIDMIN; i <= Volume::CHIDMAX; i++) {
|
|
|
|
long inc = vol.maxVolume() / 20;
|
|
|
|
int volToChange = vol.getVolume((Volume::ChannelID)i);
|
|
|
|
if (inc == 0)
|
|
|
|
if ( fivePercent < 1 ) fivePercent = 1;
|
|
|
|
{
|
|
|
|
volToChange += (int)fivePercent;
|
|
|
|
inc = 1;
|
|
|
|
vol.setVolume((Volume::ChannelID)i, volToChange);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < vol.count(); i++)
|
|
|
|
_mixerBackend->writeVolumeToHW(deviceidx, vol);
|
|
|
|
{
|
|
|
|
|
|
|
|
long newVal = (vol[i]) + inc;
|
|
|
|
|
|
|
|
mixdev->setVolume(i, newVal < vol.maxVolume() ? newVal : vol.maxVolume());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
commitVolumeChange(mixdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* see comment at the end of decreaseVolume()
|
|
|
|
|
|
|
|
int vol=volume(deviceidx);
|
|
|
|
|
|
|
|
setVolume(deviceidx, vol+5);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @dcop
|
|
|
|
// @dcop
|
|
|
|
void Mixer::decreaseVolume( int deviceidx )
|
|
|
|
void Mixer::decreaseVolume( int deviceidx )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MixDevice *mixdev= mixDeviceByType( deviceidx );
|
|
|
|
MixDevice *mixdev= mixDeviceByType( deviceidx );
|
|
|
|
if (mixdev != 0) {
|
|
|
|
if (mixdev != 0)
|
|
|
|
Volume vol=mixdev->getVolume();
|
|
|
|
{
|
|
|
|
double fivePercent = (vol.maxVolume()-vol.minVolume()+1) / 20;
|
|
|
|
Volume vol = mixdev->getVolume();
|
|
|
|
for (unsigned int i=Volume::CHIDMIN; i <= Volume::CHIDMAX; i++) {
|
|
|
|
long inc = vol.maxVolume() / 20;
|
|
|
|
int volToChange = vol.getVolume((Volume::ChannelID)i);
|
|
|
|
if (inc == 0)
|
|
|
|
//std::cout << "Mixer::decreaseVolume(): before: volToChange " <<i<< "=" <<volToChange << std::endl;
|
|
|
|
{
|
|
|
|
if ( fivePercent < 1 ) fivePercent = 1;
|
|
|
|
inc = 1;
|
|
|
|
volToChange -= (int)fivePercent;
|
|
|
|
}
|
|
|
|
//std::cout << "Mixer::decreaseVolume(): after: volToChange " <<i<< "=" <<volToChange << std::endl;
|
|
|
|
for (int i = 0; i < vol.count(); i++)
|
|
|
|
vol.setVolume((Volume::ChannelID)i, volToChange);
|
|
|
|
{
|
|
|
|
//int volChanged = vol.getVolume((Volume::ChannelID)i);
|
|
|
|
long newVal = (vol[i]) - inc;
|
|
|
|
//std::cout << "Mixer::decreaseVolume(): check: volChanged " <<i<< "=" <<volChanged << std::endl;
|
|
|
|
mixdev->setVolume(i, newVal > 0 ? newVal : 0);
|
|
|
|
} // for
|
|
|
|
}
|
|
|
|
_mixerBackend->writeVolumeToHW(deviceidx, vol);
|
|
|
|
commitVolumeChange(mixdev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
|
|
|
|
It is important, not to implement this method like this:
|
|
|
|
|
|
|
|
int vol=volume(deviceidx);
|
|
|
|
|
|
|
|
setVolume(deviceidx, vol-5);
|
|
|
|
|
|
|
|
It creates too big rounding errors. If you don't beleive me, then
|
|
|
|
|
|
|
|
do a decreaseVolume() and increaseVolume() with "vol.maxVolume() == 31".
|
|
|
|
|
|
|
|
***********************************************************/
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @dcop
|
|
|
|
// @dcop
|
|
|
@ -698,16 +694,8 @@ void Mixer::toggleMute( int deviceidx )
|
|
|
|
MixDevice *mixdev= mixDeviceByType( deviceidx );
|
|
|
|
MixDevice *mixdev= mixDeviceByType( deviceidx );
|
|
|
|
if (!mixdev) return;
|
|
|
|
if (!mixdev) return;
|
|
|
|
|
|
|
|
|
|
|
|
bool previousState= mixdev->isMuted();
|
|
|
|
mixdev->setMuted(!mixdev->isMuted());
|
|
|
|
|
|
|
|
commitVolumeChange(mixdev);
|
|
|
|
mixdev->setMuted( !previousState );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_mixerBackend->writeVolumeToHW(deviceidx, mixdev->getVolume());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Muting/unmuting PulseAudio directly does not send back any notification to the mixer
|
|
|
|
|
|
|
|
// so we make sure we always update the tray icon after each operation.
|
|
|
|
|
|
|
|
readSetFromHWforceUpdate();
|
|
|
|
|
|
|
|
TQTimer::singleShot(50, this, TQT_SLOT(readSetFromHW()));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @dcop only
|
|
|
|
// @dcop only
|
|
|
|