[vlc-devel] [PATCH 14/22] actions: seek and change volume if not menu|interactive

Rémi Denis-Courmont remi at remlab.net
Thu Aug 3 16:41:39 CEST 2017


Le 3 août 2017 16:10:47 GMT+03:00, "Hugo Beauzée-Luyssen" <hugo at beauzee.fr> a écrit :
>From: Thomas Guillem <thomas at gllm.fr>
>
>---
>src/misc/actions.c | 215
>+++++++++++++++++++++++++++++++++--------------------
> 1 file changed, 136 insertions(+), 79 deletions(-)
>
>diff --git a/src/misc/actions.c b/src/misc/actions.c
>index 552d8e7367..8a16a4bc53 100644
>--- a/src/misc/actions.c
>+++ b/src/misc/actions.c
>@@ -779,6 +779,63 @@ static float adjust_rate_fine( playlist_t
>*p_playlist, const int i_dir )
>     return f_rate;
> }
> 
>+static void do_volume_up( vlc_actions_t *p_as, vout_thread_t *p_vout,
>+                          playlist_t *p_playlist )
>+{
>+    float vol;
>+    if( playlist_VolumeUp( p_playlist, 1, &vol ) == 0 )
>+        display_volume( p_as, p_vout, vol );
>+}
>+
>+static void do_volume_down( vlc_actions_t *p_as, vout_thread_t
>*p_vout,
>+                            playlist_t *p_playlist )
>+{
>+    float vol;
>+    if( playlist_VolumeDown( p_playlist, 1, &vol ) == 0 )
>+        display_volume( p_as, p_vout, vol );
>+}
>+
>+static void do_seek( vlc_actions_t *p_as, vout_thread_t
>*p_notify_vout,
>+                     input_thread_t *p_input, vlc_action_id_t i_action
>)
>+{
>+    if( p_input == NULL || !var_GetBool( p_input, "can-seek" ) )
>+        return;
>+
>+    const char *varname;
>+    int sign = +1;
>+    switch( i_action )
>+    {
>+        case ACTIONID_JUMP_BACKWARD_EXTRASHORT:
>+            sign = -1;
>+        case ACTIONID_JUMP_FORWARD_EXTRASHORT:
>+            varname = "extrashort-jump-size";
>+            break;
>+        case ACTIONID_JUMP_BACKWARD_SHORT:
>+            sign = -1;
>+        case ACTIONID_JUMP_FORWARD_SHORT:
>+            varname = "short-jump-size";
>+            break;
>+        case ACTIONID_JUMP_BACKWARD_MEDIUM:
>+            sign = -1;
>+        case ACTIONID_JUMP_FORWARD_MEDIUM:
>+            varname = "medium-jump-size";
>+            break;
>+        case ACTIONID_JUMP_BACKWARD_LONG:
>+            sign = -1;
>+        case ACTIONID_JUMP_FORWARD_LONG:
>+            varname = "long-jump-size";
>+            break;
>+        default:
>+            vlc_assert_unreachable();
>+    }
>+
>+    mtime_t it = var_InheritInteger( p_input, varname );
>+    if( it < 0 )
>+        return;
>+    var_SetInteger( p_input, "time-offset", it * sign * CLOCK_FREQ );
>+    display_position( p_as, p_notify_vout, p_input );
>+}
>+
> static int
>vlc_actions_do_va( vlc_object_t *p_obj, vlc_action_id_t i_action, bool
>b_notify,
>                    va_list args )
>@@ -930,19 +987,11 @@ vlc_actions_do_va( vlc_object_t *p_obj,
>vlc_action_id_t i_action, bool b_notify,
>             break;
>         }
>         case ACTIONID_VOL_UP:
>-        {
>-            float vol;
>-            if( playlist_VolumeUp( p_playlist, 1, &vol ) == 0 )
>-                display_volume( p_as, p_notify_vout, vol );
>+            do_volume_up( p_as, p_notify_vout, p_playlist );
>             break;
>-        }
>         case ACTIONID_VOL_DOWN:
>-        {
>-            float vol;
>-            if( playlist_VolumeDown( p_playlist, 1, &vol ) == 0 )
>-                display_volume( p_as, p_notify_vout, vol );
>+            do_volume_down( p_as, p_notify_vout, p_playlist );
>             break;
>-        }
>         case ACTIONID_VOL_MUTE:
>         {
>             int mute = playlist_MuteGet( p_playlist );
>@@ -1370,49 +1419,8 @@ vlc_actions_do_va( vlc_object_t *p_obj,
>vlc_action_id_t i_action, bool b_notify,
>         case ACTIONID_JUMP_FORWARD_MEDIUM:
>         case ACTIONID_JUMP_BACKWARD_LONG:
>         case ACTIONID_JUMP_FORWARD_LONG:
>-        {
>-            if( p_input == NULL || !var_GetBool( p_input, "can-seek" )
>)
>-                break;
>-
>-            const char *varname;
>-            int sign = +1;
>-            switch( i_action )
>-            {
>-                case ACTIONID_JUMP_BACKWARD_EXTRASHORT:
>-                    sign = -1;
>-                    /* fall through */
>-                case ACTIONID_JUMP_FORWARD_EXTRASHORT:
>-                    varname = "extrashort-jump-size";
>-                    break;
>-                case ACTIONID_JUMP_BACKWARD_SHORT:
>-                    sign = -1;
>-                    /* fall through */
>-                case ACTIONID_JUMP_FORWARD_SHORT:
>-                    varname = "short-jump-size";
>-                    break;
>-                case ACTIONID_JUMP_BACKWARD_MEDIUM:
>-                    sign = -1;
>-                    /* fall through */
>-                case ACTIONID_JUMP_FORWARD_MEDIUM:
>-                    varname = "medium-jump-size";
>-                    break;
>-                case ACTIONID_JUMP_BACKWARD_LONG:
>-                    sign = -1;
>-                    /* fall through */
>-                case ACTIONID_JUMP_FORWARD_LONG:
>-                    varname = "long-jump-size";
>-                    break;
>-                default:
>-                    vlc_assert_unreachable();
>-            }
>-
>-            mtime_t it = var_InheritInteger( p_input, varname );
>-            if( it < 0 )
>-                break;
>-            var_SetInteger( p_input, "time-offset", it * sign *
>CLOCK_FREQ );
>-            display_position( p_as, p_notify_vout, p_input );
>+            do_seek( p_as, p_notify_vout, p_input, i_action );
>             break;
>-        }
> 
>         /* Input navigation */
>         case ACTIONID_TITLE_PREV:
>@@ -1440,37 +1448,86 @@ vlc_actions_do_va( vlc_object_t *p_obj,
>vlc_action_id_t i_action, bool b_notify,
>                 input_Control( p_input, INPUT_NAV_ACTIVATE, NULL );
>             break;
>         case ACTIONID_NAV_UP:
>-            if( p_vout )
>-                input_UpdateViewpoint( p_input,
>-                                       &(vlc_viewpoint_t) { .pitch =
>-1.f },
>-                                       false );
>-            if( p_input )
>-                input_Control( p_input, INPUT_NAV_UP, NULL );
>-            break;
>         case ACTIONID_NAV_DOWN:
>-            if( p_vout )
>-                input_UpdateViewpoint( p_input,
>-                                       &(vlc_viewpoint_t) { .pitch =
>1.f },
>-                                       false );
>-            if( p_input )
>-                input_Control( p_input, INPUT_NAV_DOWN, NULL );
>-            break;
>         case ACTIONID_NAV_LEFT:
>-            if( p_vout )
>-                input_UpdateViewpoint( p_input,
>-                                       &(vlc_viewpoint_t) { .yaw =
>-1.f },
>-                                       false );
>-            if( p_input )
>-                input_Control( p_input, INPUT_NAV_LEFT, NULL );
>-            break;
>         case ACTIONID_NAV_RIGHT:
>-            if( p_vout )
>-                input_UpdateViewpoint( p_input,
>-                                       &(vlc_viewpoint_t) { .yaw = 1.f
>},
>-                                       false );
>-            if( p_input )
>-                input_Control( p_input, INPUT_NAV_RIGHT, NULL );
>+        {
>+            if( !p_input )
>+                break;
>+            bool b_vrnav = p_vout &&
>+                            var_GetBool( p_vout,
>"viewpoint-changeable" );
>+            if( b_vrnav )
>+            {
>+                switch( i_action )
>+                {
>+                    case ACTIONID_NAV_UP:
>+                        input_UpdateViewpoint( p_input,
>+                                               &(vlc_viewpoint_t) {
>+                                                   .pitch = -1.f
>+                                               },
>+                                               false );
>+                        break;
>+                    case ACTIONID_NAV_DOWN:
>+                        input_UpdateViewpoint( p_input,
>+                                               &(vlc_viewpoint_t) {
>+                                                   .pitch = 1.f
>+                                               },
>+                                               false );
>+                        break;
>+                    case ACTIONID_NAV_LEFT:
>+                        input_UpdateViewpoint( p_input,
>+                                               &(vlc_viewpoint_t) {
>+                                                   .yaw = -1.f
>+                                               },
>+                                               false );
>+                        break;
>+                    case ACTIONID_NAV_RIGHT:
>+                        input_UpdateViewpoint( p_input,
>+                                               &(vlc_viewpoint_t) {
>+                                                   .yaw = 1.f
>+                                               },
>+                                               false );
>+                        break;
>+                    default:
>+                        vlc_assert_unreachable();
>+                }
>+                break;
>+            }
>+            input_title_t *p_title = NULL;
>+            int i_title_id = -1;
>+            if ( input_Control( p_input, INPUT_GET_TITLE_INFO,
>&p_title,
>+                                &i_title_id ) == VLC_SUCCESS
>+              && p_title->i_flags &
>(INPUT_TITLE_INTERACTIVE|INPUT_TITLE_MENU) )
>+            {
>+
>+                input_Control( p_input, i_action -
>ACTIONID_NAV_ACTIVATE
>+                               + INPUT_NAV_ACTIVATE, NULL );
>+            }
>+            else
>+            {
>+                switch( i_action )
>+                {
>+                    case ACTIONID_NAV_UP:
>+                        do_volume_up( p_as, p_notify_vout, p_playlist
>);
>+                        break;
>+                    case ACTIONID_NAV_DOWN:
>+                        do_volume_down( p_as, p_notify_vout,
>p_playlist );
>+                        break;
>+                    case ACTIONID_NAV_LEFT:
>+                        do_seek( p_as, p_notify_vout, p_input,
>+                                 ACTIONID_JUMP_BACKWARD_SHORT );
>+                        break;
>+                    case ACTIONID_NAV_RIGHT:
>+                        do_seek( p_as, p_notify_vout, p_input,
>+                                 ACTIONID_JUMP_FORWARD_SHORT );
>+                        break;
>+                    default:
>+                        break;
>+                }
>+            }
>+            vlc_input_title_Delete( p_title );
>             break;
>+        }
> 
>         /* Video Output actions */
>         case ACTIONID_SNAPSHOT:
>-- 
>2.11.0
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

This is also broken by design. The volume might not be updated, or the result may be different than requested. You can't assume that the result is known synchronously.
-- 
Rémi Denis-Courmont
Typed on an inconvenient virtual keyboard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170803/f605fbce/attachment.html>


More information about the vlc-devel mailing list