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