]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.cpp
s/vlc_object_yield/vlc_object_release/
[vlc] / modules / gui / qt4 / input_manager.cpp
1 /*****************************************************************************
2  * input_manager.cpp : Manage an input and interact with its GUI elements
3  ****************************************************************************
4  * Copyright (C) 2006-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Ilkka Ollakka  <ileoo@videolan.org>
9  *          Jean-Baptiste <jb@videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include "qt4.hpp"
30 #include "input_manager.hpp"
31 #include "dialogs_provider.hpp"
32
33 static int ChangeSPU( vlc_object_t *p_this, const char *var, vlc_value_t o,
34                       vlc_value_t n, void *param );
35
36 static int ChangeTeletext( vlc_object_t *p_this, const char *var, vlc_value_t o,
37                            vlc_value_t n, void *param );
38
39 static int ItemChanged( vlc_object_t *, const char *,
40                         vlc_value_t, vlc_value_t, void * );
41 static int PLItemChanged( vlc_object_t *, const char *,
42                         vlc_value_t, vlc_value_t, void * );
43 static int InterfaceChanged( vlc_object_t *, const char *,
44                             vlc_value_t, vlc_value_t, void * );
45 static int InterfaceVoutChanged( vlc_object_t *, const char *,
46                                  vlc_value_t, vlc_value_t, void * );
47 static int ItemStateChanged( vlc_object_t *, const char *,
48                         vlc_value_t, vlc_value_t, void * );
49 static int ItemRateChanged( vlc_object_t *, const char *,
50                         vlc_value_t, vlc_value_t, void * );
51 static int ItemTitleChanged( vlc_object_t *, const char *,
52                         vlc_value_t, vlc_value_t, void * );
53 static int VolumeChanged( vlc_object_t *, const char *,
54                         vlc_value_t, vlc_value_t, void * );
55
56 /**********************************************************************
57  * InputManager implementation
58  **********************************************************************
59  * The Input Manager can be the main one around the playlist
60  * But can also be used for VLM dialog or similar
61  **********************************************************************/
62
63 InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
64                            QObject( parent ), p_intf( _p_intf )
65 {
66     i_old_playing_status = END_S;
67     old_name     = "";
68     artUrl       = "";
69     p_input      = NULL;
70     i_rate       = 0;
71     i_input_id   = 0;
72     b_video      = false;
73     b_transparentTelextext = false;
74 }
75
76 InputManager::~InputManager()
77 {
78     delInput();
79 }
80
81 /* Define the Input used.
82    Add the callbacks on input
83    p_input is yield once here */
84 void InputManager::setInput( input_thread_t *_p_input )
85 {
86     delInput();
87     p_input = _p_input;
88     if( p_input && !( p_input->b_dead || !vlc_object_alive (p_input) ) )
89     {
90         vlc_object_hold( p_input );
91         emit statusChanged( PLAYING_S );
92         UpdateMeta();
93         UpdateArt();
94         UpdateSPU();
95         UpdateTeletext();
96         UpdateNavigation();
97         UpdateVout();
98         addCallbacks();
99         i_input_id = input_GetItem( p_input )->i_id;
100     }
101     else
102     {
103         p_input = NULL;
104         i_input_id = 0;
105         emit rateChanged( INPUT_RATE_DEFAULT );
106     }
107 }
108
109 /* delete Input if it ever existed.
110    Delete the callbacls on input
111    p_input is released once here */
112 void InputManager::delInput()
113 {
114     if( p_input )
115     {
116         delCallbacks();
117         i_old_playing_status = END_S;
118         i_input_id = 0;
119         old_name   = "";
120         artUrl     = "";
121         b_video    = false;
122         emit positionUpdated( -1.0, 0 ,0 );
123         emit statusChanged( END_S );
124         emit nameChanged( "" );
125         emit artChanged( NULL );
126         emit rateChanged( INPUT_RATE_DEFAULT );
127         emit voutChanged( false );
128         vlc_object_release( p_input );
129         p_input = NULL;
130         UpdateSPU();
131         UpdateTeletext();
132     }
133 }
134
135 /* Add the callbacks on Input. Self explanatory */
136 void InputManager::addCallbacks()
137 {
138     /* We don't care about:
139        - chapter
140        - programs
141        - audio-delay
142        - spu-delay
143        - bookmark
144        - position, time, length, because they are included in intf-change
145      */
146     /* src/input/input.c:1629 */
147     var_AddCallback( p_input, "state", ItemStateChanged, this );
148     /* src/input/es-out.c:552 */
149     var_AddCallback( p_input, "spu-es", ChangeSPU, this );
150     /* emit UpdateStatus so that main_interface updates controls 
151      * if there is new videotracks (mpeg-ts)*/
152     var_AddCallback( p_input, "video-es", ItemStateChanged, this );
153     /* src/input/es-out.c: */
154     var_AddCallback( p_input, "teletext-es", ChangeTeletext, this );
155     /* src/input/input.c:1765 */
156     var_AddCallback( p_input, "rate-change", ItemRateChanged, this );
157     /* src/input/input.c:2003 */
158     var_AddCallback( p_input, "title", ItemTitleChanged, this );
159     /* src/input/input.c:734 for timers update*/
160     var_AddCallback( p_input, "intf-change", InterfaceChanged, this );
161     /* src/input/input.c for vout creation/destruction */
162     var_AddCallback( p_input, "intf-change-vout", InterfaceVoutChanged, this );
163 }
164
165 /* Delete the callbacks on Input. Self explanatory */
166 void InputManager::delCallbacks()
167 {
168     var_DelCallback( p_input, "spu-es", ChangeSPU, this );
169     var_DelCallback( p_input, "video-es", ItemStateChanged, this );
170     var_DelCallback( p_input, "teletext-es", ChangeTeletext, this );
171     var_DelCallback( p_input, "state", ItemStateChanged, this );
172     var_DelCallback( p_input, "rate-change", ItemRateChanged, this );
173     var_DelCallback( p_input, "title", ItemTitleChanged, this );
174     var_DelCallback( p_input, "intf-change", InterfaceChanged, this );
175     var_DelCallback( p_input, "intf-change-vout", InterfaceVoutChanged, this );
176 }
177
178 /* Convert the event from the callbacks in actions */
179 void InputManager::customEvent( QEvent *event )
180 {
181     int type = event->type();
182     IMEvent *ple = static_cast<IMEvent *>(event);
183
184     if ( type != PositionUpdate_Type &&
185          type != ItemChanged_Type &&
186          type != ItemRateChanged_Type &&
187          type != ItemTitleChanged_Type &&
188          type != ItemSpuChanged_Type &&
189          type != ItemTeletextChanged_Type &&
190          type != ItemStateChanged_Type &&
191          type != InterfaceVoutUpdate_Type )
192         return;
193
194     if( type == ItemStateChanged_Type )
195     {
196         UpdateNavigation();
197         UpdateTeletext();
198     }
199
200     if( !hasInput() ) return;
201
202     if( ( type != PositionUpdate_Type  &&
203           type != ItemRateChanged_Type &&
204           type != ItemSpuChanged_Type &&
205           type != ItemTeletextChanged_Type &&
206           type != ItemStateChanged_Type &&
207           type != InterfaceVoutUpdate_Type
208         )
209         && ( i_input_id != ple->i_id ) )
210         return;
211
212     if( type != PositionUpdate_Type )
213         msg_Dbg( p_intf, "New Event: type %i", type );
214
215     /* Actions */
216     switch( type )
217     {
218     case PositionUpdate_Type:
219         UpdatePosition();
220         break;
221     case ItemChanged_Type:
222         UpdateMeta();
223         UpdateStatus();
224         UpdateArt();
225         break;
226     case ItemStateChanged_Type:
227         UpdateStatus();
228         UpdateNavigation();
229         UpdateMeta();
230         break;
231     case ItemTitleChanged_Type:
232         UpdateNavigation();
233         UpdateMeta();
234         break;
235     case ItemRateChanged_Type:
236         UpdateRate();
237         break;
238     case ItemSpuChanged_Type:
239         UpdateSPU();
240         break;
241     case ItemTeletextChanged_Type:
242         UpdateTeletext();
243         break;
244     case InterfaceVoutUpdate_Type:
245         UpdateVout();
246         break;
247     }
248 }
249
250 void InputManager::UpdatePosition()
251 {
252     /* Update position */
253     int i_length, i_time; /* Int is enough, since we store seconds */
254     float f_pos;
255     i_length = var_GetTime(  p_input , "length" ) / 1000000;
256     i_time = var_GetTime(  p_input , "time") / 1000000;
257     f_pos = var_GetFloat(  p_input , "position" );
258     emit positionUpdated( f_pos, i_time, i_length );
259 }
260
261 void InputManager::UpdateNavigation()
262 {
263     /* Update navigation status */
264     vlc_value_t val; val.i_int = 0;
265     if( hasInput() )
266         var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL );
267     if( val.i_int > 0 )
268     {
269         val.i_int = 0;
270         var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
271         emit navigationChanged( (val.i_int > 0) ? 1 : 2 );
272     }
273     else
274     {
275         emit navigationChanged( 0 );
276     }
277 }
278
279 void InputManager::UpdateStatus()
280 {
281     /* Update playing status */
282     vlc_value_t val; val.i_int = 0;
283     var_Get( p_input, "state", &val );
284     if( i_old_playing_status != val.i_int )
285     {
286         i_old_playing_status = val.i_int;
287         emit statusChanged( val.i_int );
288     }
289 }
290
291 void InputManager::UpdateRate()
292 {
293     /* Update Rate */
294     int i_new_rate = var_GetInteger( p_input, "rate");
295     if( i_new_rate != i_rate )
296     {
297         i_rate = i_new_rate;
298         /* Update rate */
299         emit rateChanged( i_rate );
300     }
301 }
302
303 void InputManager::UpdateMeta()
304 {
305     /* Update text, name and nowplaying */
306     QString text;
307
308     /* Try to get the Title, then the Name */
309     char *psz_name = input_item_GetTitle( input_GetItem( p_input ) );
310     if( EMPTY_STR( psz_name ) )
311     {
312         free( psz_name );
313         psz_name = input_item_GetName( input_GetItem( p_input ) );
314     }
315
316     /* Try to get the nowplaying */
317     char *psz_nowplaying =
318         input_item_GetNowPlaying( input_GetItem( p_input ) );
319     if( !EMPTY_STR( psz_nowplaying ) )
320     {
321         text.sprintf( "%s - %s", psz_nowplaying, psz_name );
322     }
323     else  /* Do it ourself */
324     {
325         char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
326
327         if( !EMPTY_STR( psz_artist ) )
328             text.sprintf( "%s - %s", psz_artist, psz_name );
329         else
330             text.sprintf( "%s", psz_name );
331
332         free( psz_artist );
333     }
334     /* Free everything */
335     free( psz_name );
336     free( psz_nowplaying );
337
338     /* If we have Nothing */
339     if( text.isEmpty() )
340     {
341         psz_name = input_item_GetURI( input_GetItem( p_input ) );
342         text.sprintf( "%s", psz_name );
343         text = text.remove( 0, text.lastIndexOf( DIR_SEP ) + 1 );
344         free( psz_name );
345     }
346
347     if( old_name != text )
348     {
349         emit nameChanged( text );
350         old_name=text;
351     }
352 }
353
354 bool InputManager::hasAudio()
355 {
356     if( hasInput() )
357     {
358         vlc_value_t val;
359         var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
360         return val.i_int > 0;
361     }
362     return false;
363 }
364
365 void InputManager::UpdateSPU()
366 {
367     UpdateTeletext();
368 }
369
370 void InputManager::UpdateTeletext()
371 {
372     if( hasInput() )
373         telexToggle( var_GetInteger( p_input, "teletext-es" ) >= 0 );
374     else
375         telexToggle( false );
376 }
377
378 void InputManager::UpdateVout()
379 {
380     if( hasInput() )
381     {
382         bool b_old_video = b_video;
383
384         vlc_object_t *p_vout = (vlc_object_t*)vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
385         b_video = p_vout != NULL;
386         if( p_vout )
387             vlc_object_release( p_vout );
388         if( !!b_old_video != !!b_video )
389             emit voutChanged( b_video );
390     }
391 }
392
393 void InputManager::UpdateArt()
394 {
395     /* Update Art meta */
396     emit artChanged( input_GetItem( p_input ) );
397 }
398
399 /* User update of the slider */
400 void InputManager::sliderUpdate( float new_pos )
401 {
402     if( hasInput() )
403         var_SetFloat( p_input, "position", new_pos );
404 }
405
406 /* User togglePlayPause */
407 void InputManager::togglePlayPause()
408 {
409     vlc_value_t state;
410     var_Get( p_input, "state", &state );
411     state.i_int = ( state.i_int != PLAYING_S ) ? PLAYING_S : PAUSE_S;
412     var_Set( p_input, "state", state );
413     emit statusChanged( state.i_int );
414 }
415
416 void InputManager::sectionPrev()
417 {
418     if( hasInput() )
419     {
420         int i_type = var_Type( p_input, "next-chapter" );
421         vlc_value_t val; val.b_bool = true;
422         var_Set( p_input, (i_type & VLC_VAR_TYPE) != 0 ?
423                             "prev-chapter":"prev-title", val );
424     }
425 }
426
427 void InputManager::sectionNext()
428 {
429     if( hasInput() )
430     {
431         int i_type = var_Type( p_input, "next-chapter" );
432         vlc_value_t val; val.b_bool = true;
433         var_Set( p_input, (i_type & VLC_VAR_TYPE) != 0 ?
434                             "next-chapter":"next-title", val );
435     }
436 }
437
438 void InputManager::sectionMenu()
439 {
440     if( hasInput() )
441     {
442         vlc_value_t val, text;
443         vlc_value_t root;
444
445         if( var_Change( p_input, "title  0", VLC_VAR_GETLIST, &val, &text ) < 0 )
446             return;
447
448         /* XXX is it "Root" or "Title" we want here ?" (set 0 by default) */
449         root.i_int = 0;
450         for( int i = 0; i < val.p_list->i_count; i++ )
451         {
452             if( !strcmp( text.p_list->p_values[i].psz_string, "Title" ) )
453                 root.i_int = i;
454         }
455         var_Change( p_input, "title  0", VLC_VAR_FREELIST, &val, &text );
456
457         var_Set( p_input, "title  0", root );
458     }
459 }
460
461 void InputManager::telexGotoPage( int page )
462 {
463     if( hasInput() )
464     {
465         const int i_teletext_es = var_GetInteger( p_input, "teletext-es" );
466         const int i_spu_es = var_GetInteger( p_input, "spu-es" );
467
468         if( i_teletext_es >= 0 && i_teletext_es == i_spu_es )
469         {
470             vlc_object_t *p_vbi;
471             p_vbi = (vlc_object_t *) vlc_object_find_name( p_input,
472                         "zvbi", FIND_ANYWHERE );
473             if( p_vbi )
474             {
475                 var_SetInteger( p_vbi, "vbi-page", page );
476                 vlc_object_release( p_vbi );
477             }
478         }
479     }
480     emit setNewTelexPage( page );
481 }
482
483 void InputManager::telexToggle( bool b_enabled )
484 {
485     if( hasInput() )
486     {
487         const int i_teletext_es = var_GetInteger( p_input, "teletext-es" );
488         const int i_spu_es = var_GetInteger( p_input, "spu-es" );
489
490         b_enabled = (i_teletext_es >= 0);
491         emit teletextEnabled( b_enabled );
492         if( b_enabled && (i_teletext_es == i_spu_es) )
493         {
494             vlc_object_t *p_vbi;
495             int i_page = 100;
496             p_vbi = (vlc_object_t *) vlc_object_find_name( p_input,
497                         "zvbi", FIND_ANYWHERE );
498             if( p_vbi )
499             {
500                 i_page = var_GetInteger( p_vbi, "vbi-page" );
501                 vlc_object_release( p_vbi );
502                 i_page = b_enabled ? i_page : 0;
503                 telexGotoPage( i_page );
504             }
505         }
506     }
507     else emit teletextEnabled( b_enabled );
508 }
509
510 void InputManager::telexToggleButtons()
511 {
512     if( hasInput() )
513     {
514         const int i_teletext_es = var_GetInteger( p_input, "teletext-es" );
515         if( i_teletext_es >= 0 )
516         {
517             const int i_spu_es = var_GetInteger( p_input, "spu-es" );
518
519             if( i_teletext_es == i_spu_es )
520                 var_SetInteger( p_input, "spu-es", -1 );
521             else
522                 var_SetInteger( p_input, "spu-es", i_teletext_es );
523
524             emit toggleTelexButtons();
525         }
526     }
527 }
528
529 void InputManager::telexSetTransparency()
530 {
531     if( hasInput() )
532     {
533         vlc_object_t *p_vbi;
534         p_vbi = (vlc_object_t *) vlc_object_find_name( p_input,
535                     "zvbi", FIND_ANYWHERE );
536         if( p_vbi )
537         {
538             var_SetBool( p_vbi, "vbi-opaque", b_transparentTelextext );
539             b_transparentTelextext = !b_transparentTelextext;
540             vlc_object_release( p_vbi );
541         }
542     }
543     emit toggleTelexTransparency();
544 }
545
546 void InputManager::slower()
547 {
548     if( hasInput() )
549         var_SetVoid( p_input, "rate-slower" );
550 }
551
552 void InputManager::faster()
553 {
554     if( hasInput() )
555         var_SetVoid( p_input, "rate-faster" );
556 }
557
558 void InputManager::normalRate()
559 {
560     if( hasInput() )
561         var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
562 }
563
564 void InputManager::setRate( int new_rate )
565 {
566     if( hasInput() )
567         var_SetInteger( p_input, "rate", new_rate );
568 }
569
570 /**********************************************************************
571  * MainInputManager implementation. Wrap an input manager and
572  * take care of updating the main playlist input.
573  * Used in the main playlist Dialog
574  **********************************************************************/
575 MainInputManager * MainInputManager::instance = NULL;
576
577 MainInputManager::MainInputManager( intf_thread_t *_p_intf )
578                  : QObject(NULL), p_intf( _p_intf )
579 {
580     p_input = NULL;
581     im = new InputManager( this, p_intf );
582
583 //    var_AddCallback( THEPL, "item-change", PLItemChanged, this );
584     var_AddCallback( THEPL, "item-change", ItemChanged, im );
585     var_AddCallback( THEPL, "playlist-current", PLItemChanged, this );
586     var_AddCallback( THEPL, "activity", PLItemChanged, this );
587
588     var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
589
590     /* Warn our embedded IM about input changes */
591     CONNECT( this, inputChanged( input_thread_t * ),
592              im, setInput( input_thread_t * ) );
593
594     /* emit check if playlist has allready started playing */
595     vlc_value_t val;
596     var_Change( THEPL, "playlist-current", VLC_VAR_CHOICESCOUNT, &val, NULL );
597     IMEvent *event = new IMEvent( ItemChanged_Type, val.i_int);
598     QApplication::postEvent( this, static_cast<QEvent*>(event) );
599
600 }
601
602 MainInputManager::~MainInputManager()
603 {
604     if( p_input )
605     {
606        var_DelCallback( p_input, "state", PLItemChanged, this );
607        vlc_object_release( p_input );
608        emit inputChanged( NULL );
609     }
610
611     var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this );
612
613     var_DelCallback( THEPL, "activity", PLItemChanged, this );
614     var_DelCallback( THEPL, "item-change", ItemChanged, im );
615 //    var_DelCallback( THEPL, "item-change", PLItemChanged, this );
616
617     var_DelCallback( THEPL, "playlist-current", PLItemChanged, this );
618 }
619
620 void MainInputManager::customEvent( QEvent *event )
621 {
622     int type = event->type();
623     if ( type != ItemChanged_Type && type != VolumeChanged_Type )
624         return;
625
626     // msg_Dbg( p_intf, "New MainIM Event of type: %i", type );
627     if( type == VolumeChanged_Type )
628     {
629         emit volumeChanged();
630         return;
631     }
632
633     /* Should be PLItemChanged Event */
634     if( VLC_OBJECT_INTF == p_intf->i_object_type ) /* FIXME: don't use object type */
635     {
636         vlc_mutex_lock( &p_intf->change_lock );
637         if( p_input && ( p_input->b_dead || !vlc_object_alive (p_input) ) )
638         {
639             var_DelCallback( p_input, "state", PLItemChanged, this );
640             vlc_object_release( p_input );
641             emit inputChanged( NULL );
642             p_input = NULL;
643             vlc_mutex_unlock( &p_intf->change_lock );
644             return;
645         }
646
647         if( !p_input )
648         {
649             QPL_LOCK;
650             p_input = THEPL->p_input;
651             if( p_input && !( !vlc_object_alive (p_input) || p_input->b_dead) )
652             {
653                 vlc_object_hold( p_input );
654                 var_AddCallback( p_input, "state", PLItemChanged, this );
655                 emit inputChanged( p_input );
656             }
657             else
658                 p_input = NULL;
659             QPL_UNLOCK;
660         }
661         vlc_mutex_unlock( &p_intf->change_lock );
662     }
663     else
664     {
665         /* we are working as a dialogs provider */
666         playlist_t *p_playlist = pl_Yield( p_intf );
667         p_input = playlist_CurrentInput( p_playlist );
668         if( p_input )
669         {
670             emit inputChanged( p_input );
671             vlc_object_release( p_input );
672         }
673         pl_Release( p_intf );
674     }
675 }
676
677 /* Playlist Control functions */
678 void MainInputManager::stop()
679 {
680    playlist_Stop( THEPL );
681 }
682
683 void MainInputManager::next()
684 {
685    playlist_Next( THEPL );
686 }
687
688 void MainInputManager::prev()
689 {
690    playlist_Prev( THEPL );
691 }
692
693 void MainInputManager::togglePlayPause()
694 {
695     if( p_input == NULL )
696     {
697         playlist_Play( THEPL );
698         return;
699     }
700     getIM()->togglePlayPause();
701 }
702
703 bool MainInputManager::teletextState()
704 {
705     im = getIM();
706     if( im->hasInput() )
707     {
708         const int i_teletext_es = var_GetInteger( getInput(), "teletext-es" );
709         const int i_spu_es = var_GetInteger( getInput(), "spu-es" );
710
711         return i_teletext_es >= 0 && i_teletext_es == i_spu_es;
712     }
713     return false;
714 }
715
716 /* Static callbacks */
717
718 /* IM */
719 static int InterfaceChanged( vlc_object_t *p_this, const char *psz_var,
720                            vlc_value_t oldval, vlc_value_t newval, void *param )
721 {
722     /* FIXME remove that static variable */
723     static int counter = 0;
724     InputManager *im = (InputManager*)param;
725
726     counter = ++counter % 4;
727     if(!counter)
728         return VLC_SUCCESS;
729     IMEvent *event = new IMEvent( PositionUpdate_Type, 0 );
730     QApplication::postEvent( im, static_cast<QEvent*>(event) );
731     return VLC_SUCCESS;
732 }
733
734 static int InterfaceVoutChanged( vlc_object_t *p_this, const char *psz_var,
735                                  vlc_value_t oldval, vlc_value_t newval, void *param )
736 {
737     InputManager *im = (InputManager*)param;
738
739     IMEvent *event = new IMEvent( InterfaceVoutUpdate_Type, 0 );
740     QApplication::postEvent( im, static_cast<QEvent*>(event) );
741     return VLC_SUCCESS;
742 }
743
744 static int ItemStateChanged( vlc_object_t *p_this, const char *psz_var,
745                            vlc_value_t oldval, vlc_value_t newval, void *param )
746 {
747     InputManager *im = (InputManager*)param;
748
749     IMEvent *event = new IMEvent( ItemStateChanged_Type, 0 );
750     QApplication::postEvent( im, static_cast<QEvent*>(event) );
751     return VLC_SUCCESS;
752 }
753
754 static int ItemRateChanged( vlc_object_t *p_this, const char *psz_var,
755                            vlc_value_t oldval, vlc_value_t newval, void *param )
756 {
757     InputManager *im = (InputManager*)param;
758
759     IMEvent *event = new IMEvent( ItemRateChanged_Type, 0 );
760     QApplication::postEvent( im, static_cast<QEvent*>(event) );
761     return VLC_SUCCESS;
762 }
763
764 static int ItemTitleChanged( vlc_object_t *p_this, const char *psz_var,
765                            vlc_value_t oldval, vlc_value_t newval, void *param )
766 {
767     InputManager *im = (InputManager*)param;
768
769     IMEvent *event = new IMEvent( ItemTitleChanged_Type, 0 );
770     QApplication::postEvent( im, static_cast<QEvent*>(event) );
771     return VLC_SUCCESS;
772 }
773
774 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
775                         vlc_value_t oldval, vlc_value_t newval, void *param )
776 {
777     InputManager *im = (InputManager*)param;
778
779     IMEvent *event = new IMEvent( ItemChanged_Type, newval.i_int );
780     QApplication::postEvent( im, static_cast<QEvent*>(event) );
781     return VLC_SUCCESS;
782 }
783
784 static int ChangeSPU( vlc_object_t *p_this, const char *var, vlc_value_t o,
785                         vlc_value_t n, void *param )
786 {
787     InputManager *im = (InputManager*)param;
788     IMEvent *event = new IMEvent( ItemSpuChanged_Type, 0 );
789     QApplication::postEvent( im, static_cast<QEvent*>(event) );
790     return VLC_SUCCESS;
791 }
792
793 static int ChangeTeletext( vlc_object_t *p_this, const char *var, vlc_value_t o,
794                            vlc_value_t n, void *param )
795 {
796
797     InputManager *im = (InputManager*)param;
798     IMEvent *event = new IMEvent( ItemTeletextChanged_Type, 0 );
799     QApplication::postEvent( im, static_cast<QEvent*>(event) );
800     return VLC_SUCCESS;
801 }
802
803 /* MIM */
804 static int PLItemChanged( vlc_object_t *p_this, const char *psz_var,
805                         vlc_value_t oldval, vlc_value_t newval, void *param )
806 {
807     MainInputManager *mim = (MainInputManager*)param;
808
809     IMEvent *event = new IMEvent( ItemChanged_Type, newval.i_int );
810     QApplication::postEvent( mim, static_cast<QEvent*>(event) );
811     return VLC_SUCCESS;
812 }
813
814 static int VolumeChanged( vlc_object_t *p_this, const char *psz_var,
815                         vlc_value_t oldval, vlc_value_t newval, void *param )
816 {
817     MainInputManager *mim = (MainInputManager*)param;
818
819     IMEvent *event = new IMEvent( VolumeChanged_Type, newval.i_int );
820     QApplication::postEvent( mim, static_cast<QEvent*>(event) );
821     return VLC_SUCCESS;
822 }
823