[vlc-devel] [PATCH] input: register title change callbacks only once

Petri Hintukainen phintuka at gmail.com
Tue Nov 10 12:43:01 CET 2015


Fixes skipping multiple titles with single click.
---
 src/input/var.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/input/var.c b/src/input/var.c
index f5ce212..0ad530c 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -256,15 +256,19 @@ void input_ControlVarNavigation( input_thread_t *p_input )
     /* Create more command variables */
     if( p_input->p->i_title > 1 )
     {
-        var_Create( p_input, "next-title", VLC_VAR_VOID );
-        text.psz_string = _("Next title");
-        var_Change( p_input, "next-title", VLC_VAR_SETTEXT, &text, NULL );
-        var_AddCallback( p_input, "next-title", TitleCallback, NULL );
-
-        var_Create( p_input, "prev-title", VLC_VAR_VOID );
-        text.psz_string = _("Previous title");
-        var_Change( p_input, "prev-title", VLC_VAR_SETTEXT, &text, NULL );
-        var_AddCallback( p_input, "prev-title", TitleCallback, NULL );
+        if( var_Type( p_input, "next-title" ) == 0 ) {
+            var_Create( p_input, "next-title", VLC_VAR_VOID );
+            text.psz_string = _("Next title");
+            var_Change( p_input, "next-title", VLC_VAR_SETTEXT, &text, NULL );
+            var_AddCallback( p_input, "next-title", TitleCallback, NULL );
+        }
+
+        if( var_Type( p_input, "prev-title" ) == 0 ) {
+            var_Create( p_input, "prev-title", VLC_VAR_VOID );
+            text.psz_string = _("Previous title");
+            var_Change( p_input, "prev-title", VLC_VAR_SETTEXT, &text, NULL );
+            var_AddCallback( p_input, "prev-title", TitleCallback, NULL );
+        }
     }
 
     /* Create titles and chapters */
-- 
2.5.0



More information about the vlc-devel mailing list