Skip to content

Commit

Permalink
Merge pull request #278 from MediaPortal/MP1-5199-Fix_volume_OSD_pres…
Browse files Browse the repository at this point in the history
…entation_on_the_screen

MP1-5199: Fix volume OSD presentation on the screen
  • Loading branch information
andrewjswan authored Feb 27, 2024
2 parents b758351 + 0843b63 commit cac6599
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions mediaportal/Core/Mixer/Mixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,24 @@ public void Open(int mixerIndex, bool isDigital, bool resetDevice = false)

_mixerControlDetailsVolume = GetControl(_componentType, MixerControlType.Volume);
_mixerControlDetailsMute = GetControl(_componentType, MixerControlType.Mute);

_isMuted = (int)GetValue(_componentType, MixerControlType.Mute) == 1;
_volume = (int)GetValue(_componentType, MixerControlType.Volume);
_isMutedWave = _isMuted;
_volumeWave = _volume;

if (_audioDefaultDevice != null)
{
//Take the initialization value from the Master; it is more appropriate
_isMuted = _audioDefaultDevice.Muted;
_volume = (int)Math.Round(_audioDefaultDevice.MasterVolume * VolumeMaximum);

_isMutedWave = (int)GetValue(_componentType, MixerControlType.Mute) == 1;
_volumeWave = (int)GetValue(_componentType, MixerControlType.Volume);
}
else
{
_isMuted = (int)GetValue(_componentType, MixerControlType.Mute) == 1;
_volume = (int)GetValue(_componentType, MixerControlType.Volume);

_isMutedWave = _isMuted;
_volumeWave = _volume;
}
}
}
}
Expand Down Expand Up @@ -356,14 +369,23 @@ private void OnLineChanged(object sender, MixerEventArgs e)

private void OnControlChanged(object sender, MixerEventArgs e)
{
bool wasMuted = _isMuted;
int lastVolume = _volume;
_isMuted = (int)GetValue(_componentType, MixerControlType.Mute) == 1;
_volume = (int)GetValue(_componentType, MixerControlType.Volume);
//Mode == Wave || OS < Vista

if (ControlChanged != null && (wasMuted != _isMuted || lastVolume != _volume))
bool wasMuted = _isMutedWave;
int lastVolume = _volumeWave;
_isMutedWave = (int)GetValue(_componentType, MixerControlType.Mute) == 1;
_volumeWave = (int)GetValue(_componentType, MixerControlType.Volume);

if (wasMuted != _isMutedWave || lastVolume != _volumeWave)
{
ControlChanged(sender, e);
Log.Debug("Mixer: OnControlChanged(), new muted = {0}, new volume = {1}, old muted = {2}, old volume = {3}",
_isMutedWave, _volumeWave, wasMuted, lastVolume);

_isMuted = _isMutedWave;
_volume = _volumeWave;

if (ControlChanged != null)
ControlChanged(sender, e);
}
}

Expand Down

0 comments on commit cac6599

Please sign in to comment.