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