/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
-#include <vlc/intf.h>
-#include <vlc/input.h>
-#include <vlc/vout.h>
-#include <vlc/aout.h>
+#include <vlc_interface.h>
+#include <vlc_input.h>
+#include <vlc_vout.h>
+#include <vlc_aout.h>
#include <vlc_osd.h>
-
+#include <vlc_playlist.h>
#include "vlc_keys.h"
#define BUFFER_SIZE 10
p_intf->p_sys->i_size = 0;
p_intf->pf_run = Run;
- p_intf->p_sys->p_input = NULL;
- p_intf->p_sys->p_vout = NULL;
-
var_AddCallback( p_intf->p_libvlc, "key-pressed", KeyEvent, p_intf );
return VLC_SUCCESS;
}
intf_thread_t *p_intf = (intf_thread_t *)p_this;
var_DelCallback( p_intf->p_libvlc, "key-pressed", KeyEvent, p_intf );
- if( p_intf->p_sys->p_input )
- {
- vlc_object_release( p_intf->p_sys->p_input );
- }
- if( p_intf->p_sys->p_vout )
- {
- vlc_object_release( p_intf->p_sys->p_vout );
- }
+
+ vlc_mutex_destroy( &p_intf->p_sys->change_lock );
/* Destroy structure */
free( p_intf->p_sys );
}
var_Set( p_intf->p_libvlc, p_hotkeys[i].psz_action, val );
}
- while( !intf_ShouldDie( p_intf ) )
+ for( vlc_bool_t b_quit = VLC_FALSE ; !b_quit; )
{
int i_key, i_action;
int i_times = 0;
/* Sleep a bit */
-// msleep( INTF_IDLE_SLEEP );
+ /* msleep( INTF_IDLE_SLEEP ); */
- /* Update the input */
- if( p_intf->p_sys->p_input == NULL )
- {
- PL_LOCK;
- p_intf->p_sys->p_input = p_playlist->p_input;
- if( p_intf->p_sys->p_input )
- vlc_object_yield( p_intf->p_sys->p_input );
- PL_UNLOCK;
- }
- else if( p_intf->p_sys->p_input->b_dead )
+ i_action = 0;
+ i_key = GetKey( p_intf );
+
+ /* Special action for mouse event */
+ /* FIXME: This should probably be configurable */
+ /* FIXME: rework hotkeys handling to allow more than 1 event
+ * to trigger one same action */
+ switch (i_key & KEY_SPECIAL)
{
- vlc_object_release( p_intf->p_sys->p_input );
- p_intf->p_sys->p_input = NULL;
+ case KEY_MOUSEWHEELUP:
+ i_action = ACTIONID_VOL_UP;
+ break;
+ case KEY_MOUSEWHEELDOWN:
+ i_action = ACTIONID_VOL_DOWN;
+ break;
+ case KEY_MOUSEWHEELLEFT:
+ i_action = ACTIONID_JUMP_BACKWARD_EXTRASHORT;
+ break;
+ case KEY_MOUSEWHEELRIGHT:
+ i_action = ACTIONID_JUMP_FORWARD_EXTRASHORT;
+ break;
+ default: break;
}
- p_input = p_intf->p_sys->p_input;
- /* Update the vout */
- p_last_vout = p_intf->p_sys->p_vout;
- if( p_vout == NULL )
+ /* No mouse action, find action triggered by hotkey */
+ if(!i_action)
{
- p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
- p_intf->p_sys->p_vout = p_vout;
+ for( i = 0; i_key != -1 && p_hotkeys[i].psz_action != NULL; i++ )
+ {
+ if( p_hotkeys[i].i_key == i_key )
+ {
+ i_action = p_hotkeys[i].i_action;
+ i_times = p_hotkeys[i].i_times;
+ /* times key pressed within max. delta time */
+ p_hotkeys[i].i_times = 0;
+ break;
+ }
+ }
}
- else if( p_vout->b_die )
+
+ if( !i_action )
{
- vlc_object_release( p_vout );
- p_vout = NULL;
- p_intf->p_sys->p_vout = NULL;
+ b_quit = vlc_object_lock_and_wait( p_intf );
+ /* No key pressed, sleep a bit more */
+ continue;
}
+ /* Update the input */
+ PL_LOCK;
+ p_input = p_playlist->p_input;
+ if( p_input )
+ vlc_object_yield( p_input );
+ PL_UNLOCK;
+
+ /* Update the vout */
+ p_last_vout = p_vout;
+ p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+
/* Register OSD channels */
if( p_vout && p_vout != p_last_vout )
{
}
}
- /* Find action triggered by hotkey */
- i_action = 0;
- i_key = GetKey( p_intf );
- for( i = 0; i_key != -1 && p_hotkeys[i].psz_action != NULL; i++ )
- {
- if( p_hotkeys[i].i_key == i_key )
- {
- i_action = p_hotkeys[i].i_action;
- i_times = p_hotkeys[i].i_times;
- /* times key pressed within max. delta time */
- p_hotkeys[i].i_times = 0;
- }
- }
-
- if( !i_action )
- {
- vlc_mutex_lock( &p_intf->object_lock );
- vlc_cond_wait( &p_intf->object_wait, &p_intf->object_lock );
- vlc_mutex_unlock( &p_intf->object_lock );
- /* No key pressed, sleep a bit more */
-// msleep( INTF_IDLE_SLEEP );
- continue;
- }
-
if( i_action == ACTIONID_QUIT )
{
- p_intf->p_libvlc->b_die = VLC_TRUE;
+ if( p_playlist )
+ playlist_Stop( p_playlist );
+ vlc_object_kill( p_intf->p_libvlc );
+ vlc_object_kill( p_intf );
ClearChannels( p_intf, p_vout );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Quit" ) );
+ if( p_vout )
+ vlc_object_release( p_vout );
+ if( p_input )
+ vlc_object_release( p_input );
continue;
}
else if( i_action == ACTIONID_VOL_UP )
{
if( p_vout ) vout_Control( p_vout, VOUT_SNAPSHOT );
}
- else if( i_action == ACTIONID_FULLSCREEN )
+ else if( i_action == ACTIONID_TOGGLE_FULLSCREEN )
{
if( p_vout )
{
var_Set( p_playlist, "fullscreen", val );
}
}
+ else if( i_action == ACTIONID_LEAVE_FULLSCREEN )
+ {
+ if( p_vout && var_GetBool( p_vout, "fullscreen" ) )
+ {
+ var_SetBool( p_vout, "fullscreen", VLC_FALSE );
+ }
+ }
+ else if( i_action == ACTIONID_WALLPAPER )
+ {
+ if( p_vout )
+ {
+ var_Get( p_vout, "directx-wallpaper", &val );
+ val.b_bool = !val.b_bool;
+ var_Set( p_vout, "directx-wallpaper", val );
+ }
+ else
+ {
+ var_Get( p_playlist, "directx-wallpaper", &val );
+ val.b_bool = !val.b_bool;
+ var_Set( p_playlist, "directx-wallpaper", val );
+ }
+ }
+ else if( i_action == ACTIONID_LOOP )
+ {
+ /* Toggle Normal -> Loop -> Repeat -> Normal ... */
+ vlc_value_t val2;
+ var_Get( p_playlist, "loop", &val );
+ var_Get( p_playlist, "repeat", &val2 );
+ if( val2.b_bool == VLC_TRUE )
+ {
+ val.b_bool = VLC_FALSE;
+ val2.b_bool = VLC_FALSE;
+ }
+ else if( val.b_bool == VLC_TRUE )
+ {
+ val.b_bool = VLC_FALSE;
+ val2.b_bool = VLC_TRUE;
+ }
+ else
+ {
+ val.b_bool = VLC_TRUE;
+ }
+ var_Set( p_playlist, "loop", val );
+ var_Set( p_playlist, "repeat", val2 );
+ }
+ else if( i_action == ACTIONID_RANDOM )
+ {
+ var_Get( p_playlist, "random", &val );
+ val.b_bool = !val.b_bool;
+ var_Set( p_playlist, "random", val );
+ }
else if( i_action == ACTIONID_PLAY_PAUSE )
{
val.i_int = PLAYING_S;
i_delay -= 50000; /* 50 ms */
var_SetTime( p_input, "spu-delay", i_delay );
ClearChannels( p_intf, p_vout );
- vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
+ vout_OSDMessage( p_intf, DEFAULT_CHAN,
+ _( "Subtitle delay %i ms" ),
(int)(i_delay/1000) );
}
else if( i_action == ACTIONID_SUBDELAY_UP )
i_delay += 50000; /* 50 ms */
var_SetTime( p_input, "spu-delay", i_delay );
ClearChannels( p_intf, p_vout );
- vout_OSDMessage( p_intf, DEFAULT_CHAN, "Subtitle delay %i ms",
+ vout_OSDMessage( p_intf, DEFAULT_CHAN,
+ _( "Subtitle delay %i ms" ),
(int)(i_delay/1000) );
}
else if( i_action == ACTIONID_AUDIODELAY_DOWN )
i_delay -= 50000; /* 50 ms */
var_SetTime( p_input, "audio-delay", i_delay );
ClearChannels( p_intf, p_vout );
- vout_OSDMessage( p_intf, DEFAULT_CHAN, "Audio delay %i ms",
+ vout_OSDMessage( p_intf, DEFAULT_CHAN,
+ _( "Audio delay %i ms" ),
(int)(i_delay/1000) );
}
else if( i_action == ACTIONID_AUDIODELAY_UP )
i_delay += 50000; /* 50 ms */
var_SetTime( p_input, "audio-delay", i_delay );
ClearChannels( p_intf, p_vout );
- vout_OSDMessage( p_intf, DEFAULT_CHAN, "Audio delay %i ms",
+ vout_OSDMessage( p_intf, DEFAULT_CHAN,
+ _( "Audio delay %i ms" ),
(int)(i_delay/1000) );
}
else if( i_action == ACTIONID_PLAY )
playlist_Play( p_playlist );
}
}
+ else if( i_action == ACTIONID_MENU_ON )
+ {
+ osd_MenuShow( VLC_OBJECT(p_intf) );
+ }
+ else if( i_action == ACTIONID_MENU_OFF )
+ {
+ osd_MenuHide( VLC_OBJECT(p_intf) );
+ }
+ else if( i_action == ACTIONID_MENU_LEFT )
+ {
+ osd_MenuPrev( VLC_OBJECT(p_intf) );
+ }
+ else if( i_action == ACTIONID_MENU_RIGHT )
+ {
+ osd_MenuNext( VLC_OBJECT(p_intf) );
+ }
+ else if( i_action == ACTIONID_MENU_UP )
+ {
+ osd_MenuUp( VLC_OBJECT(p_intf) );
+ }
+ else if( i_action == ACTIONID_MENU_DOWN )
+ {
+ osd_MenuDown( VLC_OBJECT(p_intf) );
+ }
+ else if( i_action == ACTIONID_MENU_SELECT )
+ {
+ osd_MenuActivate( VLC_OBJECT(p_intf) );
+ }
}
+ if( p_vout )
+ vlc_object_release( p_vout );
+ if( p_input )
+ vlc_object_release( p_input );
}
pl_Release( p_intf );
}
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t *)p_data;
+ if ( !newval.i_int )
+ {
+ msg_Warn( p_this, "Received invalid key event %d", newval.i_int );
+ return VLC_EGENERIC;
+ }
vlc_mutex_lock( &p_intf->p_sys->change_lock );
if ( p_intf->p_sys->i_size == BUFFER_SIZE )
{
static void PlayBookmark( intf_thread_t *p_intf, int i_num )
{
vlc_value_t val;
- int i;
char psz_bookmark_name[11];
playlist_t *p_playlist = pl_Yield( p_intf );
char *psz_bookmark = strdup( val.psz_string );
PL_LOCK;
FOREACH_ARRAY( playlist_item_t *p_item, p_playlist->items )
- if( !strcmp( psz_bookmark, p_item->p_input->psz_uri ) )
+ char *psz_uri = input_item_GetURI( p_item->p_input );
+ if( !strcmp( psz_bookmark, psz_uri ) )
{
+ free( psz_uri );
playlist_Control( p_playlist, PLAYLIST_VIEWPLAY, VLC_TRUE,
NULL, p_item );
break;
}
+ else
+ free( psz_uri );
FOREACH_END();
PL_UNLOCK;
vlc_object_release( p_playlist );
VLC_VAR_STRING|VLC_VAR_DOINHERIT );
if( p_playlist->status.p_item )
{
- config_PutPsz( p_intf, psz_bookmark_name,
- p_playlist->status.p_item->p_input->psz_uri);
- msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num,
- p_playlist->status.p_item->p_input->psz_uri);
+ char *psz_uri = input_item_GetURI( p_playlist->status.p_item->p_input );
+ config_PutPsz( p_intf, psz_bookmark_name, psz_uri);
+ msg_Info( p_intf, "setting playlist bookmark %i to %s", i_num, psz_uri);
+ free( psz_uri );
config_SaveConfigFile( p_intf, "hotkeys" );
}
pl_Release( p_intf );
if( time.i_time > 0 )
{
secstotimestr( psz_duration, time.i_time / 1000000 );
- vout_OSDMessage( p_input, POSITION_TEXT_CHAN, "%s / %s",
+ vout_OSDMessage( p_input, POSITION_TEXT_CHAN, (char *) "%s / %s",
psz_time, psz_duration );
}
else if( i_seconds > 0 )
}
else
{
- vout_OSDMessage( p_vout, VOLUME_TEXT_CHAN, "Volume %d%%",
+ vout_OSDMessage( p_vout, VOLUME_TEXT_CHAN, _( "Volume %d%%" ),
i_vol*400/AOUT_VOLUME_MAX );
}
}