1 /*****************************************************************************
2 * hotkeys.c: Hotkey handling for vlc
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
7 * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
8 * Jean-Paul Saman <jpsaman #_at_# m2x.nl>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
32 #include <vlc/input.h>
39 #define BUFFER_SIZE 10
41 #define CHANNELS_NUMBER 4
42 #define VOLUME_TEXT_CHAN p_intf->p_sys->p_channels[ 0 ]
43 #define VOLUME_WIDGET_CHAN p_intf->p_sys->p_channels[ 1 ]
44 #define POSITION_TEXT_CHAN p_intf->p_sys->p_channels[ 2 ]
45 #define POSITION_WIDGET_CHAN p_intf->p_sys->p_channels[ 3 ]
46 /*****************************************************************************
47 * intf_sys_t: description and status of FB interface
48 *****************************************************************************/
51 vlc_mutex_t change_lock; /* mutex to keep the callback
52 * and the main loop from
53 * stepping on each others
55 int p_keys[ BUFFER_SIZE ]; /* buffer that contains
57 int i_size; /* number of events in buffer */
58 int p_channels[ CHANNELS_NUMBER ]; /* contains registered
60 input_thread_t * p_input; /* pointer to input */
61 vout_thread_t * p_vout; /* pointer to vout object */
64 /*****************************************************************************
66 *****************************************************************************/
67 static int Open ( vlc_object_t * );
68 static void Close ( vlc_object_t * );
69 static void Run ( intf_thread_t * );
70 static int GetKey ( intf_thread_t *);
71 static int KeyEvent( vlc_object_t *, char const *,
72 vlc_value_t, vlc_value_t, void * );
73 static int ActionKeyCB( vlc_object_t *, char const *,
74 vlc_value_t, vlc_value_t, void * );
75 static void PlayBookmark( intf_thread_t *, int );
76 static void SetBookmark ( intf_thread_t *, int );
77 static void DisplayPosition( intf_thread_t *, vout_thread_t *, input_thread_t * );
78 static void DisplayVolume ( intf_thread_t *, vout_thread_t *, audio_volume_t );
79 static void ClearChannels ( intf_thread_t *, vout_thread_t * );
81 /*****************************************************************************
83 *****************************************************************************/
84 #define BOOKMARK1_TEXT N_("Playlist bookmark 1")
85 #define BOOKMARK2_TEXT N_("Playlist bookmark 2")
86 #define BOOKMARK3_TEXT N_("Playlist bookmark 3")
87 #define BOOKMARK4_TEXT N_("Playlist bookmark 4")
88 #define BOOKMARK5_TEXT N_("Playlist bookmark 5")
89 #define BOOKMARK6_TEXT N_("Playlist bookmark 6")
90 #define BOOKMARK7_TEXT N_("Playlist bookmark 7")
91 #define BOOKMARK8_TEXT N_("Playlist bookmark 8")
92 #define BOOKMARK9_TEXT N_("Playlist bookmark 9")
93 #define BOOKMARK10_TEXT N_("Playlist bookmark 10")
94 #define BOOKMARK_LONGTEXT N_( \
95 "This option allows you to define playlist bookmarks.")
98 set_shortname( _("Hotkeys") );
99 set_description( _("Hotkeys management interface") );
100 set_capability( "interface", 0 );
101 set_callbacks( Open, Close );
104 /*****************************************************************************
105 * Open: initialize interface
106 *****************************************************************************/
107 static int Open( vlc_object_t *p_this )
109 intf_thread_t *p_intf = (intf_thread_t *)p_this;
111 /* Allocate instance and initialize some members */
112 p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
113 if( p_intf->p_sys == NULL )
115 msg_Err( p_intf, "out of memory" );
118 vlc_mutex_init( p_intf, &p_intf->p_sys->change_lock );
119 p_intf->p_sys->i_size = 0;
120 p_intf->pf_run = Run;
122 p_intf->p_sys->p_input = NULL;
123 p_intf->p_sys->p_vout = NULL;
125 var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
129 /*****************************************************************************
130 * Close: destroy interface
131 *****************************************************************************/
132 static void Close( vlc_object_t *p_this )
134 intf_thread_t *p_intf = (intf_thread_t *)p_this;
136 var_DelCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
137 if( p_intf->p_sys->p_input )
139 vlc_object_release( p_intf->p_sys->p_input );
141 if( p_intf->p_sys->p_vout )
143 vlc_object_release( p_intf->p_sys->p_vout );
145 /* Destroy structure */
146 free( p_intf->p_sys );
149 /*****************************************************************************
151 *****************************************************************************/
152 static void Run( intf_thread_t *p_intf )
154 playlist_t *p_playlist = NULL;
155 input_thread_t *p_input = NULL;
156 vout_thread_t *p_vout = NULL;
157 vout_thread_t *p_last_vout = NULL;
158 struct hotkey *p_hotkeys = p_intf->p_vlc->p_hotkeys;
162 /* Initialize hotkey structure */
163 for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
165 var_Create( p_intf->p_vlc, p_hotkeys[i].psz_action,
166 VLC_VAR_HOTKEY | VLC_VAR_DOINHERIT );
168 var_AddCallback( p_intf->p_vlc, p_hotkeys[i].psz_action,
170 var_Get( p_intf->p_vlc, p_hotkeys[i].psz_action, &val );
171 var_Set( p_intf->p_vlc, p_hotkeys[i].psz_action, val );
174 while( !p_intf->b_die )
180 msleep( INTF_IDLE_SLEEP );
182 /* Update the input */
183 if( p_intf->p_sys->p_input == NULL )
185 p_playlist = (playlist_t *)vlc_object_find( p_intf,
186 VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
189 p_intf->p_sys->p_input = p_playlist->p_input;
190 if( p_intf->p_sys->p_input )
191 vlc_object_yield( p_intf->p_sys->p_input );
192 vlc_object_release( p_playlist );
195 else if( p_intf->p_sys->p_input->b_dead )
197 vlc_object_release( p_intf->p_sys->p_input );
198 p_intf->p_sys->p_input = NULL;
200 p_input = p_intf->p_sys->p_input;
202 /* Update the vout */
203 p_last_vout = p_intf->p_sys->p_vout;
206 p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
207 p_intf->p_sys->p_vout = p_vout;
209 else if( p_vout->b_die )
211 vlc_object_release( p_vout );
213 p_intf->p_sys->p_vout = NULL;
216 /* Register OSD channels */
217 if( p_vout && p_vout != p_last_vout )
219 for( i = 0; i < CHANNELS_NUMBER; i++ )
221 spu_Control( p_vout->p_spu, SPU_CHANNEL_REGISTER,
222 &p_intf->p_sys->p_channels[ i ] );
226 /* Find action triggered by hotkey */
228 i_key = GetKey( p_intf );
229 for( i = 0; i_key != -1 && p_hotkeys[i].psz_action != NULL; i++ )
231 if( p_hotkeys[i].i_key == i_key )
233 i_action = p_hotkeys[i].i_action;
234 i_times = p_hotkeys[i].i_times; /* times key pressed within max. delta time */
235 p_hotkeys[i].i_times = 0;
241 /* No key pressed, sleep a bit more */
242 msleep( INTF_IDLE_SLEEP );
246 if( i_action == ACTIONID_QUIT )
248 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
252 playlist_Stop( p_playlist );
253 vlc_object_release( p_playlist );
255 /* Playlist is stopped now kill vlc. */
256 p_intf->p_vlc->b_die = VLC_TRUE;
257 ClearChannels( p_intf, p_vout );
258 vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );
261 else if( i_action == ACTIONID_VOL_UP )
263 audio_volume_t i_newvol;
264 aout_VolumeUp( p_intf, 1, &i_newvol );
265 DisplayVolume( p_intf, p_vout, i_newvol );
267 else if( i_action == ACTIONID_VOL_DOWN )
269 audio_volume_t i_newvol;
270 aout_VolumeDown( p_intf, 1, &i_newvol );
271 DisplayVolume( p_intf, p_vout, i_newvol );
273 else if( i_action == ACTIONID_VOL_MUTE )
275 audio_volume_t i_newvol = -1;
276 aout_VolumeMute( p_intf, &i_newvol );
281 ClearChannels( p_intf, p_vout );
282 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
287 DisplayVolume( p_intf, p_vout, i_newvol );
291 else if( i_action == ACTIONID_INTF_SHOW )
293 val.b_bool = VLC_TRUE;
294 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
298 var_Set( p_playlist, "intf-show", val );
299 vlc_object_release( p_playlist );
302 else if( i_action == ACTIONID_INTF_HIDE )
304 val.b_bool = VLC_FALSE;
305 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
309 var_Set( p_playlist, "intf-show", val );
310 vlc_object_release( p_playlist );
313 else if( i_action == ACTIONID_SNAPSHOT )
315 if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
317 else if( i_action == ACTIONID_FULLSCREEN )
321 var_Get( p_vout, "fullscreen", &val ); val.b_bool = !val.b_bool;
322 var_Set( p_vout, "fullscreen", val );
326 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
330 var_Get( p_playlist, "fullscreen", &val ); val.b_bool = !val.b_bool;
331 var_Set( p_playlist, "fullscreen", val );
332 vlc_object_release( p_playlist );
336 else if( i_action == ACTIONID_PLAY_PAUSE )
338 val.i_int = PLAYING_S;
341 var_Get( p_input, "state", &val );
343 if( p_input && val.i_int != PAUSE_S )
345 ClearChannels( p_intf, p_vout );
346 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
349 var_Set( p_input, "state", val );
353 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
357 ClearChannels( p_intf, p_vout );
358 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
360 playlist_Play( p_playlist );
361 vlc_object_release( p_playlist );
368 * How to get a valid value ?
369 * That's not that easy with some special stream
371 vlc_bool_t b_seekable = VLC_TRUE;
374 if( i_action == ACTIONID_PAUSE )
376 ClearChannels( p_intf, p_vout );
377 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
380 var_Set( p_input, "state", val );
382 else if( i_action == ACTIONID_JUMP_BACKWARD_EXTRASHORT && b_seekable )
384 #define SET_TIME( a, b ) \
385 i_interval = config_GetInt( p_input, a "-jump-size" ); \
386 if( i_interval > 0 ) { \
387 val.i_time = ( (mtime_t)(i_interval * b) * 1000000L \
388 * ((mtime_t)(1 << i_times))); \
389 var_Set( p_input, "time-offset", val ); \
390 DisplayPosition( p_intf, p_vout, p_input ); \
392 SET_TIME( "extrashort", -1 );
394 else if( i_action == ACTIONID_JUMP_FORWARD_EXTRASHORT && b_seekable )
396 SET_TIME( "extrashort", 1 );
398 else if( i_action == ACTIONID_JUMP_BACKWARD_SHORT && b_seekable )
400 SET_TIME( "short", -1 );
402 else if( i_action == ACTIONID_JUMP_FORWARD_SHORT && b_seekable )
404 SET_TIME( "short", 1 );
406 else if( i_action == ACTIONID_JUMP_BACKWARD_MEDIUM && b_seekable )
408 SET_TIME( "medium", -1 );
410 else if( i_action == ACTIONID_JUMP_FORWARD_MEDIUM && b_seekable )
412 SET_TIME( "medium", 1 );
414 else if( i_action == ACTIONID_JUMP_BACKWARD_LONG && b_seekable )
416 SET_TIME( "long", -1 );
418 else if( i_action == ACTIONID_JUMP_FORWARD_LONG && b_seekable )
420 SET_TIME( "long", 1 );
423 else if( i_action == ACTIONID_AUDIO_TRACK )
425 vlc_value_t val, list, list2;
427 var_Get( p_input, "audio-es", &val );
428 var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
430 i_count = list.p_list->i_count;
435 for( i = 0; i < i_count; i++ )
437 if( val.i_int == list.p_list->p_values[i].i_int )
442 /* value of audio-es was not in choices list */
446 "invalid current audio track, selecting 0" );
447 var_Set( p_input, "audio-es",
448 list.p_list->p_values[0] );
451 else if( i == i_count - 1 )
453 var_Set( p_input, "audio-es",
454 list.p_list->p_values[1] );
459 var_Set( p_input, "audio-es",
460 list.p_list->p_values[i+1] );
463 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
464 _("Audio track: %s"),
465 list2.p_list->p_values[i].psz_string );
467 else if( i_action == ACTIONID_SUBTITLE_TRACK )
469 vlc_value_t val, list, list2;
471 var_Get( p_input, "spu-es", &val );
473 var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
475 i_count = list.p_list->i_count;
478 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Subtitle track: %s"), _("N/A") );
481 for( i = 0; i < i_count; i++ )
483 if( val.i_int == list.p_list->p_values[i].i_int )
488 /* value of spu-es was not in choices list */
491 msg_Warn( p_input, "invalid current subtitle track, selecting 0" );
492 var_Set( p_input, "spu-es", list.p_list->p_values[0] );
495 else if( i == i_count - 1 )
497 var_Set( p_input, "spu-es", list.p_list->p_values[0] );
502 var_Set( p_input, "spu-es", list.p_list->p_values[i+1] );
505 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
506 _("Subtitle track: %s"),
507 list2.p_list->p_values[i].psz_string );
509 else if( i_action == ACTIONID_ASPECT_RATIO )
511 vlc_value_t val={0}, val_list, text_list;
512 var_Get( p_vout, "aspect-ratio", &val );
513 if( var_Change( p_vout, "aspect-ratio", VLC_VAR_GETLIST,
514 &val_list, &text_list ) >= 0 )
517 for( i = 0; i < val_list.p_list->i_count; i++ )
519 if( !strcmp( val_list.p_list->p_values[i].psz_string,
526 if( i == val_list.p_list->i_count ) i = 0;
527 var_SetString( p_vout, "aspect-ratio",
528 val_list.p_list->p_values[i].psz_string );
529 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
530 _("Aspect ratio: %s"),
531 text_list.p_list->p_values[i].psz_string );
533 free( val.psz_string );
535 else if( i_action == ACTIONID_CROP )
537 vlc_value_t val={0}, val_list, text_list;
538 var_Get( p_vout, "crop", &val );
539 if( var_Change( p_vout, "crop", VLC_VAR_GETLIST,
540 &val_list, &text_list ) >= 0 )
543 for( i = 0; i < val_list.p_list->i_count; i++ )
545 if( !strcmp( val_list.p_list->p_values[i].psz_string,
552 if( i == val_list.p_list->i_count ) i = 0;
553 var_SetString( p_vout, "crop",
554 val_list.p_list->p_values[i].psz_string );
555 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
557 text_list.p_list->p_values[i].psz_string );
559 free( val.psz_string );
561 else if( i_action == ACTIONID_DEINTERLACE )
563 vlc_value_t val={0}, val_list, text_list;
564 var_Get( p_vout, "deinterlace", &val );
565 if( var_Change( p_vout, "deinterlace", VLC_VAR_GETLIST,
566 &val_list, &text_list ) >= 0 )
569 for( i = 0; i < val_list.p_list->i_count; i++ )
571 if( !strcmp( val_list.p_list->p_values[i].psz_string,
578 if( i == val_list.p_list->i_count ) i = 0;
579 var_SetString( p_vout, "deinterlace",
580 val_list.p_list->p_values[i].psz_string );
581 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
582 _("Deinterlace mode: %s"),
583 text_list.p_list->p_values[i].psz_string );
585 free( val.psz_string );
587 else if( i_action == ACTIONID_NEXT )
589 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
593 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Next") );
594 playlist_Next( p_playlist );
595 vlc_object_release( p_playlist );
598 else if( i_action == ACTIONID_PREV )
600 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
604 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Previous") );
605 playlist_Prev( p_playlist );
606 vlc_object_release( p_playlist );
609 else if( i_action == ACTIONID_STOP )
611 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
615 playlist_Stop( p_playlist );
616 vlc_object_release( p_playlist );
619 else if( i_action == ACTIONID_FASTER )
622 val.b_bool = VLC_TRUE;
623 var_Set( p_input, "rate-faster", val );
624 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Faster") );
626 else if( i_action == ACTIONID_SLOWER )
629 val.b_bool = VLC_TRUE;
630 var_Set( p_input, "rate-slower", val );
631 vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN, _("Slower") );
633 else if( i_action == ACTIONID_POSITION && b_seekable )
635 DisplayPosition( p_intf, p_vout, p_input );
637 else if( i_action >= ACTIONID_PLAY_BOOKMARK1 &&
638 i_action <= ACTIONID_PLAY_BOOKMARK10 )
640 PlayBookmark( p_intf, i_action - ACTIONID_PLAY_BOOKMARK1 + 1 );
642 else if( i_action >= ACTIONID_SET_BOOKMARK1 &&
643 i_action <= ACTIONID_SET_BOOKMARK10 )
645 SetBookmark( p_intf, i_action - ACTIONID_SET_BOOKMARK1 + 1 );
647 /* Only makes sense with DVD */
648 else if( i_action == ACTIONID_TITLE_PREV )
650 val.b_bool = VLC_TRUE;
651 var_Set( p_input, "prev-title", val );
653 else if( i_action == ACTIONID_TITLE_NEXT )
655 val.b_bool = VLC_TRUE;
656 var_Set( p_input, "next-title", val );
658 else if( i_action == ACTIONID_CHAPTER_PREV )
660 val.b_bool = VLC_TRUE;
661 var_Set( p_input, "prev-chapter", val );
663 else if( i_action == ACTIONID_CHAPTER_NEXT )
665 val.b_bool = VLC_TRUE;
666 var_Set( p_input, "next-chapter", val );
668 else if( i_action == ACTIONID_DISC_MENU )
670 vlc_value_t val; val.i_int = 2;
671 msg_Dbg( p_input, "set dvdmenu" );
672 var_Set( p_input, "title 0", val);
674 else if( i_action == ACTIONID_SUBDELAY_DOWN )
676 int64_t i_delay = var_GetTime( p_input, "spu-delay" );
678 i_delay -= 50000; /* 50 ms */
680 var_SetTime( p_input, "spu-delay", i_delay );
681 ClearChannels( p_intf, p_vout );
682 vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
683 (int)(i_delay/1000) );
685 else if( i_action == ACTIONID_SUBDELAY_UP )
687 int64_t i_delay = var_GetTime( p_input, "spu-delay" );
689 i_delay += 50000; /* 50 ms */
691 var_SetTime( p_input, "spu-delay", i_delay );
692 ClearChannels( p_intf, p_vout );
693 vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
694 (int)(i_delay/1000) );
696 else if( i_action == ACTIONID_AUDIODELAY_DOWN )
698 int64_t i_delay = var_GetTime( p_input, "audio-delay" );
700 i_delay -= 50000; /* 50 ms */
702 var_SetTime( p_input, "audio-delay", i_delay );
703 ClearChannels( p_intf, p_vout );
704 vout_OSDMessage( p_intf, DEFAULT_CHAN, "Audio delay %i ms",
705 (int)(i_delay/1000) );
707 else if( i_action == ACTIONID_AUDIODELAY_UP )
709 int64_t i_delay = var_GetTime( p_input, "audio-delay" );
711 i_delay += 50000; /* 50 ms */
713 var_SetTime( p_input, "audio-delay", i_delay );
714 ClearChannels( p_intf, p_vout );
715 vout_OSDMessage( p_intf, DEFAULT_CHAN, "Audio delay %i ms",
716 (int)(i_delay/1000) );
718 else if( i_action == ACTIONID_PLAY )
720 p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
724 var_Get( p_input, "rate", &val );
725 msg_Dbg( p_input, "rate %d", val.i_int );
726 if( val.i_int != INPUT_RATE_DEFAULT )
728 /* Return to normal speed */
729 val.i_int = INPUT_RATE_DEFAULT;
730 var_Set( p_input, "rate", val );
734 ClearChannels( p_intf, p_vout );
735 vout_OSDIcon( VLC_OBJECT( p_intf ), DEFAULT_CHAN,
737 playlist_Play( p_playlist );
739 vlc_object_release( p_playlist );
746 static int GetKey( intf_thread_t *p_intf)
748 vlc_mutex_lock( &p_intf->p_sys->change_lock );
749 if ( p_intf->p_sys->i_size == 0 )
751 vlc_mutex_unlock( &p_intf->p_sys->change_lock );
756 int i_return = p_intf->p_sys->p_keys[ 0 ];
758 p_intf->p_sys->i_size--;
759 for ( i = 0; i < BUFFER_SIZE - 1; i++)
761 p_intf->p_sys->p_keys[ i ] = p_intf->p_sys->p_keys[ i + 1 ];
763 vlc_mutex_unlock( &p_intf->p_sys->change_lock );
768 /*****************************************************************************
769 * KeyEvent: callback for keyboard events
770 *****************************************************************************/
771 static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
772 vlc_value_t oldval, vlc_value_t newval, void *p_data )
774 intf_thread_t *p_intf = (intf_thread_t *)p_data;
775 vlc_mutex_lock( &p_intf->p_sys->change_lock );
776 if ( p_intf->p_sys->i_size == BUFFER_SIZE )
778 msg_Warn( p_intf, "event buffer full, dropping keypress" );
779 vlc_mutex_unlock( &p_intf->p_sys->change_lock );
784 p_intf->p_sys->p_keys[ p_intf->p_sys->i_size ] = newval.i_int;
785 p_intf->p_sys->i_size++;
787 vlc_mutex_unlock( &p_intf->p_sys->change_lock );
792 static int ActionKeyCB( vlc_object_t *p_this, char const *psz_var,
793 vlc_value_t oldval, vlc_value_t newval, void *p_data )
795 vlc_t *p_vlc = (vlc_t *)p_this;
796 struct hotkey *p_hotkeys = p_vlc->p_hotkeys;
800 for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
802 if( !strcmp( p_hotkeys[i].psz_action, psz_var ) )
804 p_hotkeys[i].i_key = newval.i_int;
805 /* do hotkey accounting */
807 if( (p_hotkeys[i].i_delta_date > 0) &&
808 (p_hotkeys[i].i_delta_date <= (i_date - p_hotkeys[i].i_last_date) ) )
809 p_hotkeys[i].i_times = 0;
811 p_hotkeys[i].i_times++;
812 p_hotkeys[i].i_last_date = i_date;
819 static void PlayBookmark( intf_thread_t *p_intf, int i_num )
823 char psz_bookmark_name[11];
824 playlist_t *p_playlist =
825 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
827 sprintf( psz_bookmark_name, "bookmark%i", i_num );
828 var_Create( p_intf, psz_bookmark_name, VLC_VAR_STRING|VLC_VAR_DOINHERIT );
829 var_Get( p_intf, psz_bookmark_name, &val );
833 char *psz_bookmark = strdup( val.psz_string );
834 for( i_position = 0; i_position < p_playlist->i_size; i_position++)
836 if( !strcmp( psz_bookmark,
837 p_playlist->pp_items[i_position]->input.psz_uri ) )
839 playlist_Goto( p_playlist, i_position );
843 vlc_object_release( p_playlist );
847 static void SetBookmark( intf_thread_t *p_intf, int i_num )
849 playlist_t *p_playlist =
850 vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
853 char psz_bookmark_name[11];
854 sprintf( psz_bookmark_name, "bookmark%i", i_num );
855 var_Create( p_intf, psz_bookmark_name,
856 VLC_VAR_STRING|VLC_VAR_DOINHERIT );
857 if( p_playlist->status.p_item )
859 config_PutPsz( p_intf, psz_bookmark_name,
860 p_playlist->status.p_item->input.psz_uri);
861 msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
862 p_playlist->status.p_item->input.psz_uri);
863 config_SaveConfigFile( p_intf, "hotkeys" );
865 vlc_object_release( p_playlist );
869 static void DisplayPosition( intf_thread_t *p_intf, vout_thread_t *p_vout,
870 input_thread_t *p_input )
872 char psz_duration[MSTRTIME_MAX_SIZE];
873 char psz_time[MSTRTIME_MAX_SIZE];
874 vlc_value_t time, pos;
881 ClearChannels( p_intf, p_vout );
883 var_Get( p_input, "time", &time );
884 i_seconds = time.i_time / 1000000;
885 secstotimestr ( psz_time, i_seconds );
887 var_Get( p_input, "length", &time );
888 if( time.i_time > 0 )
890 secstotimestr( psz_duration, time.i_time / 1000000 );
891 vout_OSDMessage( p_input, POSITION_TEXT_CHAN, "%s / %s",
892 psz_time, psz_duration );
894 else if( i_seconds > 0 )
896 vout_OSDMessage( p_input, POSITION_TEXT_CHAN, psz_time );
899 if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
901 var_Get( p_input, "position", &pos );
902 vout_OSDSlider( VLC_OBJECT( p_input ), POSITION_WIDGET_CHAN,
903 pos.f_float * 100, OSD_HOR_SLIDER );
907 static void DisplayVolume( intf_thread_t *p_intf, vout_thread_t *p_vout,
908 audio_volume_t i_vol )
914 ClearChannels( p_intf, p_vout );
916 if( !p_vout->p_parent_intf || p_vout->b_fullscreen )
918 vout_OSDSlider( VLC_OBJECT( p_vout ), VOLUME_WIDGET_CHAN,
919 i_vol*100/AOUT_VOLUME_MAX, OSD_VERT_SLIDER );
923 vout_OSDMessage( p_vout, VOLUME_TEXT_CHAN, "Volume %d%%",
924 i_vol*400/AOUT_VOLUME_MAX );
928 static void ClearChannels( intf_thread_t *p_intf, vout_thread_t *p_vout )
934 spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
935 for( i = 0; i < CHANNELS_NUMBER; i++ )
937 spu_Control( p_vout->p_spu, SPU_CHANNEL_CLEAR,
938 p_intf->p_sys->p_channels[ i ] );