[vlc-devel] [V3 PATCH 1/3] vout: set a mouse event cb when creating a vout
Rémi Denis-Courmont
remi at remlab.net
Tue Jul 17 16:22:33 CEST 2018
Le lundi 16 juillet 2018, 16:57:21 EEST Thomas Guillem a écrit :
> ---
> include/vlc_mouse.h | 3 +++
> src/input/decoder.c | 6 +++---
> src/input/resource.c | 15 +++++++++++----
> src/input/resource.h | 5 ++++-
> src/video_output/display.c | 2 ++
> src/video_output/video_output.c | 23 ++++++++++++++++-------
> src/video_output/vout_internal.h | 4 ++++
> 7 files changed, 43 insertions(+), 15 deletions(-)
Almost LGTM.
>
> diff --git a/include/vlc_mouse.h b/include/vlc_mouse.h
> index 481c3598e9..f7edbe1446 100644
> --- a/include/vlc_mouse.h
> +++ b/include/vlc_mouse.h
> @@ -53,6 +53,9 @@ typedef struct vlc_mouse_t
> bool b_double_click;
> } vlc_mouse_t;
>
> +typedef void (*vlc_mouse_event)(const vlc_mouse_t *oldmouse,
> + const vlc_mouse_t *newmouse, void
As argued in the other thread, I would remove the "old" parameter here.
> *user_data); +
> static inline void vlc_mouse_Init( vlc_mouse_t *p_mouse )
> {
> p_mouse->i_x = 0;
> diff --git a/src/input/decoder.c b/src/input/decoder.c
> index 1cba292d14..6af9ca8479 100644
> --- a/src/input/decoder.c
> +++ b/src/input/decoder.c
> @@ -291,7 +291,7 @@ static vout_thread_t *aout_request_vout( void
> *p_private, input_thread_t *p_input = p_owner->p_input;
>
> p_vout = input_resource_RequestVout( p_owner->p_resource, p_vout,
> p_fmt, 1, - b_recyle );
> + NULL, NULL, b_recyle );
> if( p_input != NULL )
> input_SendEventVout( p_input );
>
> @@ -521,7 +521,7 @@ static int vout_update_format( decoder_t *p_dec )
> p_vout, &fmt,
> dpb_size +
> p_dec->i_extra_picture_buffers
> + 1, - true );
> + NULL, NULL, true );
> vlc_mutex_lock( &p_owner->lock );
> p_owner->p_vout = p_vout;
>
> @@ -1869,7 +1869,7 @@ static void DeleteDecoder( decoder_t * p_dec )
> vout_Cancel( p_owner->p_vout, false );
>
> input_resource_RequestVout( p_owner->p_resource,
> p_owner->p_vout, NULL, - 0, true
> );
> + 0, NULL, NULL, true );
> if( p_owner->p_input != NULL )
> input_SendEventVout( p_owner->p_input );
> }
> diff --git a/src/input/resource.c b/src/input/resource.c
> index b1a8675dc3..daaafc8591 100644
> --- a/src/input/resource.c
> +++ b/src/input/resource.c
> @@ -196,7 +196,8 @@ static void DisplayVoutTitle( input_resource_t
> *p_resource, static vout_thread_t *RequestVout( input_resource_t
> *p_resource,
> vout_thread_t *p_vout,
> const video_format_t *p_fmt, unsigned
> dpb_size, - bool b_recycle )
> + vlc_mouse_event mouse_event,
> + void *mouse_data, bool b_recycle )
> {
> vlc_assert_locked( &p_resource->lock );
>
> @@ -237,6 +238,8 @@ static vout_thread_t *RequestVout( input_resource_t
> *p_resource, .change_fmt = true,
> .fmt = p_fmt,
> .dpb_size = dpb_size,
> + .mouse_event= mouse_event,
> + .mouse_data = mouse_data,
> };
> p_vout = vout_Request( p_resource->p_parent, &cfg );
> if( !p_vout )
> @@ -282,6 +285,8 @@ static vout_thread_t *RequestVout( input_resource_t
> *p_resource, .change_fmt = false,
> .fmt = NULL,
> .dpb_size = 0,
> + .mouse_event= NULL,
> + .mouse_data = NULL,
> };
> p_resource->p_vout_free = vout_Request( p_resource->p_parent,
> &cfg ); }
> @@ -466,10 +471,12 @@ void input_resource_SetInput( input_resource_t
> *p_resource, input_thread_t *p_in vout_thread_t
> *input_resource_RequestVout( input_resource_t *p_resource, vout_thread_t
> *p_vout, const video_format_t *p_fmt, unsigned dpb_size, -
> bool b_recycle )
> + vlc_mouse_event mouse_event,
> + void *mouse_data, bool
> b_recycle ) {
> vlc_mutex_lock( &p_resource->lock );
> - vout_thread_t *p_ret = RequestVout( p_resource, p_vout, p_fmt,
> dpb_size, b_recycle ); + vout_thread_t *p_ret = RequestVout( p_resource,
> p_vout, p_fmt, dpb_size, +
> mouse_event, mouse_data, b_recycle ); vlc_mutex_unlock( &p_resource->lock
> );
>
> return p_ret;
> @@ -487,7 +494,7 @@ void input_resource_HoldVouts( input_resource_t
> *p_resource, vout_thread_t ***pp
>
> void input_resource_TerminateVout( input_resource_t *p_resource )
> {
> - input_resource_RequestVout( p_resource, NULL, NULL, 0, false );
> + input_resource_RequestVout( p_resource, NULL, NULL, 0, NULL, NULL,
> false ); }
> bool input_resource_HasVout( input_resource_t *p_resource )
> {
> diff --git a/src/input/resource.h b/src/input/resource.h
> index 8f83eb3183..8011a59edb 100644
> --- a/src/input/resource.h
> +++ b/src/input/resource.h
> @@ -25,6 +25,7 @@
> #define LIBVLC_INPUT_RESOURCE_H 1
>
> #include <vlc_common.h>
> +#include <vlc_mouse.h>
>
> /**
> * This function set the associated input.
> @@ -40,7 +41,9 @@ sout_instance_t *input_resource_RequestSout(
> input_resource_t *, sout_instance_t * This function handles vout request.
> */
> vout_thread_t *input_resource_RequestVout( input_resource_t *,
> vout_thread_t *, - const
> video_format_t *, unsigned dpb_size, bool b_recycle ); +
> const video_format_t *, unsigned dpb_size, +
> vlc_mouse_event mouse_event, +
> void *mouse_event_data, bool b_recycle );
>
> /**
> * This function returns one of the current vout if any.
> diff --git a/src/video_output/display.c b/src/video_output/display.c
> index 7f0b16c937..091593195f 100644
> --- a/src/video_output/display.c
> +++ b/src/video_output/display.c
> @@ -1331,5 +1331,7 @@ void vout_SendDisplayEventMouse(vout_thread_t *vout,
> const vlc_mouse_t *m)
>
> if (m->b_double_click)
> var_ToggleBool(vout, "fullscreen");
> + if (vout->p->mouse_event)
> + vout->p->mouse_event(&vout->p->mouse, m, vout->p->mouse_data);
> vout->p->mouse = *m;
> }
> diff --git a/src/video_output/video_output.c
> b/src/video_output/video_output.c index 5db7acf509..e9b5de944f 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -134,6 +134,8 @@ static vout_thread_t *VoutCreate(vlc_object_t *object,
>
> vout->p->original = original;
> vout->p->dpb_size = cfg->dpb_size;
> + vout->p->mouse_event = cfg->mouse_event;
> + vout->p->mouse_data = cfg->mouse_data;
>
> vout_control_Init(&vout->p->control);
> vout_control_PushVoid(&vout->p->control, VOUT_CONTROL_INIT);
> @@ -242,15 +244,14 @@ vout_thread_t *vout_Request(vlc_object_t *object,
> spu_Attach(vout->p->spu, vout->p->input, true);
> }
>
> - if (cfg->change_fmt) {
> - vout_control_cmd_t cmd;
> - vout_control_cmd_Init(&cmd, VOUT_CONTROL_REINIT);
> - cmd.cfg = cfg;
> + vout_control_cmd_t cmd;
> + vout_control_cmd_Init(&cmd, VOUT_CONTROL_REINIT);
> + cmd.cfg = cfg;
> + vout_control_Push(&vout->p->control, &cmd);
> + vout_control_WaitEmpty(&vout->p->control);
>
> - vout_control_Push(&vout->p->control, &cmd);
> - vout_control_WaitEmpty(&vout->p->control);
> + if (cfg->change_fmt)
> vout_IntfReinit(vout);
> - }
>
> if (!vout->p->dead) {
> msg_Dbg(object, "reusing provided vout");
> @@ -1594,6 +1595,12 @@ static int ThreadReinit(vout_thread_t *vout,
> {
> video_format_t original;
>
> + vout->p->mouse_event = NULL;
> + vout->p->mouse_data = NULL;
> +
> + if (!cfg->change_fmt)
> + return VLC_SUCCESS;
> +
> vout->p->pause.is_on = false;
> vout->p->pause.date = VLC_TICK_INVALID;
>
> @@ -1646,6 +1653,8 @@ static int ThreadReinit(vout_thread_t *vout,
>
> vout->p->original = original;
> vout->p->dpb_size = cfg->dpb_size;
> + vout->p->mouse_event = cfg->mouse_event;
> + vout->p->mouse_data = cfg->mouse_data;
> if (ThreadStart(vout, &state)) {
> ThreadClean(vout);
> return VLC_EGENERIC;
> diff --git a/src/video_output/vout_internal.h
> b/src/video_output/vout_internal.h index b6940ba070..ce02c850ed 100644
> --- a/src/video_output/vout_internal.h
> +++ b/src/video_output/vout_internal.h
> @@ -50,6 +50,8 @@ typedef struct {
> bool change_fmt;
> const video_format_t *fmt;
> unsigned dpb_size;
> + vlc_mouse_event mouse_event;
> + void *mouse_data;
I'd keep the callback data pointer generic/common, e.g. 'opaque'. If other
callbacks are added, they should probably share the callback data - and use a
const callbacks structure.
Keyboard events callback make the logical next step in the future.
> } vout_configuration_t;
> #include "control.h"
>
> @@ -138,6 +140,8 @@ struct vout_thread_sys_t
>
> /* */
> vlc_mouse_t mouse;
> + vlc_mouse_event mouse_event;
> + void *mouse_data;
>
> /* */
> picture_pool_t *private_pool;
--
Rémi Denis-Courmont
More information about the vlc-devel
mailing list