From 1ced1a3f083c1895f570bc0a6d02a47b7df1fbb0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Sun, 9 Sep 2007 01:17:15 +0000 Subject: [PATCH] Qt4 - Volume: set the slider maximum to 200, in order to match the OSD % of the volume, which will help to debug. However, I still don't understand whether the "normal" volume is 256 or 512 and when starts the "dangerous" amplification --- modules/gui/qt4/components/interface_widgets.cpp | 9 ++++----- modules/gui/qt4/components/interface_widgets.hpp | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp index ba440d81ce..ae7941639c 100644 --- a/modules/gui/qt4/components/interface_widgets.cpp +++ b/modules/gui/qt4/components/interface_widgets.cpp @@ -487,7 +487,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i, bool b_advControls ) : volumeSlider->setMaximumSize( QSize( 80, 200 ) ); volumeSlider->setOrientation( Qt::Horizontal ); - volumeSlider->setMaximum( 100 ); + volumeSlider->setMaximum( VOLUME_MAX ); volumeSlider->setFocusPolicy( Qt::NoFocus ); controlLayout->addWidget( volMuteLabel, 3, 15 ); controlLayout->addWidget( volumeSlider, 3, 16, 1, 2 ); @@ -558,13 +558,12 @@ void ControlsWidget::updateVolume( int i_sliderVolume ) { if( !b_my_volume ) { - int i_res = i_sliderVolume * AOUT_VOLUME_MAX / - ( 2*volumeSlider->maximum() ); + int i_res = i_sliderVolume * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX; aout_VolumeSet( p_intf, i_res ); } if( i_sliderVolume == 0 ) volMuteLabel->setPixmap( QPixmap(":/pixmaps/volume-muted.png" ) ); - else if( i_sliderVolume < volumeSlider->maximum()/2 ) + else if( i_sliderVolume < VOLUME_MAX / 2 ) volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) ); else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-high.png" ) ); } @@ -574,7 +573,7 @@ void ControlsWidget::updateOnTimer() /* Audio part */ audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); - i_volume = ( i_volume * 200 )/ AOUT_VOLUME_MAX ; + i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2) ; int i_gauge = volumeSlider->value(); b_my_volume = false; if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 ) diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp index 0a57560b0e..2ac1b59a31 100644 --- a/modules/gui/qt4/components/interface_widgets.hpp +++ b/modules/gui/qt4/components/interface_widgets.hpp @@ -34,6 +34,7 @@ #include #include +#define VOLUME_MAX 200 class ResizeEvent; class QPalette; @@ -125,6 +126,8 @@ private slots: void record(); }; + + class InputSlider; class QSlider; class QGridLayout; @@ -188,7 +191,7 @@ public: aout_VolumeMute( p_intf, NULL ); audio_volume_t i_volume; aout_VolumeGet( p_intf, &i_volume ); - m->updateVolume( i_volume * 200 /AOUT_VOLUME_MAX ); + m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) ); return true; } return false; -- GitLab