[vlc-commits] hotkeys: Change subtitle position only if it exists and is enabled.

Zoran Turalija git at videolan.org
Mon Apr 15 11:30:05 CEST 2013


vlc | branch: master | Zoran Turalija <zoran.turalija at gmail.com> | Sun Apr 14 12:49:03 2013 +0200| [251fdaddb2007443b841d10aa246eda2bba3a381] | committer: Jean-Baptiste Kempf

hotkeys: Change subtitle position only if it exists and is enabled.

In ACTIONID_SUBPOS_UP/DOWN, do not change subtitle position if there
is no subtitle, or if subtitle has been currently disabled.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=251fdaddb2007443b841d10aa246eda2bba3a381
---

 modules/control/hotkeys.c |   33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 01d6f6b..7069d3d 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -970,14 +970,33 @@ static int PutAction( intf_thread_t *p_intf, int i_action )
         case ACTIONID_SUBPOS_DOWN:
         case ACTIONID_SUBPOS_UP:
         {
-            int i_pos;
-            if( i_action == ACTIONID_SUBPOS_DOWN )
-                i_pos = var_DecInteger( p_vout, "sub-margin" );
-            else
-                i_pos = var_IncInteger( p_vout, "sub-margin" );
+            if( p_input )
+            {
+                vlc_value_t val, list, list2;
+                int i_count;
+                var_Get( p_input, "spu-es", &val );
 
-            ClearChannels( p_intf, p_vout );
-            DisplayMessage( p_vout, _( "Subtitle position %d px" ), i_pos );
+                var_Change( p_input, "spu-es", VLC_VAR_GETCHOICES,
+                            &list, &list2 );
+                i_count = list.p_list->i_count;
+                if( i_count < 1 || val.i_int < 0 )
+                {
+                    DisplayMessage( p_vout,
+                                    _("Subtitle position: no active subtitle") );
+                    var_FreeList( &list, &list2 );
+                    break;
+                }
+
+                int i_pos;
+                if( i_action == ACTIONID_SUBPOS_DOWN )
+                    i_pos = var_DecInteger( p_vout, "sub-margin" );
+                else
+                    i_pos = var_IncInteger( p_vout, "sub-margin" );
+
+                ClearChannels( p_intf, p_vout );
+                DisplayMessage( p_vout, _( "Subtitle position %d px" ), i_pos );
+                var_FreeList( &list, &list2 );
+            }
             break;
         }
 



More information about the vlc-commits mailing list