]> git.sesse.net Git - vlc/blobdiff - modules/visualization/goom.c
Remove useless <errno.h> inclusions
[vlc] / modules / visualization / goom.c
index c2ae3a25a8db4ce12a616a0db3c471716cc9abae..6d93663273913c7c63ffdca03f40cdf946b2e5e0 100644 (file)
@@ -25,8 +25,6 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>
-
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
@@ -37,6 +35,7 @@
 #include <vlc_vout.h>
 #include <vlc_block.h>
 #include <vlc_input.h>
+#include <vlc_filter.h>
 
 #ifdef USE_GOOM_TREE
 #   ifdef OLD_GOOM
@@ -74,7 +73,7 @@ vlc_module_begin ()
     set_description( N_("Goom effect") )
     set_category( CAT_AUDIO )
     set_subcategory( SUBCAT_AUDIO_VISUAL )
-    set_capability( "visualization", 0 )
+    set_capability( "visualization2", 0 )
     add_integer( "goom-width", 800, NULL,
                  WIDTH_TEXT, RES_LONGTEXT, false )
     add_integer( "goom-height", 640, NULL,
@@ -112,14 +111,13 @@ typedef struct
 
 } goom_thread_t;
 
-struct aout_filter_sys_t
+struct filter_sys_t
 {
     goom_thread_t *p_thread;
 
 };
 
-static void DoWork   ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
-                       aout_buffer_t * );
+static block_t *DoWork ( filter_t *, block_t * );
 
 static void* Thread   ( vlc_object_t * );
 
@@ -130,30 +128,29 @@ static char *TitleGet( vlc_object_t * );
  *****************************************************************************/
 static int Open( vlc_object_t *p_this )
 {
-    aout_filter_t     *p_filter = (aout_filter_t *)p_this;
-    aout_filter_sys_t *p_sys;
-    goom_thread_t     *p_thread;
-    int                width, height;
-    video_format_t     fmt;
+    filter_t       *p_filter = (filter_t *)p_this;
+    filter_sys_t   *p_sys;
+    goom_thread_t  *p_thread;
+    int             width, height;
+    video_format_t fmt;
 
 
-    if( p_filter->input.i_format != VLC_CODEC_FL32 ||
-         p_filter->output.i_format != VLC_CODEC_FL32 )
+    if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32 ||
+         p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 )
     {
         msg_Warn( p_filter, "bad input or output format" );
         return VLC_EGENERIC;
     }
-    if( !AOUT_FMTS_SIMILAR( &p_filter->input, &p_filter->output ) )
+    if( !AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) )
     {
         msg_Warn( p_filter, "input and output formats are not similar" );
         return VLC_EGENERIC;
     }
 
-    p_filter->pf_do_work = DoWork;
-    p_filter->b_in_place = 1;
+    p_filter->pf_audio_filter = DoWork;
 
     /* Allocate structure */
-    p_sys = p_filter->p_sys = malloc( sizeof( aout_filter_sys_t ) );
+    p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
 
     /* Create goom thread */
     p_sys->p_thread = p_thread =
@@ -168,7 +165,6 @@ static int Open( vlc_object_t *p_this )
     fmt.i_width = fmt.i_visible_width = width;
     fmt.i_height = fmt.i_visible_height = height;
     fmt.i_chroma = VLC_CODEC_RGB32;
-    fmt.i_aspect = VOUT_ASPECT_FACTOR * width/height;
     fmt.i_sar_num = fmt.i_sar_den = 1;
 
     p_thread->p_vout = aout_filter_RequestVout( p_filter, NULL, &fmt );
@@ -184,9 +180,9 @@ static int Open( vlc_object_t *p_this )
     vlc_cond_init( &p_thread->wait );
 
     p_thread->i_blocks = 0;
-    date_Init( &p_thread->date, p_filter->output.i_rate, 1 );
+    date_Init( &p_thread->date, p_filter->fmt_out.audio.i_rate, 1 );
     date_Set( &p_thread->date, 0 );
-    p_thread->i_channels = aout_FormatNbChannels( &p_filter->input );
+    p_thread->i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
 
     p_thread->psz_title = TitleGet( VLC_OBJECT( p_filter ) );
 
@@ -212,38 +208,34 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************
  * This function queues the audio buffer to be processed by the goom thread
  *****************************************************************************/
-static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
-                    aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
+static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
 {
-    VLC_UNUSED( p_aout );
-
-    aout_filter_sys_t *p_sys = p_filter->p_sys;
+    filter_sys_t *p_sys = p_filter->p_sys;
     block_t *p_block;
 
-    p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
-    p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes;
-
     /* Queue sample */
     vlc_mutex_lock( &p_sys->p_thread->lock );
     if( p_sys->p_thread->i_blocks == MAX_BLOCKS )
     {
         vlc_mutex_unlock( &p_sys->p_thread->lock );
-        return;
+        return p_in_buf;
     }
 
-    p_block = block_New( p_sys->p_thread, p_in_buf->i_nb_bytes );
+    p_block = block_New( p_sys->p_thread, p_in_buf->i_buffer );
     if( !p_block )
     {
         vlc_mutex_unlock( &p_sys->p_thread->lock );
-        return;
+        return p_in_buf;
     }
-    memcpy( p_block->p_buffer, p_in_buf->p_buffer, p_in_buf->i_nb_bytes );
-    p_block->i_pts = p_in_buf->start_date;
+    memcpy( p_block->p_buffer, p_in_buf->p_buffer, p_in_buf->i_buffer );
+    p_block->i_pts = p_in_buf->i_pts;
 
     p_sys->p_thread->pp_blocks[p_sys->p_thread->i_blocks++] = p_block;
 
     vlc_cond_signal( &p_sys->p_thread->wait );
     vlc_mutex_unlock( &p_sys->p_thread->lock );
+
+    return p_in_buf;
 }
 
 /*****************************************************************************
@@ -278,12 +270,12 @@ static int FillBuffer( int16_t *p_data, int *pi_data,
                 p_block->i_buffer / sizeof(float) / p_this->i_channels );
 
         /* Date management */
-        if( p_block->i_pts > 0 &&
+        if( p_block->i_pts > VLC_TS_INVALID &&
             p_block->i_pts != date_Get( pi_date_end ) )
         {
            date_Set( pi_date_end, p_block->i_pts );
         }
-        p_block->i_pts = 0;
+        p_block->i_pts = VLC_TS_INVALID;
 
         date_Increment( pi_date_end, i_samples );
 
@@ -386,8 +378,8 @@ static void* Thread( vlc_object_t *p_this )
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
 {
-    aout_filter_t     *p_filter = (aout_filter_t *)p_this;
-    aout_filter_sys_t *p_sys = p_filter->p_sys;
+    filter_t     *p_filter = (filter_t *)p_this;
+    filter_sys_t *p_sys = p_filter->p_sys;
 
     /* Stop Goom Thread */
     vlc_object_kill( p_sys->p_thread );