]> git.sesse.net Git - vlc/blob - modules/control/hotkeys.c
* check for p_vout before accessing it. (quit before playing would cause a crash...
[vlc] / modules / control / hotkeys.c
1 /*****************************************************************************
2  * hotkeys.c: Hotkey handling for vlc
3  *****************************************************************************
4  * Copyright (C) 2004 VideoLAN
5  * $Id$
6  *
7  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28
29 #include <vlc/vlc.h>
30 #include <vlc/intf.h>
31 #include <vlc/input.h>
32 #include <vlc/vout.h>
33 #include <vlc/aout.h>
34 #include <osd.h>
35
36 #include "vlc_keys.h"
37
38 #define BUFFER_SIZE 10
39
40 #define CHANNELS_NUMBER 4
41 #define VOLUME_TEXT_CHAN     p_intf->p_sys->p_channels[ 0 ]
42 #define VOLUME_WIDGET_CHAN   p_intf->p_sys->p_channels[ 1 ]
43 #define POSITION_TEXT_CHAN   p_intf->p_sys->p_channels[ 2 ]
44 #define POSITION_WIDGET_CHAN p_intf->p_sys->p_channels[ 3 ]
45 /*****************************************************************************
46  * intf_sys_t: description and status of FB interface
47  *****************************************************************************/
48 struct intf_sys_t
49 {
50     vlc_mutex_t         change_lock;  /* mutex to keep the callback
51                                        * and the main loop from
52                                        * stepping on each others
53                                        * toes */
54     int                 p_keys[ BUFFER_SIZE ]; /* buffer that contains
55                                                 * keyevents */
56     int                 i_size;        /* number of events in buffer */
57     int                 p_channels[ CHANNELS_NUMBER ]; /* contains registered
58                                                         * channel IDs */
59     input_thread_t *    p_input;       /* pointer to input */
60     vout_thread_t *     p_vout;        /* pointer to vout object */
61 };
62
63 /*****************************************************************************
64  * Local prototypes
65  *****************************************************************************/
66 static int  Open    ( vlc_object_t * );
67 static void Close   ( vlc_object_t * );
68 static void Run     ( intf_thread_t * );
69 static int  GetKey  ( intf_thread_t *);
70 static int  KeyEvent( vlc_object_t *, char const *,
71                       vlc_value_t, vlc_value_t, void * );
72 static int  ActionKeyCB( vlc_object_t *, char const *,
73                          vlc_value_t, vlc_value_t, void * );
74 static void PlayBookmark( intf_thread_t *, int );
75 static void SetBookmark ( intf_thread_t *, int );
76 static void DisplayPosition( intf_thread_t *, vout_thread_t *, input_thread_t * );
77 static void DisplayVolume  ( intf_thread_t *, vout_thread_t *, audio_volume_t );
78 static void ClearChannels  ( intf_thread_t *, vout_thread_t * );
79
80 /*****************************************************************************
81  * Module descriptor
82  *****************************************************************************/
83 #define BOOKMARK1_TEXT N_("Playlist bookmark 1")
84 #define BOOKMARK2_TEXT N_("Playlist bookmark 2")
85 #define BOOKMARK3_TEXT N_("Playlist bookmark 3")
86 #define BOOKMARK4_TEXT N_("Playlist bookmark 4")
87 #define BOOKMARK5_TEXT N_("Playlist bookmark 5")
88 #define BOOKMARK6_TEXT N_("Playlist bookmark 6")
89 #define BOOKMARK7_TEXT N_("Playlist bookmark 7")
90 #define BOOKMARK8_TEXT N_("Playlist bookmark 8")
91 #define BOOKMARK9_TEXT N_("Playlist bookmark 9")
92 #define BOOKMARK10_TEXT N_("Playlist bookmark 10")
93 #define BOOKMARK_LONGTEXT N_( \
94     "This option allows you to define playlist bookmarks.")
95
96 vlc_module_begin();
97     set_description( _("Hotkeys management interface") );
98     add_string( "bookmark1", NULL, NULL,
99                 BOOKMARK1_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
100     add_string( "bookmark2", NULL, NULL,
101                 BOOKMARK2_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
102     add_string( "bookmark3", NULL, NULL,
103                 BOOKMARK3_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
104     add_string( "bookmark4", NULL, NULL,
105                 BOOKMARK4_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
106     add_string( "bookmark5", NULL, NULL,
107                 BOOKMARK5_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
108     add_string( "bookmark6", NULL, NULL,
109                 BOOKMARK6_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
110     add_string( "bookmark7", NULL, NULL,
111                 BOOKMARK7_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
112     add_string( "bookmark8", NULL, NULL,
113                 BOOKMARK8_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
114     add_string( "bookmark9", NULL, NULL,
115                 BOOKMARK9_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
116     add_string( "bookmark10", NULL, NULL,
117                 BOOKMARK10_TEXT, BOOKMARK_LONGTEXT, VLC_FALSE );
118
119     set_capability( "interface", 0 );
120     set_callbacks( Open, Close );
121 vlc_module_end();
122
123 /*****************************************************************************
124  * Open: initialize interface
125  *****************************************************************************/
126 static int Open( vlc_object_t *p_this )
127 {
128     intf_thread_t *p_intf = (intf_thread_t *)p_this;
129
130     /* Allocate instance and initialize some members */
131     p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
132     if( p_intf->p_sys == NULL )
133     {
134         msg_Err( p_intf, "out of memory" );
135         return 1;
136     }
137     vlc_mutex_init( p_intf, &p_intf->p_sys->change_lock );
138     p_intf->p_sys->i_size = 0;
139     p_intf->pf_run = Run;
140
141     p_intf->p_sys->p_input = NULL;
142     p_intf->p_sys->p_vout = NULL;
143
144     var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
145     return 0;
146 }
147
148 /*****************************************************************************
149  * Close: destroy interface
150  *****************************************************************************/
151 static void Close( vlc_object_t *p_this )
152 {
153     intf_thread_t *p_intf = (intf_thread_t *)p_this;
154
155     if( p_intf->p_sys->p_input )
156     {
157         vlc_object_release( p_intf->p_sys->p_input );
158     }
159     if( p_intf->p_sys->p_vout )
160     {
161         vlc_object_release( p_intf->p_sys->p_vout );
162     }
163     /* Destroy structure */
164     free( p_intf->p_sys );
165 }
166
167 /*****************************************************************************
168  * Run: main loop
169  *****************************************************************************/
170 static void Run( intf_thread_t *p_intf )
171 {
172     playlist_t *p_playlist;
173     input_thread_t *p_input;
174     vout_thread_t *p_vout = NULL;
175     vout_thread_t *p_last_vout;
176     struct hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
177     vlc_value_t val;
178     int i;
179
180     /* Initialize hotkey structure */
181     for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
182     {
183         var_Create( p_intf->p_vlc, p_hotkeys[i].psz_action,
184                     VLC_VAR_HOTKEY | VLC_VAR_DOINHERIT );
185
186         var_AddCallback( p_intf->p_vlc, p_hotkeys[i].psz_action,
187                          ActionKeyCB, NULL );
188         var_Get( p_intf->p_vlc, p_hotkeys[i].psz_action, &val );
189         var_Set( p_intf->p_vlc, p_hotkeys[i].psz_action, val );
190     }
191
192     while( !p_intf->b_die )
193     {
194         int i_key, i_action;
195
196         /* Sleep a bit */
197         msleep( INTF_IDLE_SLEEP );
198
199         /* Update the input */
200         if( p_intf->p_sys->p_input == NULL )
201         {
202             p_intf->p_sys->p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT,
203                                                       FIND_ANYWHERE );
204         }
205         else if( p_intf->p_sys->p_input->b_dead )
206         {
207             vlc_object_release( p_intf->p_sys->p_input );
208             p_intf->p_sys->p_input = NULL;
209         }
210         p_input = p_intf->p_sys->p_input;
211
212         /* Update the vout */
213         p_last_vout = p_intf->p_sys->p_vout;
214         if( p_vout == NULL )
215         {
216             p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
217             p_intf->p_sys->p_vout = p_vout;
218         }
219         else if( p_vout->b_die )
220         {
221             vlc_object_release( p_vout );
222             p_vout = NULL;
223             p_intf->p_sys->p_vout = NULL;
224         }
225
226         /* Register OSD channels */
227         if( p_vout && p_vout != p_last_vout )
228         {
229             for( i = 0; i < CHANNELS_NUMBER; i++ )
230             {
231                 p_intf->p_sys->p_channels[ i ] =
232                     vout_RegisterOSDChannel( p_vout );
233             }
234         }
235
236         /* Find action triggered by hotkey */
237         i_action = 0;
238         i_key = GetKey( p_intf );
239         for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
240         {
241             if( p_hotkeys[i].i_key == i_key )
242             {
243                  i_action = p_hotkeys[i].i_action;
244             }
245         }
246
247         if( !i_action )
248         {
249             /* No key pressed, sleep a bit more */
250             msleep( INTF_IDLE_SLEEP );
251             continue;
252         }
253
254         if( i_action == ACTIONID_QUIT )
255         {
256             p_intf->p_vlc->b_die = VLC_TRUE;
257             ClearChannels( p_intf, p_vout );
258             vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );
259             continue;
260         }
261         else if( i_action == ACTIONID_VOL_UP )
262         {
263             audio_volume_t i_newvol;
264             aout_VolumeUp( p_intf, 1, &i_newvol );
265             DisplayVolume( p_intf, p_vout, i_newvol );
266         }
267         else if( i_action == ACTIONID_VOL_DOWN )
268         {
269             audio_volume_t i_newvol;
270             aout_VolumeDown( p_intf, 1, &i_newvol );
271             DisplayVolume( p_intf, p_vout, i_newvol );
272         }
273         else if( i_action == ACTIONID_VOL_MUTE )
274         {
275             audio_volume_t i_newvol = -1;
276             aout_VolumeMute( p_intf, &i_newvol );
277             if( p_vout )
278             {
279                 if( i_newvol == 0 )
280                 {
281                     ClearChannels( p_intf, p_vout );
282                     vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
283                                   OSD_MUTE_ICON );
284                 }
285                 else
286                 {
287                     DisplayVolume( p_intf, p_vout, i_newvol );
288                 }
289             }
290         }
291
292         else if( i_action == ACTIONID_SUBDELAY_DOWN )
293         {
294             int64_t i_delay = var_GetTime( p_input, "spu-delay" );
295
296             i_delay -= 10000;    /* 10 ms */
297
298             var_SetTime( p_input, "spu-delay", i_delay );
299             ClearChannels( p_intf, p_vout );
300             vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
301                                  (int)(i_delay/1000) );
302         }
303         else if( i_action == ACTIONID_SUBDELAY_UP )
304         {
305             int64_t i_delay = var_GetTime( p_input, "spu-delay" );
306
307             i_delay += 10000;    /* 10 ms */
308
309             var_SetTime( p_input, "spu-delay", i_delay );
310             ClearChannels( p_intf, p_vout );
311             vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
312                                  (int)(i_delay/1000) );
313         }
314         else if( i_action == ACTIONID_FULLSCREEN && p_vout )
315         {
316             var_Get( p_vout, "fullscreen", &val );
317             var_Set( p_vout, "fullscreen", (vlc_value_t)!val.b_bool );
318         }
319         else if( i_action == ACTIONID_PLAY )
320         {
321             p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
322                                           FIND_ANYWHERE );
323             if( p_playlist )
324             {
325                 playlist_Play( p_playlist );
326                 vlc_object_release( p_playlist );
327             }
328         }
329         else if( i_action == ACTIONID_PLAY_PAUSE )
330         {
331             val.i_int = PLAYING_S;
332             if( p_input )
333             {
334                 var_Get( p_input, "state", &val );
335             }
336             if( p_input && val.i_int != PAUSE_S )
337             {
338                 ClearChannels( p_intf, p_vout );
339                 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
340                               OSD_PAUSE_ICON );
341                 val.i_int = PAUSE_S;
342                 var_Set( p_input, "state", val );
343             }
344             else
345             {
346                 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
347                                               FIND_ANYWHERE );
348                 if( p_playlist )
349                 {
350                     ClearChannels( p_intf, p_vout );
351                     vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
352                                   OSD_PLAY_ICON );
353                     playlist_Play( p_playlist );
354                     vlc_object_release( p_playlist );
355                 }
356             }
357         }
358         else if( p_input )
359         {
360             /* FIXME --fenrir
361              * How to get a valid value ?
362              * That's not that easy with some special stream
363              */
364             vlc_bool_t b_seekable = VLC_TRUE;
365
366             if( i_action == ACTIONID_PAUSE )
367             {
368                 ClearChannels( p_intf, p_vout );
369                 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
370                               OSD_PAUSE_ICON );
371                 val.i_int = PAUSE_S;
372                 var_Set( p_input, "state", val );
373             }
374             else if( i_action == ACTIONID_JUMP_BACKWARD_10SEC && b_seekable )
375             {
376                 val.i_time = -10000000;
377                 var_Set( p_input, "time-offset", val );
378                 DisplayPosition( p_intf, p_vout, p_input );
379             }
380             else if( i_action == ACTIONID_JUMP_FORWARD_10SEC && b_seekable )
381             {
382                 val.i_time = 10000000;
383                 var_Set( p_input, "time-offset", val );
384                 DisplayPosition( p_intf, p_vout, p_input );
385             }
386             else if( i_action == ACTIONID_JUMP_BACKWARD_1MIN && b_seekable )
387             {
388                 val.i_time = -60000000;
389                 var_Set( p_input, "time-offset", val );
390                 DisplayPosition( p_intf, p_vout, p_input );
391             }
392             else if( i_action == ACTIONID_JUMP_FORWARD_1MIN && b_seekable )
393             {
394                 val.i_time = 60000000;
395                 var_Set( p_input, "time-offset", val );
396                 DisplayPosition( p_intf, p_vout, p_input );
397             }
398             else if( i_action == ACTIONID_JUMP_BACKWARD_5MIN && b_seekable )
399             {
400                 val.i_time = -300000000;
401                 var_Set( p_input, "time-offset", val );
402                 DisplayPosition( p_intf, p_vout, p_input );
403             }
404             else if( i_action == ACTIONID_JUMP_FORWARD_5MIN && b_seekable )
405             {
406                 val.i_time = 300000000;
407                 var_Set( p_input, "time-offset", val );
408                 DisplayPosition( p_intf, p_vout, p_input );
409             }
410             else if( i_action == ACTIONID_NEXT )
411             {
412                 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
413                                               FIND_ANYWHERE );
414                 if( p_playlist )
415                 {
416                     playlist_Next( p_playlist );
417                     vlc_object_release( p_playlist );
418                 }
419             }
420             else if( i_action == ACTIONID_PREV )
421             {
422                 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
423                                               FIND_ANYWHERE );
424                 if( p_playlist )
425                 {
426                     playlist_Prev( p_playlist );
427                     vlc_object_release( p_playlist );
428                 }
429             }
430             else if( i_action == ACTIONID_STOP )
431             {
432                 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
433                                               FIND_ANYWHERE );
434                 if( p_playlist )
435                 {
436                     playlist_Stop( p_playlist );
437                     vlc_object_release( p_playlist );
438                 }
439             }
440             else if( i_action == ACTIONID_FASTER )
441             {
442                 vlc_value_t val; val.b_bool = VLC_TRUE;
443                 var_Set( p_input, "rate-faster", val );
444             }
445             else if( i_action == ACTIONID_SLOWER )
446             {
447                 vlc_value_t val; val.b_bool = VLC_TRUE;
448                 var_Set( p_input, "rate-slower", val );
449             }
450             else if( i_action == ACTIONID_POSITION && b_seekable )
451             {
452                 DisplayPosition( p_intf, p_vout, p_input );
453             }
454             else if( i_action >= ACTIONID_PLAY_BOOKMARK1 &&
455                      i_action <= ACTIONID_PLAY_BOOKMARK10 )
456             {
457                 PlayBookmark( p_intf, i_action - ACTIONID_PLAY_BOOKMARK1 + 1 );
458             }
459             else if( i_action >= ACTIONID_SET_BOOKMARK1 &&
460                      i_action <= ACTIONID_SET_BOOKMARK10 )
461             {
462                 SetBookmark( p_intf, i_action - ACTIONID_SET_BOOKMARK1 + 1 );
463             }
464         }
465     }
466 }
467
468 static int GetKey( intf_thread_t *p_intf)
469 {
470     vlc_mutex_lock( &p_intf->p_sys->change_lock );
471     if ( p_intf->p_sys->i_size == 0 )
472     {
473         vlc_mutex_unlock( &p_intf->p_sys->change_lock );
474         return -1;
475     }
476     else
477     {
478         int i_return = p_intf->p_sys->p_keys[ 0 ];
479         int i;
480         p_intf->p_sys->i_size--;
481         for ( i = 0; i < BUFFER_SIZE - 1; i++)
482         {
483             p_intf->p_sys->p_keys[ i ] = p_intf->p_sys->p_keys[ i + 1 ];
484         }
485         vlc_mutex_unlock( &p_intf->p_sys->change_lock );
486         return i_return;
487     }
488 }
489
490 /*****************************************************************************
491  * KeyEvent: callback for keyboard events
492  *****************************************************************************/
493 static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
494                      vlc_value_t oldval, vlc_value_t newval, void *p_data )
495 {
496     intf_thread_t *p_intf = (intf_thread_t *)p_data;
497     vlc_mutex_lock( &p_intf->p_sys->change_lock );
498     if ( p_intf->p_sys->i_size == BUFFER_SIZE )
499     {
500         msg_Warn( p_intf, "event buffer full, dropping keypress" );
501         vlc_mutex_unlock( &p_intf->p_sys->change_lock );
502         return VLC_EGENERIC;
503     }
504     else
505     {
506         p_intf->p_sys->p_keys[ p_intf->p_sys->i_size ] = newval.i_int;
507         p_intf->p_sys->i_size++;
508     }
509     vlc_mutex_unlock( &p_intf->p_sys->change_lock );
510
511     return VLC_SUCCESS;
512 }
513
514 static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var,
515                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
516 {
517     vlc_t *p_vlc = (vlc_t *)p_this;
518     struct hotkey *p_hotkeys = p_vlc->p_hotkeys;
519     int i;
520
521     for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
522     {
523         if( !strcmp( p_hotkeys[i].psz_action, psz_var ) )
524         {
525             p_hotkeys[i].i_key = newval.i_int;
526         }
527     }
528
529     return VLC_SUCCESS;
530 }
531
532 static void PlayBookmark( intf_thread_t *p_intf, int i_num )
533 {
534     vlc_value_t val;
535     int i_position;
536     char psz_bookmark_name[11];
537     playlist_t *p_playlist =
538         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
539
540     sprintf( psz_bookmark_name, "bookmark%i", i_num );
541     var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT );
542     var_Get( p_intf, psz_bookmark_name, &val );
543
544     if( p_playlist )
545     {
546         char *psz_bookmark = strdup( val.psz_string );
547         for( i_position = 0; i_position < p_playlist->i_size; i_position++)
548         {
549             if( !strcmp( psz_bookmark,
550                          p_playlist->pp_items[i_position]->input.psz_uri ) )
551             {
552                 playlist_Goto( p_playlist, i_position );
553                 break;
554             }
555         }
556         vlc_object_release( p_playlist );
557     }
558 }
559
560 static void SetBookmark( intf_thread_t *p_intf, int i_num )
561 {
562     vlc_value_t val;
563     playlist_t *p_playlist =
564         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
565     if( p_playlist )
566     {
567         char psz_bookmark_name[11];
568         sprintf( psz_bookmark_name, "bookmark%i", i_num );
569         var_Create( p_intf, psz_bookmark_name,
570                     VLC_VAR_STRING|VLC_VAR_DOINHERIT );
571         val.psz_string = strdup( p_playlist->pp_items[p_playlist->i_index]->input.psz_uri );
572         var_Set( p_intf, psz_bookmark_name, val );
573         msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
574                   val.psz_string );
575         vlc_object_release( p_playlist );
576     }
577 }
578
579 static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
580                              input_thread_t *p_input )
581 {
582     char psz_duration[MSTRTIME_MAX_SIZE];
583     char psz_time[MSTRTIME_MAX_SIZE];
584     vlc_value_t time, pos;
585     mtime_t i_seconds;
586
587     if( p_vout == NULL )
588     {
589         return;
590     }
591     ClearChannels( p_intf, p_vout );
592
593     var_Get( p_input, "time", &time );
594     i_seconds = time.i_time / 1000000;
595     secstotimestr ( psz_time, i_seconds );
596
597     var_Get( p_input, "length", &time );
598     if( time.i_time > 0 )
599     {
600         secstotimestr( psz_duration, time.i_time / 1000000 );
601         vout_OSDMessage( p_input, POSITION_TEXT_CHAN, "%s / %s",
602                          psz_time, psz_duration );
603     }
604     else if( i_seconds > 0 )
605     {
606         vout_OSDMessage( p_input, POSITION_TEXT_CHAN, psz_time );
607     }
608
609     if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
610     {
611         var_Get( p_input, "position", &pos );
612         vout_OSDSlider( VLC_OBJECT( p_input ), POSITION_WIDGET_CHAN,
613                         pos.f_float * 100, OSD_HOR_SLIDER );
614     }
615 }
616
617 static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
618                            audio_volume_t i_vol )
619 {
620     if( p_vout == NULL )
621     {
622         return;
623     }
624     ClearChannels( p_intf, p_vout );
625
626     if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
627     {
628         vout_OSDSlider( VLC_OBJECT( p_vout ), VOLUME_WIDGET_CHAN,
629             i_vol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );
630     }
631     else
632     {
633         vout_OSDMessage( p_vout, VOLUME_TEXT_CHAN, "Vol %d%%",
634                          2*i_vol*100/AOUT_VOLUME_MAX );
635     }
636 }
637
638 static void ClearChannels( intf_thread_t *p_intf, vout_thread_t *p_vout )
639 {
640     int i;
641
642     if( p_vout )
643     {
644         vout_ClearOSDChannel( p_vout, DEFAULT_CHAN );
645         for( i = 0; i < CHANNELS_NUMBER; i++ )
646         {
647             vout_ClearOSDChannel( p_vout, p_intf->p_sys->p_channels[ i ] );
648         }
649     }
650 }