Commit 83ad48a4 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: partly fix volume display

parent b092d34b
...@@ -109,7 +109,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, ...@@ -109,7 +109,8 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
layout->addWidget( volumeSlider, 0, Qt::AlignBottom ); layout->addWidget( volumeSlider, 0, Qt::AlignBottom );
/* Set the volume from the config */ /* Set the volume from the config */
libUpdateVolume(); float volume = aout_VolumeGet( THEPL );
libUpdateVolume( (volume >= 0.f) ? volume : 1.f );
/* Sync mute status */ /* Sync mute status */
if( aout_MuteGet( THEPL ) > 0 ) if( aout_MuteGet( THEPL ) > 0 )
updateMuteStatus( true ); updateMuteStatus( true );
...@@ -118,7 +119,7 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf, ...@@ -118,7 +119,7 @@ SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
volumeSlider->setTracking( true ); volumeSlider->setTracking( true );
CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) ); CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) );
CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) ); CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) );
CONNECT( THEMIM, volumeChanged( void ), this, libUpdateVolume( void ) ); CONNECT( THEMIM, volumeChanged( float ), this, libUpdateVolume( float ) );
CONNECT( THEMIM, soundMuteChanged( bool ), this, updateMuteStatus( bool ) ); CONNECT( THEMIM, soundMuteChanged( bool ), this, updateMuteStatus( bool ) );
} }
...@@ -152,19 +153,15 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume ) ...@@ -152,19 +153,15 @@ void SoundWidget::userUpdateVolume( int i_sliderVolume )
{ {
/* Only if volume is set by user action on slider */ /* Only if volume is set by user action on slider */
setMuted( false ); setMuted( false );
playlist_t *p_playlist = pl_Get( p_intf ); aout_VolumeSet( THEPL, i_sliderVolume / 100.f );
aout_VolumeSet( p_playlist, i_sliderVolume / 100.f );
refreshLabels(); refreshLabels();
} }
/* libvlc changed value event slot */ /* libvlc changed value event slot */
void SoundWidget::libUpdateVolume() void SoundWidget::libUpdateVolume( float volume )
{ {
/* Audio part */ long i_volume = lroundf(volume * 100.f);
playlist_t *p_playlist = pl_Get( p_intf ); if( i_volume != volumeSlider->value() )
long i_volume = lroundf(aout_VolumeGet( p_playlist ) * 100.f);
if ( i_volume - volumeSlider->value() != 0 )
{ {
b_ignore_valuechanged = true; b_ignore_valuechanged = true;
volumeSlider->setValue( i_volume ); volumeSlider->setValue( i_volume );
......
...@@ -117,7 +117,7 @@ private: ...@@ -117,7 +117,7 @@ private:
protected slots: protected slots:
void userUpdateVolume( int ); void userUpdateVolume( int );
void libUpdateVolume( void ); void libUpdateVolume( float );
void updateMuteStatus( bool ); void updateMuteStatus( bool );
void refreshLabels( void ); void refreshLabels( void );
void showVolumeMenu( QPoint pos ); void showVolumeMenu( QPoint pos );
......
...@@ -51,8 +51,6 @@ static int PLItemAppended( vlc_object_t *, const char *, ...@@ -51,8 +51,6 @@ static int PLItemAppended( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int PLItemRemoved( vlc_object_t *, const char *, static int PLItemRemoved( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int VolumeChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int InputEvent( vlc_object_t *, const char *, static int InputEvent( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
...@@ -945,7 +943,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) ...@@ -945,7 +943,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
: QObject(NULL), p_intf( _p_intf ), : QObject(NULL), p_intf( _p_intf ),
random( VLC_OBJECT(THEPL), "random" ), random( VLC_OBJECT(THEPL), "random" ),
repeat( VLC_OBJECT(THEPL), "repeat" ), loop( VLC_OBJECT(THEPL), "loop" ), repeat( VLC_OBJECT(THEPL), "repeat" ), loop( VLC_OBJECT(THEPL), "loop" ),
mute( VLC_OBJECT(THEPL), "mute" ) volume( VLC_OBJECT(THEPL), "volume" ), mute( VLC_OBJECT(THEPL), "mute" )
{ {
p_input = NULL; p_input = NULL;
im = new InputManager( this, p_intf ); im = new InputManager( this, p_intf );
...@@ -960,7 +958,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf ) ...@@ -960,7 +958,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
repeat.addCallback( this, SLOT(notifyRepeatLoop(bool)) ); repeat.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) ); loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
var_AddCallback( THEPL, "volume", VolumeChanged, this ); volume.addCallback( this, SLOT(notifyVolume(int)) );
mute.addCallback( this, SLOT(notifyMute(bool)) ); mute.addCallback( this, SLOT(notifyMute(bool)) );
/* Warn our embedded IM about input changes */ /* Warn our embedded IM about input changes */
...@@ -986,8 +984,6 @@ MainInputManager::~MainInputManager() ...@@ -986,8 +984,6 @@ MainInputManager::~MainInputManager()
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
var_DelCallback( THEPL, "volume", VolumeChanged, this );
var_DelCallback( THEPL, "activity", PLItemChanged, this ); var_DelCallback( THEPL, "activity", PLItemChanged, this );
var_DelCallback( THEPL, "item-change", ItemChanged, im ); var_DelCallback( THEPL, "item-change", ItemChanged, im );
var_DelCallback( THEPL, "leaf-to-parent", LeafToParent, this ); var_DelCallback( THEPL, "leaf-to-parent", LeafToParent, this );
...@@ -1016,9 +1012,6 @@ void MainInputManager::customEvent( QEvent *event ) ...@@ -1016,9 +1012,6 @@ void MainInputManager::customEvent( QEvent *event )
// msg_Dbg( p_intf, "New MainIM Event of type: %i", type ); // msg_Dbg( p_intf, "New MainIM Event of type: %i", type );
switch( type ) switch( type )
{ {
case VolumeChanged_Type:
emit volumeChanged();
return;
case PLItemAppended_Type: case PLItemAppended_Type:
plEv = static_cast<PLEvent*>( event ); plEv = static_cast<PLEvent*>( event );
emit playlistItemAppended( plEv->i_item, plEv->i_parent ); emit playlistItemAppended( plEv->i_item, plEv->i_parent );
...@@ -1224,16 +1217,9 @@ static int LeafToParent( vlc_object_t *p_this, const char *psz_var, ...@@ -1224,16 +1217,9 @@ static int LeafToParent( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int VolumeChanged( vlc_object_t *p_this, const char *psz_var, void MainInputManager::notifyVolume( int volume )
vlc_value_t oldval, vlc_value_t newval, void *param )
{ {
VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( newval ); emit volumeChanged( volume / (float)AOUT_VOLUME_DEFAULT );
MainInputManager *mim = (MainInputManager*)param;
IMEvent *event = new IMEvent( VolumeChanged_Type );
QApplication::postEvent( mim, event );
return VLC_SUCCESS;
} }
void MainInputManager::notifyMute( bool mute ) void MainInputManager::notifyMute( bool mute )
......
...@@ -38,14 +38,12 @@ ...@@ -38,14 +38,12 @@
#include <QObject> #include <QObject>
#include <QEvent> #include <QEvent>
enum { enum {
PositionUpdate_Type = QEvent::User + IMEventType + 1, PositionUpdate_Type = QEvent::User + IMEventType + 1,
ItemChanged_Type, ItemChanged_Type,
ItemStateChanged_Type, ItemStateChanged_Type,
ItemTitleChanged_Type, ItemTitleChanged_Type,
ItemRateChanged_Type, ItemRateChanged_Type,
VolumeChanged_Type,
ItemEsChanged_Type, ItemEsChanged_Type,
ItemTeletextChanged_Type, ItemTeletextChanged_Type,
InterfaceVoutUpdate_Type, InterfaceVoutUpdate_Type,
...@@ -276,6 +274,7 @@ private: ...@@ -276,6 +274,7 @@ private:
input_thread_t *p_input; input_thread_t *p_input;
intf_thread_t *p_intf; intf_thread_t *p_intf;
QVLCBool random, repeat, loop; QVLCBool random, repeat, loop;
QVLCInteger volume;
QVLCBool mute; QVLCBool mute;
public slots: public slots:
...@@ -293,11 +292,12 @@ public slots: ...@@ -293,11 +292,12 @@ public slots:
private slots: private slots:
void notifyRandom( bool ); void notifyRandom( bool );
void notifyRepeatLoop( bool ); void notifyRepeatLoop( bool );
void notifyVolume( int );
void notifyMute( bool ); void notifyMute( bool );
signals: signals:
void inputChanged( input_thread_t * ); void inputChanged( input_thread_t * );
void volumeChanged(); void volumeChanged( float );
void soundMuteChanged(bool); void soundMuteChanged( bool );
void playlistItemAppended( int itemId, int parentId ); void playlistItemAppended( int itemId, int parentId );
void playlistItemRemoved( int itemId ); void playlistItemRemoved( int itemId );
void playlistNotEmpty( bool ); void playlistNotEmpty( bool );
......
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