[vlc-commits] visualization filters: use a typed close callback in the operations structure

Steve Lhomme git at videolan.org
Mon Oct 12 15:56:14 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct  9 12:54:10 2020 +0200| [6806b49b226b5e019f54549c1e0dcd12146ca3c3] | committer: Steve Lhomme

visualization filters: use a typed close callback in the operations structure

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

 modules/visualization/glspectrum.c    | 9 ++++-----
 modules/visualization/goom.c          | 8 ++++----
 modules/visualization/projectm.cpp    | 7 +++----
 modules/visualization/visual/visual.c | 8 ++++----
 modules/visualization/vsxu.cpp        | 8 ++++----
 5 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/modules/visualization/glspectrum.c b/modules/visualization/glspectrum.c
index 3e8b878197..f97c711a26 100644
--- a/modules/visualization/glspectrum.c
+++ b/modules/visualization/glspectrum.c
@@ -51,7 +51,7 @@
  * Module descriptor
  *****************************************************************************/
 static int Open(vlc_object_t *);
-static void Close(vlc_object_t *);
+static void Close(filter_t *);
 
 #define WIDTH_TEXT N_("Video width")
 #define WIDTH_LONGTEXT N_("The width of the visualization window, in pixels.")
@@ -70,7 +70,7 @@ vlc_module_begin()
     add_integer("glspectrum-height", 300, HEIGHT_TEXT, HEIGHT_LONGTEXT, false)
 
     add_shortcut("glspectrum")
-    set_callbacks(Open, Close)
+    set_callback(Open)
 vlc_module_end()
 
 
@@ -112,7 +112,7 @@ const GLfloat lightZeroColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
 const GLfloat lightZeroPosition[] = {0.0f, 3.0f, 10.0f, 0.0f};
 
 static const struct vlc_filter_operations filter_ops = {
-    .filter_audio = DoWork,
+    .filter_audio = DoWork, .close = Close,
 };
 
 /**
@@ -174,9 +174,8 @@ static int Open(vlc_object_t * p_this)
  * Close the module.
  * @param p_this: the filter object
  */
-static void Close(vlc_object_t *p_this)
+static void Close(filter_t *p_filter)
 {
-    filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     /* Terminate the thread. */
diff --git a/modules/visualization/goom.c b/modules/visualization/goom.c
index eeeeae90cf..69450e73f7 100644
--- a/modules/visualization/goom.c
+++ b/modules/visualization/goom.c
@@ -41,7 +41,7 @@
  * Module descriptor
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );
-static void Close        ( vlc_object_t * );
+static void Close        ( filter_t * );
 
 #define WIDTH_TEXT N_("Goom display width")
 #define HEIGHT_TEXT N_("Goom display height")
@@ -66,7 +66,7 @@ vlc_module_begin ()
                  HEIGHT_TEXT, RES_LONGTEXT, false )
     add_integer_with_range( "goom-speed", 6, 1, 10,
                  SPEED_TEXT, SPEED_LONGTEXT, false )
-    set_callbacks( Open, Close )
+    set_callback( Open )
     add_shortcut( "goom" )
 vlc_module_end ()
 
@@ -107,6 +107,7 @@ static void *Thread( void * );
 static const struct vlc_filter_operations filter_ops = {
     .filter_audio = DoWork,
     .flush = Flush,
+    .close = Close,
 };
 
 /*****************************************************************************
@@ -340,9 +341,8 @@ static void *Thread( void *p_thread_data )
 /*****************************************************************************
  * Close: close the plugin
  *****************************************************************************/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
 {
-    filter_t     *p_filter = (filter_t *)p_this;
     goom_thread_t *p_thread = p_filter->p_sys;
 
     /* Stop Goom Thread */
diff --git a/modules/visualization/projectm.cpp b/modules/visualization/projectm.cpp
index b0e2d0edbb..8756ab8fe7 100644
--- a/modules/visualization/projectm.cpp
+++ b/modules/visualization/projectm.cpp
@@ -46,7 +46,7 @@
  * Module descriptor
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );
-static void Close        ( vlc_object_t * );
+static void Close        ( filter_t * );
 
 #define CONFIG_TEXT N_("projectM configuration file")
 #define CONFIG_LONGTEXT N_("File that will be used to configure the projectM " \
@@ -124,7 +124,7 @@ vlc_module_begin ()
     add_integer( "projectm-texture-size", 1024, TEXTURE_TEXT, TEXTURE_LONGTEXT,
                  false )
     add_shortcut( "projectm" )
-    set_callbacks( Open, Close )
+    set_callback( Open )
 vlc_module_end ()
 
 
@@ -221,9 +221,8 @@ error:
  * Close the module
  * @param p_this: the filter object
  */
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
 {
-    filter_t  *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = reinterpret_cast<filter_sys_t *>( p_filter->p_sys );
 
     /* Stop the thread
diff --git a/modules/visualization/visual/visual.c b/modules/visualization/visual/visual.c
index 21c34ad945..c3591944ad 100644
--- a/modules/visualization/visual/visual.c
+++ b/modules/visualization/visual/visual.c
@@ -112,7 +112,7 @@
 #define VOUT_HEIGHT 500
 
 static int  Open         ( vlc_object_t * );
-static void Close        ( vlc_object_t * );
+static void Close        ( filter_t * );
 
 vlc_module_begin ()
     set_shortname( N_("Visualizer"))
@@ -166,7 +166,7 @@ vlc_module_begin ()
     add_integer("spect-peak-height", 1,
              PEAK_HEIGHT_TEXT, PEAK_HEIGHT_LONGTEXT, true )
     set_capability( "visualization", 0 )
-    set_callbacks( Open, Close )
+    set_callback( Open )
     add_shortcut( "visualizer")
 vlc_module_end ()
 
@@ -191,6 +191,7 @@ typedef struct
 static const struct vlc_filter_operations filter_ops = {
     .filter_audio = DoWork,
     .flush = Flush,
+    .close = Close,
 };
 
 /*****************************************************************************
@@ -403,9 +404,8 @@ static void Flush( filter_t *p_filter )
 /*****************************************************************************
  * Close: close the plugin
  *****************************************************************************/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t * p_filter )
 {
-    filter_t * p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     vlc_queue_Kill(&p_sys->queue, &p_sys->dead);
diff --git a/modules/visualization/vsxu.cpp b/modules/visualization/vsxu.cpp
index 9abea745da..42a09552df 100644
--- a/modules/visualization/vsxu.cpp
+++ b/modules/visualization/vsxu.cpp
@@ -46,7 +46,7 @@
  * Module descriptor
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );
-static void Close        ( vlc_object_t * );
+static void Close        ( filter_t * );
 
 #define WIDTH_TEXT N_("Video width")
 #define WIDTH_LONGTEXT N_("The width of the video window, in pixels.")
@@ -65,7 +65,7 @@ vlc_module_begin ()
     add_integer( "vsxu-height", 800, HEIGHT_TEXT, HEIGHT_LONGTEXT,
                  false )
     add_shortcut( "vsxu" )
-    set_callbacks( Open, Close )
+    set_callback( Open )
 vlc_module_end ()
 
 
@@ -102,6 +102,7 @@ static const struct FilterOperationInitializer {
     FilterOperationInitializer()
     {
         ops.filter_audio = DoWork;
+        ops.close = Close;
     };
 } filter_ops;
 
@@ -162,9 +163,8 @@ error:
  * Close the module
  * @param p_this: the filter object
  */
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
 {
-    filter_t  *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
     vlc_mutex_lock( &p_sys->lock );



More information about the vlc-commits mailing list