#include "input_manager.hpp" /* Get notification of Volume Change */
#include "util/input_slider.hpp" /* SoundSlider */
+#include <math.h>
#include <vlc_aout_intf.h> /* Volume functions */
#include <QLabel>
/* Set the volume from the config */
libUpdateVolume();
- /* Force the update at build time in order to have a muted icon if needed */
- updateMuteStatus();
+ /* Sync mute status */
+ if( aout_MuteGet( THEPL ) > 0 )
+ updateMuteStatus( true );
/* Volume control connection */
volumeSlider->setTracking( true );
CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) );
CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) );
CONNECT( THEMIM, volumeChanged( void ), this, libUpdateVolume( void ) );
- CONNECT( THEMIM, soundMuteChanged( void ), this, updateMuteStatus( void ) );
+ CONNECT( THEMIM, soundMuteChanged( bool ), this, updateMuteStatus( bool ) );
}
SoundWidget::~SoundWidget()
/* Only if volume is set by user action on slider */
setMuted( false );
playlist_t *p_playlist = pl_Get( p_intf );
- int i_res = i_sliderVolume * (AOUT_VOLUME_DEFAULT * 2) / VOLUME_MAX;
- aout_VolumeSet( p_playlist, i_res );
+ aout_VolumeSet( p_playlist, i_sliderVolume / 100.f );
refreshLabels();
}
void SoundWidget::libUpdateVolume()
{
/* Audio part */
- audio_volume_t i_volume;
playlist_t *p_playlist = pl_Get( p_intf );
-
- i_volume = aout_VolumeGet( p_playlist );
- i_volume = (i_volume * VOLUME_MAX ) / (AOUT_VOLUME_DEFAULT * 2);
+ long i_volume = lroundf(aout_VolumeGet( p_playlist ) * 100.f);
if ( i_volume - volumeSlider->value() != 0 )
{
}
/* libvlc mute/unmute event slot */
-void SoundWidget::updateMuteStatus()
+void SoundWidget::updateMuteStatus( bool mute )
{
- playlist_t *p_playlist = pl_Get( p_intf );
- b_is_muted = aout_MuteGet( p_playlist ) > 0;
+ b_is_muted = mute;
SoundSlider *soundSlider = qobject_cast<SoundSlider *>(volumeSlider);
if( soundSlider )
- soundSlider->setMuted( b_is_muted );
+ soundSlider->setMuted( mute );
refreshLabels();
}