[vlc-commits] commit: Added mouse support to sub-filter. (Laurent Aimar )

git at videolan.org git at videolan.org
Sat May 1 13:42:29 CEST 2010


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat May  1 01:31:26 2010 +0200| [72aabd946436d7ad8fe9f24a79a3da476f8fd01a] | committer: Laurent Aimar 

Added mouse support to sub-filter.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=72aabd946436d7ad8fe9f24a79a3da476f8fd01a
---

 include/vlc_filter.h                |   18 +++++++++++++++---
 src/libvlccore.sym                  |    1 +
 src/misc/filter_chain.c             |   19 +++++++++++++++++++
 src/video_output/display.c          |    3 +++
 src/video_output/vout_internal.h    |    3 +++
 src/video_output/vout_subpictures.c |   22 +++++++++++++++++++++-
 6 files changed, 62 insertions(+), 4 deletions(-)

diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index cdc6923..dd5cc29 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -101,13 +101,18 @@ struct filter_t
 
         struct
         {
-            subpicture_t * (*pf_filter) ( filter_t *, mtime_t );
-            subpicture_t * (*pf_buffer_new) ( filter_t * );
-            void        (*pf_buffer_del) ( filter_t *, subpicture_t * );
+            subpicture_t * (*pf_filter)    ( filter_t *, mtime_t );
+            subpicture_t * (*pf_buffer_new)( filter_t * );
+            void           (*pf_buffer_del)( filter_t *, subpicture_t * );
+            int            (*pf_mouse)     ( filter_t *,
+                                             const vlc_mouse_t *p_old,
+                                             const vlc_mouse_t *p_new,
+                                             const video_format_t * );
         } sub;
 #define pf_sub_filter      u.sub.pf_filter
 #define pf_sub_buffer_new  u.sub.pf_buffer_new
 #define pf_sub_buffer_del  u.sub.pf_buffer_del
+#define pf_sub_mouse       u.sub.pf_mouse
 
         struct
         {
@@ -370,5 +375,12 @@ VLC_EXPORT( void, filter_chain_SubFilter, ( filter_chain_t *, mtime_t ) );
  */
 VLC_EXPORT( int, filter_chain_MouseFilter, ( filter_chain_t *, vlc_mouse_t *, const vlc_mouse_t * ) );
 
+/**
+ * Inform the filter chain of mouse state.
+ *
+ * It makes sense only for a sub filter chain.
+ */
+VLC_EXPORT( int, filter_chain_MouseEvent, ( filter_chain_t *, const vlc_mouse_t *, const video_format_t * ) );
+
 #endif /* _VLC_FILTER_H */
 
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 2c548b6..a8479eb 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -131,6 +131,7 @@ filter_chain_DeleteFilter
 filter_chain_GetFmtOut
 filter_chain_GetLength
 filter_chain_MouseFilter
+filter_chain_MouseEvent
 filter_chain_New
 filter_chain_Reset
 filter_chain_SubFilter
diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index 01e9913..3fd4c31 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -284,6 +284,25 @@ int filter_chain_MouseFilter( filter_chain_t *p_chain, vlc_mouse_t *p_dst, const
     return VLC_SUCCESS;
 }
 
+int filter_chain_MouseEvent( filter_chain_t *p_chain,
+                             const vlc_mouse_t *p_mouse,
+                             const video_format_t *p_fmt )
+{
+    for( chained_filter_t *f = p_chain->first; f != NULL; f = f->next )
+    {
+        filter_t *p_filter = &f->filter;
+
+        if( p_filter->pf_sub_mouse )
+        {
+            vlc_mouse_t old = *f->mouse;
+            *f->mouse = *p_mouse;
+            if( p_filter->pf_sub_mouse( p_filter, &old, p_mouse, p_fmt ) )
+                return VLC_EGENERIC;
+        }
+    }
+
+    return VLC_SUCCESS;
+}
 
 /* Helpers */
 static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain,
diff --git a/src/video_output/display.c b/src/video_output/display.c
index 09e2d13..6c1d1a3 100644
--- a/src/video_output/display.c
+++ b/src/video_output/display.c
@@ -1411,6 +1411,9 @@ void vout_SendDisplayEventMouse(vout_thread_t *vout, const vlc_mouse_t *m)
 {
     vlc_mouse_t tmp;
 
+    if (spu_ProcessMouse( vout->p->p_spu, m, &vout->fmt_out))
+        return;
+
     vlc_mutex_lock( &vout->p->vfilter_lock );
     if (vout->p->p_vf2_chain) {
         if (!filter_chain_MouseFilter(vout->p->p_vf2_chain, &tmp, m))
diff --git a/src/video_output/vout_internal.h b/src/video_output/vout_internal.h
index c23d276..c9b2ea3 100644
--- a/src/video_output/vout_internal.h
+++ b/src/video_output/vout_internal.h
@@ -161,5 +161,8 @@ int  vout_ManageWrapper(vout_thread_t *);
 void vout_RenderWrapper(vout_thread_t *, picture_t *);
 void vout_DisplayWrapper(vout_thread_t *, picture_t *);
 
+/* */
+int spu_ProcessMouse(spu_t *, const vlc_mouse_t *, const video_format_t *);
+
 #endif
 
diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index a4e7c60..adef7e9 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -88,6 +88,7 @@ struct spu_private_t
 
     /* Subpiture filters */
     char           *psz_chain_update;
+    vlc_mutex_t    chain_lock;
     filter_chain_t *p_chain;
 
     /* */
@@ -226,6 +227,7 @@ spu_t *spu_Create( vlc_object_t *p_this )
     p_sys->i_channel = 2;
 
     p_sys->psz_chain_update = NULL;
+    vlc_mutex_init( &p_sys->chain_lock );
     p_sys->p_chain = filter_chain_New( p_spu, "sub filter", false,
                                        SubFilterAllocationInit,
                                        SubFilterAllocationClean,
@@ -279,6 +281,7 @@ void spu_Destroy( spu_t *p_spu )
         FilterRelease( p_sys->p_scale );
 
     filter_chain_Delete( p_sys->p_chain );
+    vlc_mutex_destroy( &p_sys->chain_lock );
     free( p_sys->psz_chain_update );
 
     /* Destroy all remaining subpictures */
@@ -327,6 +330,22 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
 }
 
 /**
+ * Inform the SPU filters of mouse event
+ */
+int spu_ProcessMouse( spu_t *p_spu,
+                      const vlc_mouse_t *p_mouse,
+                      const video_format_t *p_fmt )
+{
+    spu_private_t *p_sys = p_spu->p;
+
+    vlc_mutex_lock( &p_sys->chain_lock );
+    filter_chain_MouseEvent( p_sys->p_chain, p_mouse, p_fmt );
+    vlc_mutex_unlock( &p_sys->chain_lock );
+
+    return VLC_SUCCESS;
+}
+
+/**
  * Display a subpicture
  *
  * Remove the reservation flag of a subpicture, which will cause it to be
@@ -552,6 +571,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_subtitle_date,
     p_sys->psz_chain_update = NULL;
     vlc_mutex_unlock( &p_sys->lock );
 
+    vlc_mutex_lock( &p_sys->chain_lock );
     if( psz_chain_update )
     {
         filter_chain_Reset( p_sys->p_chain, NULL, NULL );
@@ -560,9 +580,9 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_subtitle_date,
 
         free( psz_chain_update );
     }
-
     /* Run subpicture filters */
     filter_chain_SubFilter( p_sys->p_chain, render_osd_date );
+    vlc_mutex_unlock( &p_sys->chain_lock );
 
     vlc_mutex_lock( &p_sys->lock );
 



More information about the vlc-commits mailing list