[vlc-commits] remoteosd: fix key event callback removal
Rémi Denis-Courmont
git at videolan.org
Thu Jul 9 20:34:18 CEST 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul 9 20:50:30 2015 +0300| [e21826c0cf709dd652dd544379845d45345c9945] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e21826c0cf709dd652dd544379845d45345c9945
---
modules/video_filter/remoteosd.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/modules/video_filter/remoteosd.c b/modules/video_filter/remoteosd.c
index c95c299..a644187 100644
--- a/modules/video_filter/remoteosd.c
+++ b/modules/video_filter/remoteosd.c
@@ -267,8 +267,6 @@ static int CreateFilter ( vlc_object_t *p_this )
p_sys->b_vnc_mouse_events = var_CreateGetBoolCommand( p_this,
RMTOSD_CFG "mouse-events" );
- p_sys->b_vnc_key_events = var_CreateGetBoolCommand( p_this,
- RMTOSD_CFG "key-events" );
/* Keep track of OSD Events */
p_sys->b_need_update = false;
@@ -277,8 +275,6 @@ static int CreateFilter ( vlc_object_t *p_this )
p_filter->pf_sub_source = Filter;
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 );
p_filter->fmt_out.i_priority = ES_PRIORITY_SELECTABLE_MIN;
@@ -292,6 +288,11 @@ static int CreateFilter ( vlc_object_t *p_this )
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" );
return VLC_SUCCESS;
@@ -317,15 +318,15 @@ static void DestroyFilter( vlc_object_t *p_this )
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_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 "password" );
var_Destroy( p_this, RMTOSD_CFG "mouse-events" );
- var_Destroy( p_this, RMTOSD_CFG "key-events" );
var_Destroy( p_this, RMTOSD_CFG "alpha" );
vlc_mutex_destroy( &p_sys->lock );
@@ -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_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 );
if ( !newval.i_int )
More information about the vlc-commits
mailing list