[vlc-commits] demux: mkv: move key event handling to separate function
Filip Roséen
git at videolan.org
Fri Jul 20 09:37:35 CEST 2018
vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Jul 18 03:09:44 2018 +0200| [9d12eedb8a4c1984335ef6394cc1c56186dd2443] | committer: Thomas Guillem
demux: mkv: move key event handling to separate function
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9d12eedb8a4c1984335ef6394cc1c56186dd2443
---
modules/demux/mkv/events.cpp | 246 ++++++++++++++++++++++---------------------
modules/demux/mkv/events.hpp | 2 +
2 files changed, 127 insertions(+), 121 deletions(-)
diff --git a/modules/demux/mkv/events.cpp b/modules/demux/mkv/events.cpp
index 128fdda62a..238c3f1054 100644
--- a/modules/demux/mkv/events.cpp
+++ b/modules/demux/mkv/events.cpp
@@ -167,127 +167,7 @@ void event_thread_t::EventThread()
/* KEY part */
if( i_key_action )
- {
- msg_Dbg( p_demux, "Handle Key Event");
-
- pci_t *pci = &pci_packet;
-
- uint16 i_curr_button = p_sys->dvd_interpretor.GetSPRM( 0x88 );
-
- switch( i_key_action )
- {
- case ACTIONID_NAV_LEFT:
- if ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
- {
- btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
- if ( p_button_ptr->left > 0 && p_button_ptr->left <= pci->hli.hl_gi.btn_ns )
- {
- i_curr_button = p_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 ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
- {
- btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
- if ( p_button_ptr->right > 0 && p_button_ptr->right <= pci->hli.hl_gi.btn_ns )
- {
- i_curr_button = p_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 ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
- {
- btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
- if ( p_button_ptr->up > 0 && p_button_ptr->up <= pci->hli.hl_gi.btn_ns )
- {
- i_curr_button = p_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 ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
- {
- btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
- if ( p_button_ptr->down > 0 && p_button_ptr->down <= pci->hli.hl_gi.btn_ns )
- {
- i_curr_button = p_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_ACTIVATE:
- if ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
- {
- btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
-
- 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;
- default:
- break;
- }
- i_key_action = 0;
- }
+ HandleKeyEvent();
/* MOUSE part */
if( p_vout && ( b_moved || b_clicked ) )
@@ -430,5 +310,129 @@ void *event_thread_t::EventThread(void *data)
return NULL;
}
+void event_thread_t::HandleKeyEvent()
+{
+ msg_Dbg( p_demux, "Handle Key Event");
+
+ demux_sys_t* p_sys = (demux_sys_t*)p_demux->p_sys;
+ pci_t *pci = &pci_packet;
+
+ uint16 i_curr_button = p_sys->dvd_interpretor.GetSPRM( 0x88 );
+
+ switch( i_key_action )
+ {
+ case ACTIONID_NAV_LEFT:
+ if ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
+ {
+ btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
+ if ( p_button_ptr->left > 0 && p_button_ptr->left <= pci->hli.hl_gi.btn_ns )
+ {
+ i_curr_button = p_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 ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
+ {
+ btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
+ if ( p_button_ptr->right > 0 && p_button_ptr->right <= pci->hli.hl_gi.btn_ns )
+ {
+ i_curr_button = p_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 ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
+ {
+ btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
+ if ( p_button_ptr->up > 0 && p_button_ptr->up <= pci->hli.hl_gi.btn_ns )
+ {
+ i_curr_button = p_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 ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
+ {
+ btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
+ if ( p_button_ptr->down > 0 && p_button_ptr->down <= pci->hli.hl_gi.btn_ns )
+ {
+ i_curr_button = p_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_ACTIVATE:
+ if ( i_curr_button > 0 && i_curr_button <= pci->hli.hl_gi.btn_ns )
+ {
+ btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
+
+ 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;
+ default:
+ break;
+ }
+ i_key_action = 0;
+}
+
} // namespace
diff --git a/modules/demux/mkv/events.hpp b/modules/demux/mkv/events.hpp
index 98c8113af3..03441d6550 100644
--- a/modules/demux/mkv/events.hpp
+++ b/modules/demux/mkv/events.hpp
@@ -51,6 +51,8 @@ private:
static int EventKey( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * );
static int EventInput( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * );
+ void HandleKeyEvent();
+
demux_t *p_demux;
bool is_running;
More information about the vlc-commits
mailing list