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