Commit 662a0037 authored by Ilkka Ollakka's avatar Ilkka Ollakka

don't poll volume-change, change volumecontrol to use signal from

maininputmanager which listens p_intf->p_libvlc "volume-change" variable
for volumechange. ref #1365
parent 79274077
......@@ -581,6 +581,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
/* Volume control connection */
CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
}
ControlsWidget::~ControlsWidget()
......@@ -655,7 +656,7 @@ void ControlsWidget::updateVolume( int i_sliderVolume )
else volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-medium.png" ) );
}
void ControlsWidget::updateOnTimer()
void ControlsWidget::updateVolume()
{
/* Audio part */
audio_volume_t i_volume;
......
......@@ -152,7 +152,6 @@ public:
void enableVideo( bool );
public slots:
void setNavigation( int );
void updateOnTimer();
protected:
friend class MainInterface;
friend class VolumeClickHandler;
......@@ -176,6 +175,7 @@ private slots:
void prev();
void next();
void updateVolume( int );
void updateVolume( void );
void fullscreen();
void extSettings();
void faster();
......
......@@ -39,6 +39,8 @@ static int ItemRateChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int ItemTitleChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int VolumeChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
/**********************************************************************
* InputManager implementation
......@@ -178,6 +180,16 @@ static int InputChanged( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS;
}
static int VolumeChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
MainInputManager *im = (MainInputManager*)param;
IMEvent *event = new IMEvent( VolumeChanged_Type, newval.i_int );
QApplication::postEvent( im, static_cast<QEvent*>(event) );
return VLC_SUCCESS;
}
static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
......@@ -329,11 +341,6 @@ void InputManager::UpdateMeta( void )
}
void InputManager::update()
{
}
void InputManager::sliderUpdate( float new_pos )
{
if( hasInput() ) var_SetFloat( p_input, "position", new_pos );
......@@ -464,6 +471,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) : QObject(NULL),
im = new InputManager( this, p_intf );
var_AddCallback( THEPL, "playlist-current", InputChanged, this );
var_AddCallback( THEPL, "activity", InputChanged, this );
var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
/* Warn our embedded IM about input changes */
CONNECT( this, inputChanged( input_thread_t * ),
im, setInput( input_thread_t * ) );
......@@ -476,6 +484,7 @@ MainInputManager::~MainInputManager()
vlc_object_release( p_input );
emit inputChanged( NULL );
}
var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
var_DelCallback( THEPL, "playlist-current", InputChanged, this );
var_DelCallback( THEPL, "activity", InputChanged, this );
}
......@@ -483,8 +492,14 @@ MainInputManager::~MainInputManager()
void MainInputManager::customEvent( QEvent *event )
{
int type = event->type();
if ( type != ItemChanged_Type )
if ( type != ItemChanged_Type && type != VolumeChanged_Type )
return;
if( type == VolumeChanged_Type )
{
emit volumeChanged();
return;
}
if( VLC_OBJECT_INTF == p_intf->i_object_type )
{
......@@ -551,6 +566,8 @@ void MainInputManager::togglePlayPause()
getIM()->togglePlayPause();
}
static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o,
vlc_value_t n, void *param )
{
......@@ -566,3 +583,4 @@ static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o,
im->b_has_video = true;
return VLC_SUCCESS;
}
......@@ -35,6 +35,7 @@ static int ItemChanged_Type = QEvent::User + 7;
static int ItemRateChanged_Type = QEvent::User + 8;
static int ItemTitleChanged_Type = QEvent::User + 9;
static int ItemStateChanged_Type = QEvent::User + 10;
static int VolumeChanged_Type = QEvent::User + 11;
class IMEvent : public QEvent
{
......@@ -75,7 +76,6 @@ private:
int i_rate;
public slots:
void togglePlayPause();
void update(); ///< Periodic updates
void setInput( input_thread_t * ); ///< Our controlled input changed
void sliderUpdate( float ); ///< User dragged the slider. We get new pos
void slower();
......@@ -140,6 +140,7 @@ private slots:
//void updateInput();
signals:
void inputChanged( input_thread_t * );
void volumeChanged( void );
};
#endif
......@@ -889,8 +889,6 @@ void MainInterface::updateOnTimer()
need_components_update = false;
}
#endif
controls->updateOnTimer();
}
/*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment