[vlc-devel] [PATCH 5/5] mkv: use DEMUX_VOUT_CHANGED control to get vouts
Thomas Guillem
thomas at gllm.fr
Fri Jul 13 12:13:42 CEST 2018
On Fri, Jul 13, 2018, at 11:34, Thomas Guillem wrote:
> Remove one other dependency to "intf-event".
> ---
> modules/demux/mkv/demux.cpp | 57 +++++++++++++------------------------
> modules/demux/mkv/demux.hpp | 4 +--
> modules/demux/mkv/mkv.cpp | 5 ++++
> 3 files changed, 27 insertions(+), 39 deletions(-)
>
> diff --git a/modules/demux/mkv/demux.cpp b/modules/demux/mkv/demux.cpp
> index 4e39af0078..13dcfe534a 100644
> --- a/modules/demux/mkv/demux.cpp
> +++ b/modules/demux/mkv/demux.cpp
> @@ -31,7 +31,7 @@
>
> namespace mkv {
>
> -event_thread_t::event_thread_t(demux_t *p_demux) : p_demux(p_demux)
> +event_thread_t::event_thread_t(demux_t *p_demux) : p_demux(p_demux),
> vout(NULL)
> {
> vlc_mutex_init( &lock );
> vlc_cond_init( &wait );
> @@ -41,6 +41,12 @@ event_thread_t::event_thread_t(demux_t *p_demux) :
> p_demux(p_demux)
> event_thread_t::~event_thread_t()
> {
> ResetPci();
> + if( vout )
> + {
> + var_DelCallback( vout, "mouse-moved", EventMouse, this );
> + var_DelCallback( vout, "mouse-clicked", EventMouse, this );
> + vlc_object_release( vout );
> + }
> vlc_cond_destroy( &wait );
> vlc_mutex_destroy( &lock );
> }
> @@ -120,20 +126,21 @@ int event_thread_t::EventKey( vlc_object_t
> *p_this, char const *,
> return VLC_SUCCESS;
> }
>
> -int event_thread_t::EventInput( vlc_object_t *p_this, char const *,
> - vlc_value_t, vlc_value_t newval, void *p_data )
> +void event_thread_t::voutChanged(vout_thread_t **vouts, size_t vout_count)
> {
> - VLC_UNUSED( p_this );
> - event_thread_t *p_ev = (event_thread_t *) p_data;
> - vlc_mutex_lock( &p_ev->lock );
> - if( newval.i_int == INPUT_EVENT_VOUT )
> + if( vout )
> {
> - p_ev->b_vout |= true;
> - vlc_cond_signal( &p_ev->wait );
> + var_DelCallback( vout, "mouse-moved", EventMouse, this );
> + var_DelCallback( vout, "mouse-clicked", EventMouse, this );
> + vlc_object_release( vout );
> + }
> + vout = vout_count > 0 ? vouts[0] : NULL;
> + if( vout )
> + {
> + vlc_object_hold( vout );
> + var_AddCallback( vout, "mouse-moved", EventMouse, this );
> + var_AddCallback( vout, "mouse-clicked", EventMouse, this );
> }
> - vlc_mutex_unlock( &p_ev->lock );
> -
> - return VLC_SUCCESS;
> }
>
> void event_thread_t::EventThread()
> @@ -145,18 +152,15 @@ void event_thread_t::EventThread()
> b_moved = false;
> b_clicked = false;
> i_key_action = 0;
> - b_vout = true;
>
> /* catch all key event */
> var_AddCallback( p_demux->obj.libvlc, "key-action", EventKey, this );
> - /* catch input event */
> - var_AddCallback( p_demux->p_input, "intf-event", EventInput, this );
>
> /* main loop */
> for( ;; )
> {
> vlc_mutex_lock( &lock );
> - while( !b_abort && !i_key_action && !b_moved && !b_clicked && !b_vout)
> + while( !b_abort && !i_key_action && !b_moved && !b_clicked)
> vlc_cond_wait( &wait, &lock );
>
> if( b_abort )
> @@ -395,30 +399,9 @@ void event_thread_t::EventThread()
> b_moved = false;
> b_clicked = false;
> }
> -
> - b_vout = false;
> vlc_mutex_unlock( &lock );
> -
> - /* Always check vout */
> - if( p_vout == NULL )
> - {
> - p_vout = (vlc_object_t*) input_GetVout(p_demux->p_input);
> - if( p_vout)
> - {
> - var_AddCallback( p_vout, "mouse-moved", EventMouse, this );
> - var_AddCallback( p_vout, "mouse-clicked", EventMouse, this );
> - }
> - }
> }
>
> - /* Release callback */
> - if( p_vout )
> - {
> - var_DelCallback( p_vout, "mouse-moved", EventMouse, this );
> - var_DelCallback( p_vout, "mouse-clicked", EventMouse, this );
> - vlc_object_release( p_vout );
> - }
> - var_DelCallback( p_demux->p_input, "intf-event", EventInput, this );
> var_DelCallback( p_demux->obj.libvlc, "key-action", EventKey, this );
>
> vlc_restorecancel (canc);
> diff --git a/modules/demux/mkv/demux.hpp b/modules/demux/mkv/demux.hpp
> index 79f15b5f83..a465e0438e 100644
> --- a/modules/demux/mkv/demux.hpp
> +++ b/modules/demux/mkv/demux.hpp
> @@ -303,6 +303,7 @@ public:
>
> void SetPci(const pci_t *data);
> void ResetPci();
> + void voutChanged(vout_thread_t **, size_t);
>
> private:
> void EventThread();
> @@ -310,12 +311,12 @@ private:
>
> static int EventMouse( vlc_object_t *, char const *, vlc_value_t,
> vlc_value_t, void * );
> 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 * );
>
> demux_t *p_demux;
>
> bool is_running;
> vlc_thread_t thread;
> + vout_thread_t *vout;
>
> vlc_mutex_t lock;
> vlc_cond_t wait;
> @@ -323,7 +324,6 @@ private:
> bool b_moved;
> bool b_clicked;
> int i_key_action;
> - bool b_vout;
> pci_t pci_packet;
> };
>
> diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
> index af6554dcb2..432acb4a96 100644
> --- a/modules/demux/mkv/mkv.cpp
> +++ b/modules/demux/mkv/mkv.cpp
> @@ -465,6 +465,11 @@ static int Control( demux_t *p_demux, int i_query,
> va_list args )
> case DEMUX_GET_PTS_DELAY:
> return demux_vaControlHelper( p_demux->s, 0, -1, 0, 1,
> i_query, args );
>
> + case DEMUX_VOUT_CHANGED:
> + p_sys->p_ev->voutChanged( va_arg( args, vout_thread_t** ),
> + va_arg( args, size_t ) );
va_arg evaluation order is undefined here: fixed in my local branch.
> + break;
return VLC_SUCCESS; here.
> +
> default:
> return VLC_EGENERIC;
> }
> --
> 2.18.0
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list