[vlc-commits] demux: mkv: HandleKeyEvent: introduce common helper
Filip Roséen
git at videolan.org
Sun Jul 22 23:36:11 CEST 2018
vlc | branch: master | Filip Roséen <filip at atch.se> | Sun Jul 22 08:16:34 2018 +0200| [67a2d714e47b439c6e680abb7e34ddfd57596f6e] | committer: Jean-Baptiste Kempf
demux: mkv: HandleKeyEvent: introduce common helper
All of the handling in terms of ACTIONID_NAV_{LEFT,RIGHT,UP,DOWN} have
the same logic, besides what button they affect. A new helper,
ProcessNavAction, has been introduced to avoid code-duplication.
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=67a2d714e47b439c6e680abb7e34ddfd57596f6e
---
modules/demux/mkv/events.cpp | 110 ++++++++++---------------------------------
modules/demux/mkv/events.hpp | 2 +
2 files changed, 28 insertions(+), 84 deletions(-)
diff --git a/modules/demux/mkv/events.cpp b/modules/demux/mkv/events.cpp
index 769dcefe9e..1423ac9152 100644
--- a/modules/demux/mkv/events.cpp
+++ b/modules/demux/mkv/events.cpp
@@ -166,6 +166,28 @@ void *event_thread_t::EventThread(void *data)
return NULL;
}
+void event_thread_t::ProcessNavAction( uint16 button, pci_t* pci )
+{
+ demux_sys_t* p_sys = (demux_sys_t*)p_demux->p_sys;
+
+ if ( button > 0 && button <= pci->hli.hl_gi.btn_ns )
+ {
+ p_sys->dvd_interpretor.SetSPRM( 0x88, button );
+ btni_t button_ptr = pci->hli.btnit[button-1];
+ if ( button_ptr.auto_action_mode )
+ {
+ vlc_mutex_unlock( &lock );
+ vlc_mutex_lock( &p_sys->lock_demuxer );
+
+ // process the button action
+ p_sys->dvd_interpretor.Interpret( button_ptr.cmd.bytes, 8 );
+
+ vlc_mutex_unlock( &p_sys->lock_demuxer );
+ vlc_mutex_lock( &lock );
+ }
+ }
+}
+
void event_thread_t::HandleKeyEvent( EventInfo const& ev )
{
msg_Dbg( p_demux, "Handle Key Event");
@@ -182,90 +204,10 @@ void event_thread_t::HandleKeyEvent( EventInfo const& ev )
switch( ev.action.id )
{
- case ACTIONID_NAV_LEFT:
- {
- if ( button_ptr.left > 0 && button_ptr.left <= pci->hli.hl_gi.btn_ns )
- {
- i_curr_button = button_ptr.left;
- p_sys->dvd_interpretor.SetSPRM( 0x88, i_curr_button );
- btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
- if ( button_ptr.auto_action_mode )
- {
- vlc_mutex_unlock( &lock );
- vlc_mutex_lock( &p_sys->lock_demuxer );
-
- // process the button action
- p_sys->dvd_interpretor.Interpret( button_ptr.cmd.bytes, 8 );
-
- vlc_mutex_unlock( &p_sys->lock_demuxer );
- vlc_mutex_lock( &lock );
- }
- }
- }
- break;
- case ACTIONID_NAV_RIGHT:
- {
- if ( button_ptr.right > 0 && button_ptr.right <= pci->hli.hl_gi.btn_ns )
- {
- i_curr_button = button_ptr.right;
- p_sys->dvd_interpretor.SetSPRM( 0x88, i_curr_button );
- btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
- if ( button_ptr.auto_action_mode )
- {
- vlc_mutex_unlock( &lock );
- vlc_mutex_lock( &p_sys->lock_demuxer );
-
- // process the button action
- p_sys->dvd_interpretor.Interpret( button_ptr.cmd.bytes, 8 );
-
- vlc_mutex_unlock( &p_sys->lock_demuxer );
- vlc_mutex_lock( &lock );
- }
- }
- }
- break;
- case ACTIONID_NAV_UP:
- {
- if ( button_ptr.up > 0 && button_ptr.up <= pci->hli.hl_gi.btn_ns )
- {
- i_curr_button = button_ptr.up;
- p_sys->dvd_interpretor.SetSPRM( 0x88, i_curr_button );
- btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
- if ( button_ptr.auto_action_mode )
- {
- vlc_mutex_unlock( &lock );
- vlc_mutex_lock( &p_sys->lock_demuxer );
-
- // process the button action
- p_sys->dvd_interpretor.Interpret( button_ptr.cmd.bytes, 8 );
-
- vlc_mutex_unlock( &p_sys->lock_demuxer );
- vlc_mutex_lock( &lock );
- }
- }
- }
- break;
- case ACTIONID_NAV_DOWN:
- {
- if ( button_ptr.down > 0 && button_ptr.down <= pci->hli.hl_gi.btn_ns )
- {
- i_curr_button = button_ptr.down;
- p_sys->dvd_interpretor.SetSPRM( 0x88, i_curr_button );
- btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
- if ( button_ptr.auto_action_mode )
- {
- vlc_mutex_unlock( &lock );
- vlc_mutex_lock( &p_sys->lock_demuxer );
-
- // process the button action
- p_sys->dvd_interpretor.Interpret( button_ptr.cmd.bytes, 8 );
-
- vlc_mutex_unlock( &p_sys->lock_demuxer );
- vlc_mutex_lock( &lock );
- }
- }
- }
- break;
+ case ACTIONID_NAV_LEFT: return ProcessNavAction( button_ptr.left, pci );
+ case ACTIONID_NAV_RIGHT: return ProcessNavAction( button_ptr.right, pci );
+ case ACTIONID_NAV_UP: return ProcessNavAction( button_ptr.up, pci );
+ case ACTIONID_NAV_DOWN: return ProcessNavAction( button_ptr.down, pci );
case ACTIONID_NAV_ACTIVATE:
{
vlc_mutex_unlock( &lock );
diff --git a/modules/demux/mkv/events.hpp b/modules/demux/mkv/events.hpp
index 6bab0f5859..3aa670841a 100644
--- a/modules/demux/mkv/events.hpp
+++ b/modules/demux/mkv/events.hpp
@@ -112,6 +112,8 @@ private:
void HandleKeyEvent( EventInfo const& );
void HandleMouseEvent( EventInfo const& );
+ void ProcessNavAction( uint16 button, pci_t* pci );
+
demux_t *p_demux;
bool is_running;
More information about the vlc-commits
mailing list