Commit 57300f50 authored by Ilkka Ollakka's avatar Ilkka Ollakka

Change backgroundwidget and mediainfo-dialog to use THEMIM

inputChanged-signal instead of polling.

I think that iteration-count for this one is still under 10 ;)
parent c4ffec64
...@@ -50,8 +50,6 @@ static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*, ...@@ -50,8 +50,6 @@ static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
unsigned int *, unsigned int * ); unsigned int *, unsigned int * );
static void DoRelease( intf_thread_t *, void * ); static void DoRelease( intf_thread_t *, void * );
static int DoControl( intf_thread_t *, void *, int, va_list ); static int DoControl( intf_thread_t *, void *, int, va_list );
static int ItemChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i ) VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
{ {
...@@ -149,34 +147,16 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : ...@@ -149,34 +147,16 @@ BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
resize( 300, 150 ); resize( 300, 150 );
updateGeometry(); updateGeometry();
i_runs = 0; CONNECT( THEMIM, inputChanged( input_thread_t *), this, update( input_thread_t * ) );
b_need_update = VLC_FALSE;
var_AddCallback( THEPL, "item-change", ItemChanged, this );
ON_TIMEOUT( update() );
} }
BackgroundWidget::~BackgroundWidget() BackgroundWidget::~BackgroundWidget()
{ {
var_DelCallback( THEPL, "item-change", ItemChanged, this );
} }
static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
BackgroundWidget *p_d = (BackgroundWidget*)param;
p_d->b_need_update = VLC_TRUE;
return VLC_SUCCESS;
}
void BackgroundWidget::update() void BackgroundWidget::update( input_thread_t *p_input )
{ {
/* Timer runs at 150 ms, dont' update more than once every 750ms */
i_runs++;
if( i_runs % 6 != 0 ) return;
/* Get Input and clear if non-existant */
input_thread_t *p_input =
MainInputManager::getInstance( p_intf )->getInput();
if( !p_input || p_input->b_dead ) if( !p_input || p_input->b_dead )
{ {
label->setPixmap( QPixmap( ":/vlc128.png" ) ); label->setPixmap( QPixmap( ":/vlc128.png" ) );
...@@ -184,8 +164,6 @@ void BackgroundWidget::update() ...@@ -184,8 +164,6 @@ void BackgroundWidget::update()
} }
if( b_need_update )
{
vlc_object_yield( p_input ); vlc_object_yield( p_input );
char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) ); char *psz_arturl = input_item_GetArtURL( input_GetItem(p_input) );
vlc_object_release( p_input ); vlc_object_release( p_input );
...@@ -199,8 +177,6 @@ void BackgroundWidget::update() ...@@ -199,8 +177,6 @@ void BackgroundWidget::update()
msg_Dbg( p_intf, "changing input b_need_update done %s", psz_arturl ); msg_Dbg( p_intf, "changing input b_need_update done %s", psz_arturl );
} }
free( psz_arturl ); free( psz_arturl );
}
b_need_update = false;
} }
QSize BackgroundWidget::sizeHint() const QSize BackgroundWidget::sizeHint() const
......
...@@ -90,7 +90,7 @@ private: ...@@ -90,7 +90,7 @@ private:
int i_runs; int i_runs;
public slots: public slots:
void toggle(){ TOGGLEV( this ); } void toggle(){ TOGGLEV( this ); }
void update( void ); void update( input_thread_t * );
}; };
class VisualSelector : public QFrame class VisualSelector : public QFrame
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#include <QLineEdit> #include <QLineEdit>
#include <QLabel> #include <QLabel>
static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param );
MediaInfoDialog *MediaInfoDialog::instance = NULL; MediaInfoDialog *MediaInfoDialog::instance = NULL;
MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
...@@ -92,18 +90,13 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf, ...@@ -92,18 +90,13 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
CONNECT( IT, currentChanged( int ), this, updateButtons( int ) ); CONNECT( IT, currentChanged( int ), this, updateButtons( int ) );
/* Create the main Update function with a time (150ms) */ CONNECT( THEMIM, inputChanged( input_thread_t * ), this, update( input_thread_t * ) );
if( mainInput ) { /* Call update by hand, so info is shown from current item too */
ON_TIMEOUT( updateOnTimeOut() ); update( input_GetItem(THEMIM->getInput()), true, true );
var_AddCallback( THEPL, "item-change", ItemChanged, this );
}
} }
MediaInfoDialog::~MediaInfoDialog() MediaInfoDialog::~MediaInfoDialog()
{ {
if( mainInput ) {
var_DelCallback( THEPL, "item-change", ItemChanged, this );
}
writeSettings( "mediainfo" ); writeSettings( "mediainfo" );
} }
...@@ -124,23 +117,9 @@ void MediaInfoDialog::saveMeta() ...@@ -124,23 +117,9 @@ void MediaInfoDialog::saveMeta()
saveMetaButton->hide(); saveMetaButton->hide();
} }
static int ItemChanged( vlc_object_t *p_this, const char *psz_var, /* Function called on inputChanged-update*/
vlc_value_t oldval, vlc_value_t newval, void *param ) void MediaInfoDialog::update( input_thread_t *p_input )
{
MediaInfoDialog *p_d = (MediaInfoDialog *)param;
p_d->b_need_update = VLC_TRUE;
return VLC_SUCCESS;
}
/* Function called on TimeOut */
void MediaInfoDialog::updateOnTimeOut()
{ {
/* Timer runs at 150 ms, dont' update more than 2 times per second */
i_runs++;
if( i_runs % 4 != 0 ) return;
/* Get Input and clear if non-existant */
input_thread_t *p_input = THEMIM->getInput();
if( !p_input || p_input->b_dead ) if( !p_input || p_input->b_dead )
{ {
if( !b_cleaned ) if( !b_cleaned )
......
...@@ -83,7 +83,7 @@ private: ...@@ -83,7 +83,7 @@ private:
QLineEdit *uriLine; QLineEdit *uriLine;
public slots: public slots:
void updateOnTimeOut(); void update( input_thread_t * );
void update( input_item_t *, bool, bool ); void update( input_item_t *, bool, bool );
private slots: private slots:
......
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