[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: mkv: handle navigation keys directly

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Nov 27 07:48:08 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
e03a9e11 by Steve Lhomme at 2024-11-27T07:35:39+00:00
demux: mkv: handle navigation keys directly

Before 66ca609d2bcede2f64fdcc518eba3eabcbdfe5ef the keys were
received from the UI thread. Now they are recieved in the input
thread and they can be handled right away.

- - - - -
5a30e9b9 by Steve Lhomme at 2024-11-27T07:35:39+00:00
demux: mkv: pass events to queue by reference

No need to do a copy, another copy will be queued.

- - - - -


4 changed files:

- modules/demux/mkv/chapter_command_dvd.cpp
- modules/demux/mkv/chapter_command_dvd.hpp
- modules/demux/mkv/events.cpp
- modules/demux/mkv/events.hpp


Changes:

=====================================
modules/demux/mkv/chapter_command_dvd.cpp
=====================================
@@ -570,29 +570,30 @@ bool dvd_command_interpretor_c::Interpret( const binary * p_command, size_t i_si
     return f_result;
 }
 
-void dvd_command_interpretor_c::ProcessNavAction( uint16_t button )
+bool dvd_command_interpretor_c::ProcessNavAction( uint16_t button )
 {
     const pci_t & pci = pci_packet;
 
     if( button <= 0 || button > pci.hli.hl_gi.btn_ns )
-        return;
+        return false;
 
     SetSPRM( 0x88, button );
     const btni_t & button_ptr = pci.hli.btnit[button-1];
     if ( button_ptr.auto_action_mode )
     {
         // process the button action
-        Interpret( button_ptr.cmd.bytes, 8 );
+        return Interpret( button_ptr.cmd.bytes, 8 );
     }
+    return false;
 }
 
-void dvd_command_interpretor_c::HandleKeyEvent( NavivationKey key )
+bool dvd_command_interpretor_c::HandleKeyEvent( NavivationKey key )
 {
     const pci_t & pci = pci_packet;
     uint16_t i_curr_button = GetSPRM( 0x88 );
 
     if( i_curr_button <= 0 || i_curr_button > pci.hli.hl_gi.btn_ns )
-        return;
+        return false;
 
     const btni_t & button_ptr = pci.hli.btnit[i_curr_button-1];
 
@@ -604,10 +605,10 @@ void dvd_command_interpretor_c::HandleKeyEvent( NavivationKey key )
     case DOWN:  return ProcessNavAction( button_ptr.down );
     case OK:
         // process the button action
-        Interpret( button_ptr.cmd.bytes, 8 );
-        break;
-    default:
-        break;
+        return Interpret( button_ptr.cmd.bytes, 8 );
+    case MENU:
+    case POPUP:
+        return false;
     }
 }
 


=====================================
modules/demux/mkv/chapter_command_dvd.hpp
=====================================
@@ -35,7 +35,7 @@ public:
 
     bool Interpret( const binary * p_command, size_t i_size = 8 );
 
-    void HandleKeyEvent( NavivationKey );
+    bool HandleKeyEvent( NavivationKey );
     void HandleMousePressed( unsigned x, unsigned y );
 
     void SetPci(const uint8_t *, unsigned size);
@@ -92,7 +92,7 @@ protected:
         return false;
     }
 
-    void ProcessNavAction( uint16_t button );
+    bool ProcessNavAction( uint16_t button );
 
     std::string GetRegTypeName( bool b_value, uint16_t value ) const
     {


=====================================
modules/demux/mkv/events.cpp
=====================================
@@ -100,7 +100,8 @@ int event_thread_t::SendEventNav( demux_query_e nav_query )
     if( !is_running )
         return VLC_EGENERIC;
 
-    QueueEvent( EventInfo{ key } );
+    if ( !HandleKeyEvent( key ) )
+        return VLC_EGENERIC;
 
     return VLC_SUCCESS;
 }
@@ -145,10 +146,6 @@ void event_thread_t::EventThread()
                     HandleMouseEvent( ev );
                     break;
 
-                case EventInfo::ActionEvent:
-                    HandleKeyEvent( ev );
-                    break;
-
                 case EventInfo::ButtonDataEvent:
                     HandleButtonData( ev );
                     break;
@@ -166,14 +163,7 @@ void *event_thread_t::EventThread(void *data)
     return NULL;
 }
 
-void event_thread_t::HandleKeyEvent( EventInfo const& ev )
-{
-    msg_Dbg( p_demux, "Handle Key Event");
-
-    HandleKeyEvent( ev.nav.key );
-}
-
-void event_thread_t::HandleKeyEvent( NavivationKey key )
+bool event_thread_t::HandleKeyEvent( NavivationKey key )
 {
     demux_sys_t* p_sys = (demux_sys_t*)p_demux->p_sys;
 
@@ -181,10 +171,10 @@ void event_thread_t::HandleKeyEvent( NavivationKey key )
 
     auto interpretor = p_sys->GetDVDInterpretor();
     if (!interpretor)
-        return;
+        return false;
 
     // process the button action
-    interpretor->HandleKeyEvent( key );
+    return interpretor->HandleKeyEvent( key );
 }
 
 void event_thread_t::HandleMouseEvent( EventInfo const& event )


=====================================
modules/demux/mkv/events.hpp
=====================================
@@ -72,7 +72,6 @@ private:
     struct EventInfo {
         enum {
             ESMouseEvent,
-            ActionEvent,
             ButtonDataEvent,
         } type;
 
@@ -82,12 +81,6 @@ private:
         {
         }
 
-        EventInfo( NavivationKey key )
-            : type( ActionEvent )
-            , nav{ key }
-        {
-        }
-
         EventInfo( block_t * block )
             : type( ButtonDataEvent )
             , button_data( block, block_Release )
@@ -114,7 +107,6 @@ private:
 
     static void EventMouse( vlc_mouse_t const* state, void* userdata );
 
-    void HandleKeyEvent( EventInfo const& );
     void HandleMouseEvent( EventInfo const& );
     void HandleButtonData( EventInfo const& );
 
@@ -133,7 +125,7 @@ private:
     typedef std::list<EventInfo> pending_events_t;
     pending_events_t pending_events; // protected by "lock"
 
-    void QueueEvent(const EventInfo e)
+    void QueueEvent(const EventInfo & e)
     {
         vlc_mutex_locker lock_guard( &lock );
 
@@ -143,7 +135,7 @@ private:
         vlc_cond_signal( &wait );
     }
 
-    void HandleKeyEvent( NavivationKey key );
+    bool HandleKeyEvent( NavivationKey key );
     void HandleMousePressed( unsigned x, unsigned y );
     void HandleButtonData( block_t * );
 };



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/aa496943e41e3b73044d405cda7d4ff2740d467a...5a30e9b99352d2b737272807faaa5e63b5767817

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/aa496943e41e3b73044d405cda7d4ff2740d467a...5a30e9b99352d2b737272807faaa5e63b5767817
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list