]> git.sesse.net Git - vlc/blob - modules/control/hotkeys.c
* modules/control/hotkeys.c: check if there is a vout before writing some OSD, since...
[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 )
243             {
244                 if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
245                 {
246                     vout_OSDSlider( VLC_OBJECT( p_intf ),
247                                     i_newvol*100/AOUT_VOLUME_MAX, 1 );
248                 }
249                 else
250                 {
251                     vout_OSDMessage( p_intf, "Vol %d%%",
252                                      2*i_newvol*100/AOUT_VOLUME_MAX );
253                 }
254             }
255         }
256         else if( i_action == ACTIONID_VOL_DOWN )
257         {
258             audio_volume_t i_newvol;
259             aout_VolumeDown( p_intf, 1, &i_newvol );
260             if( p_vout )
261             {
262                 if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
263                 {
264                     vout_OSDSlider( VLC_OBJECT( p_intf ),
265                                     i_newvol*100/AOUT_VOLUME_MAX, 1 );
266                 }
267                 else
268                 {
269                     vout_OSDMessage( p_intf, "Vol %d%%",
270                                      2*i_newvol*100/AOUT_VOLUME_MAX );
271                 }
272             }
273
274         }
275         else if( i_action == ACTIONID_SUBDELAY_DOWN )
276         {
277             int i_delay;
278             if( input_Control( p_input, INPUT_GET_SUBDELAY, &i_delay ) ==
279                 VLC_SUCCESS )
280             {
281                 i_delay--;
282                 input_Control( p_input, INPUT_SET_SUBDELAY, i_delay );
283                 vout_OSDMessage( p_intf, "Subtitle delay %i ms", i_delay*100);
284             }
285         }
286         else if( i_action == ACTIONID_SUBDELAY_UP )
287         {
288             int i_delay;
289             if( input_Control( p_input, INPUT_GET_SUBDELAY, &i_delay ) ==
290                 VLC_SUCCESS )
291             {
292                 i_delay++;
293                 input_Control( p_input, INPUT_SET_SUBDELAY, i_delay );
294                 vout_OSDMessage( p_intf, "Subtitle delay %i ms", i_delay*100);
295             }
296         }
297         else if( i_action == ACTIONID_VOL_MUTE )
298         {
299             audio_volume_t i_newvol = -1;
300             aout_VolumeMute( p_intf, &i_newvol );
301             if( i_newvol == 0 )
302             {
303                 vout_OSDMessage( p_intf, _( "Mute" ) );
304             }
305             else
306             {
307                 vout_OSDMessage( p_intf, "Vol %d%%",
308                                  i_newvol * 100 / AOUT_VOLUME_MAX );
309             }
310         }
311         else if( i_action == ACTIONID_FULLSCREEN && p_vout )
312         {
313             var_Get( p_vout, "fullscreen", &val );
314             var_Set( p_vout, "fullscreen", (vlc_value_t)!val.b_bool );
315         }
316         else if( i_action == ACTIONID_PLAY )
317         {
318             p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
319                                           FIND_ANYWHERE );
320             if( p_playlist )
321             {
322                 playlist_Play( p_playlist );
323                 vlc_object_release( p_playlist );
324             }
325         }
326         else if( i_action == ACTIONID_PLAY_PAUSE )
327         {
328             val.i_int = PLAYING_S;
329             if( p_input )
330             {
331                 var_Get( p_input, "state", &val );
332             }
333             if( p_input && val.i_int != PAUSE_S )
334             {
335                 vout_OSDMessage( p_intf, _( "Pause" ) );
336                 val.i_int = PAUSE_S;
337                 var_Set( p_input, "state", val );
338             }
339             else
340             {
341                 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
342                                               FIND_ANYWHERE );
343                 if( p_playlist )
344                 {
345                     vout_OSDMessage( p_intf, _( "Play" ) );
346                     playlist_Play( p_playlist );
347                     vlc_object_release( p_playlist );
348                 }
349             }
350         }
351         else if( p_input )
352         {
353             vlc_bool_t b_seekable = p_input->stream.b_seekable;
354
355             if( i_action == ACTIONID_PAUSE )
356             {
357                 vout_OSDMessage( p_intf, _( "Pause" ) );
358                 val.i_int = PAUSE_S;
359                 var_Set( p_input, "state", val );
360             }
361             else if( i_action == ACTIONID_JUMP_BACKWARD_10SEC && b_seekable )
362             {
363                 val.i_time = -10000000;
364                 var_Set( p_input, "time-offset", val );
365                 if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
366                 {
367                     vout_OSDSlider( VLC_OBJECT( p_intf ),
368                                     GetPosition( p_intf ), 0 );
369                 }
370                 else
371                 {
372                     vout_OSDMessage( p_intf, _( "Jump -10 seconds" ) );
373                 }
374             }
375             else if( i_action == ACTIONID_JUMP_FORWARD_10SEC && b_seekable )
376             {
377                 val.i_time = 10000000;
378                 var_Set( p_input, "time-offset", val );
379                 if( p_vout )
380                 {
381                     if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
382                     {
383                         vout_OSDSlider( VLC_OBJECT( p_intf ),
384                                         GetPosition( p_intf ), 0 );
385                     }
386                     else
387                     {
388                         vout_OSDMessage( p_intf, _( "Jump +10 seconds" ) );
389                     }
390                 }
391             }
392             else if( i_action == ACTIONID_JUMP_BACKWARD_1MIN && b_seekable )
393             {
394                 val.i_time = -60000000;
395                 var_Set( p_input, "time-offset", val );
396                 if( p_vout )
397                 {
398                     if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
399                     {
400                         vout_OSDSlider( VLC_OBJECT( p_intf ),
401                                         GetPosition( p_intf ), 0 );
402                     }
403                     else
404                     {
405                         vout_OSDMessage( p_intf, _( "Jump -1 minute" ) );
406                     }
407                 }
408             }
409             else if( i_action == ACTIONID_JUMP_FORWARD_1MIN && b_seekable )
410             {
411                 val.i_time = 60000000;
412                 var_Set( p_input, "time-offset", val );
413                 if( p_vout )
414                 {
415                     if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
416                     {
417                         vout_OSDSlider( VLC_OBJECT( p_intf ),
418                                         GetPosition( p_intf ), 0 );
419                     }
420                     else
421                     {
422                         vout_OSDMessage( p_intf, _( "Jump +1 minute" ) );
423                     }
424                 }
425             }
426             else if( i_action == ACTIONID_JUMP_BACKWARD_5MIN && b_seekable )
427             {
428                 vout_OSDMessage( p_intf, _( "Jump -5 minutes" ) );
429                 val.i_time = -300000000;
430                 var_Set( p_input, "time-offset", val );
431                 if( p_vout )
432                 {
433                     if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
434                     {
435                         vout_OSDSlider( VLC_OBJECT( p_intf ),
436                                         GetPosition( p_intf ), 0 );
437                     }
438                     else
439                     {
440                         vout_OSDMessage( p_intf, _( "Jump -5 minutes" ) );
441                     }
442                 }
443             }
444             else if( i_action == ACTIONID_JUMP_FORWARD_5MIN && b_seekable )
445             {
446                 val.i_time = 300000000;
447                 var_Set( p_input, "time-offset", val );
448                 if( p_vout )
449                 {
450                     if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
451                     {
452                         vout_OSDSlider( VLC_OBJECT( p_intf ),
453                                         GetPosition( p_intf ), 0 );
454                     }
455                     else
456                     {
457                         vout_OSDMessage( p_intf, _( "Jump +5 minutes" ) );
458                     }
459                 }
460             }
461             else if( i_action == ACTIONID_NEXT )
462             {
463                 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
464                                               FIND_ANYWHERE );
465                 if( p_playlist )
466                 {
467                     playlist_Next( p_playlist );
468                     vlc_object_release( p_playlist );
469                 }
470             }
471             else if( i_action == ACTIONID_PREV )
472             {
473                 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
474                                               FIND_ANYWHERE );
475                 if( p_playlist )
476                 {
477                     playlist_Prev( p_playlist );
478                     vlc_object_release( p_playlist );
479                 }
480             }
481             else if( i_action == ACTIONID_STOP )
482             {
483                 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
484                                               FIND_ANYWHERE );
485                 if( p_playlist )
486                 {
487                     playlist_Stop( p_playlist );
488                     vlc_object_release( p_playlist );
489                 }
490             }
491             else if( i_action == ACTIONID_FASTER )
492             {
493                 vlc_value_t val; val.b_bool = VLC_TRUE;
494                 var_Set( p_input, "rate-faster", val );
495             }
496             else if( i_action == ACTIONID_SLOWER )
497             {
498                 vlc_value_t val; val.b_bool = VLC_TRUE;
499                 var_Set( p_input, "rate-slower", val );
500             }
501             else if( i_action == ACTIONID_POSITION )
502             {
503                 char psz_duration[MSTRTIME_MAX_SIZE];
504                 char psz_time[MSTRTIME_MAX_SIZE];
505                 vlc_value_t time;
506                 mtime_t i_seconds;
507
508                 var_Get( p_input, "time", &time );
509                 i_seconds = time.i_time / 1000000;
510                 secstotimestr ( psz_time, i_seconds );
511
512                 var_Get( p_input, "length", &time );
513                 if( time.i_time > 0 )
514                 {
515                     secstotimestr( psz_duration, time.i_time / 1000000 );
516                     vout_OSDMessage( p_input, "%s / %s",
517                                      psz_time, psz_duration );
518                 }
519                 else if( i_seconds > 0 )
520                 {
521                     vout_OSDMessage( p_input, psz_time );
522                 }
523             }
524             else if( i_action >= ACTIONID_PLAY_BOOKMARK1 &&
525                      i_action <= ACTIONID_PLAY_BOOKMARK10 )
526             {
527                 PlayBookmark( p_intf, i_action - ACTIONID_PLAY_BOOKMARK1 + 1 );
528             }
529             else if( i_action >= ACTIONID_SET_BOOKMARK1 &&
530                      i_action <= ACTIONID_SET_BOOKMARK10 )
531             {
532                 SetBookmark( p_intf, i_action - ACTIONID_SET_BOOKMARK1 + 1 );
533             }
534         }
535     }
536 }
537
538 static int GetKey( intf_thread_t *p_intf)
539 {
540     vlc_mutex_lock( &p_intf->p_sys->change_lock );
541     if ( p_intf->p_sys->i_size == 0 )
542     {
543         vlc_mutex_unlock( &p_intf->p_sys->change_lock );
544         return -1;
545     }
546     else
547     {
548         int i_return = p_intf->p_sys->p_keys[ 0 ];
549         int i;
550         p_intf->p_sys->i_size--;
551         for ( i = 0; i < BUFFER_SIZE - 1; i++)
552         {
553             p_intf->p_sys->p_keys[ i ] = p_intf->p_sys->p_keys[ i + 1 ];
554         }
555         vlc_mutex_unlock( &p_intf->p_sys->change_lock );
556         return i_return;
557     }
558 }
559
560 /*****************************************************************************
561  * KeyEvent: callback for keyboard events
562  *****************************************************************************/
563 static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
564                      vlc_value_t oldval, vlc_value_t newval, void *p_data )
565 {
566     intf_thread_t *p_intf = (intf_thread_t *)p_data;
567     vlc_mutex_lock( &p_intf->p_sys->change_lock );
568     if ( p_intf->p_sys->i_size == BUFFER_SIZE )
569     {
570         msg_Warn( p_intf, "event buffer full, dropping keypress" );
571         vlc_mutex_unlock( &p_intf->p_sys->change_lock );
572         return VLC_EGENERIC;
573     }
574     else
575     {
576         p_intf->p_sys->p_keys[ p_intf->p_sys->i_size ] = newval.i_int;
577         p_intf->p_sys->i_size++;
578     }
579     vlc_mutex_unlock( &p_intf->p_sys->change_lock );
580
581     return VLC_SUCCESS;
582 }
583
584 static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var,
585                         vlc_value_t oldval, vlc_value_t newval, void *p_data )
586 {
587     vlc_t *p_vlc = (vlc_t *)p_this;
588     struct hotkey *p_hotkeys = p_vlc->p_hotkeys;
589     int i;
590
591     for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
592     {
593         if( !strcmp( p_hotkeys[i].psz_action, psz_var ) )
594         {
595             p_hotkeys[i].i_key = newval.i_int;
596         }
597     }
598
599     return VLC_SUCCESS;
600 }
601
602 static void PlayBookmark( intf_thread_t *p_intf, int i_num )
603 {
604     vlc_value_t val;
605     int i_position;
606     char psz_bookmark_name[11];
607     playlist_t *p_playlist =
608         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
609
610     sprintf( psz_bookmark_name, "bookmark%i", i_num );
611     var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT );
612     var_Get( p_intf, psz_bookmark_name, &val );
613
614     if( p_playlist )
615     {
616         char *psz_bookmark = strdup( val.psz_string );
617         for( i_position = 0; i_position < p_playlist->i_size; i_position++)
618         {
619             if( !strcmp( psz_bookmark,
620                          p_playlist->pp_items[i_position]->input.psz_uri ) )
621             {
622                 playlist_Goto( p_playlist, i_position );
623                 break;
624             }
625         }
626         vlc_object_release( p_playlist );
627     }
628 }
629
630 static void SetBookmark( intf_thread_t *p_intf, int i_num )
631 {
632     vlc_value_t val;
633     playlist_t *p_playlist =
634         vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
635     if( p_playlist )
636     {
637         char psz_bookmark_name[11];
638         sprintf( psz_bookmark_name, "bookmark%i", i_num );
639         var_Create( p_intf, psz_bookmark_name,
640                     VLC_VAR_STRING|VLC_VAR_DOINHERIT );
641         val.psz_string = strdup( p_playlist->pp_items[p_playlist->i_index]->input.psz_uri );
642         var_Set( p_intf, psz_bookmark_name, val );
643         msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
644                   val.psz_string );
645         vlc_object_release( p_playlist );
646     }
647 }
648
649 static int GetPosition( intf_thread_t *p_intf )
650 {
651     input_thread_t *p_input =
652         (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
653                                                FIND_ANYWHERE );
654     if( p_input )
655     {
656         vlc_value_t pos;
657         var_Get( p_input, "position", &pos );
658         vlc_object_release( p_input );
659         return pos.f_float * 100;
660     }
661     return -1;
662 }