Commit e21826c0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

remoteosd: fix key event callback removal

Do not register it if keys are disabled. Do not leave it dangling if
thread creation fails.
parent c1f6fddf
...@@ -267,8 +267,6 @@ static int CreateFilter ( vlc_object_t *p_this ) ...@@ -267,8 +267,6 @@ static int CreateFilter ( vlc_object_t *p_this )
p_sys->b_vnc_mouse_events = var_CreateGetBoolCommand( p_this, p_sys->b_vnc_mouse_events = var_CreateGetBoolCommand( p_this,
RMTOSD_CFG "mouse-events" ); RMTOSD_CFG "mouse-events" );
p_sys->b_vnc_key_events = var_CreateGetBoolCommand( p_this,
RMTOSD_CFG "key-events" );
/* Keep track of OSD Events */ /* Keep track of OSD Events */
p_sys->b_need_update = false; p_sys->b_need_update = false;
...@@ -277,8 +275,6 @@ static int CreateFilter ( vlc_object_t *p_this ) ...@@ -277,8 +275,6 @@ static int CreateFilter ( vlc_object_t *p_this )
p_filter->pf_sub_source = Filter; p_filter->pf_sub_source = Filter;
p_filter->pf_sub_mouse = MouseEvent; p_filter->pf_sub_mouse = MouseEvent;
var_AddCallback( p_filter->p_libvlc, "key-pressed", KeyEvent, p_this );
es_format_Init( &p_filter->fmt_out, SPU_ES, VLC_CODEC_SPU ); es_format_Init( &p_filter->fmt_out, SPU_ES, VLC_CODEC_SPU );
p_filter->fmt_out.i_priority = ES_PRIORITY_SELECTABLE_MIN; p_filter->fmt_out.i_priority = ES_PRIORITY_SELECTABLE_MIN;
...@@ -292,6 +288,11 @@ static int CreateFilter ( vlc_object_t *p_this ) ...@@ -292,6 +288,11 @@ static int CreateFilter ( vlc_object_t *p_this )
goto error; goto error;
} }
p_sys->b_vnc_key_events = var_InheritBool( p_this,
RMTOSD_CFG "key-events" );
if( p_sys->b_vnc_key_events )
var_AddCallback( p_filter->p_libvlc, "key-pressed", KeyEvent, p_this );
msg_Dbg( p_filter, "osdvnc filter started" ); msg_Dbg( p_filter, "osdvnc filter started" );
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -317,15 +318,15 @@ static void DestroyFilter( vlc_object_t *p_this ) ...@@ -317,15 +318,15 @@ static void DestroyFilter( vlc_object_t *p_this )
msg_Dbg( p_filter, "DestroyFilter called." ); msg_Dbg( p_filter, "DestroyFilter called." );
if( p_sys->b_vnc_key_events )
var_DelCallback( p_filter->p_libvlc, "key-pressed", KeyEvent, p_this );
vlc_cancel( p_sys->worker_thread ); vlc_cancel( p_sys->worker_thread );
vlc_join( p_sys->worker_thread, NULL ); vlc_join( p_sys->worker_thread, NULL );
var_DelCallback( p_filter->p_libvlc, "key-pressed", KeyEvent, p_this );
var_Destroy( p_this, RMTOSD_CFG "host" ); var_Destroy( p_this, RMTOSD_CFG "host" );
var_Destroy( p_this, RMTOSD_CFG "password" ); var_Destroy( p_this, RMTOSD_CFG "password" );
var_Destroy( p_this, RMTOSD_CFG "mouse-events" ); var_Destroy( p_this, RMTOSD_CFG "mouse-events" );
var_Destroy( p_this, RMTOSD_CFG "key-events" );
var_Destroy( p_this, RMTOSD_CFG "alpha" ); var_Destroy( p_this, RMTOSD_CFG "alpha" );
vlc_mutex_destroy( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock );
...@@ -1263,9 +1264,6 @@ static int KeyEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -1263,9 +1264,6 @@ static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
filter_t *p_filter = (filter_t *)p_data; filter_t *p_filter = (filter_t *)p_data;
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
if( !p_sys->b_vnc_key_events )
return VLC_SUCCESS;
msg_Dbg( p_this, "key pressed (%"PRId64") ", newval.i_int ); msg_Dbg( p_this, "key pressed (%"PRId64") ", newval.i_int );
if ( !newval.i_int ) if ( !newval.i_int )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment