]> git.sesse.net Git - vlc/blobdiff - modules/visualization/goom.c
transcode: fix audio format given to filters (fixes #8385)
[vlc] / modules / visualization / goom.c
index 4d5ea6c32fa9e3f0e3a6d53b4e86443b476c181e..11f09a654e183ab06ef812175d26bb3b62d7a2d0 100644 (file)
@@ -33,7 +33,6 @@
 #include <vlc_plugin.h>
 #include <vlc_aout.h>            /* aout_FormatNbChannels, AOUT_FMTS_SIMILAR */
 #include <vlc_vout.h>              /* vout_*Picture, aout_filter_RequestVout */
-#include <vlc_playlist.h>              /* playlist_CurrentInput, input*Title */
 
 #include <goom/goom.h>
 
@@ -59,12 +58,12 @@ vlc_module_begin ()
     set_description( N_("Goom effect") )
     set_category( CAT_AUDIO )
     set_subcategory( SUBCAT_AUDIO_VISUAL )
-    set_capability( "visualization2", 0 )
+    set_capability( "visualization", 0 )
     add_integer( "goom-width", 800,
                  WIDTH_TEXT, RES_LONGTEXT, false )
-    add_integer( "goom-height", 640,
+    add_integer( "goom-height", 500,
                  HEIGHT_TEXT, RES_LONGTEXT, false )
-    add_integer( "goom-speed", 6,
+    add_integer_with_range( "goom-speed", 6, 1, 10,
                  SPEED_TEXT, SPEED_LONGTEXT, false )
     set_callbacks( Open, Close )
     add_shortcut( "goom" )
@@ -85,8 +84,6 @@ typedef struct
     vout_thread_t *p_vout;
     int           i_speed;
 
-    char          *psz_title;
-
     vlc_mutex_t   lock;
     vlc_cond_t    wait;
     bool          b_exit;
@@ -112,8 +109,6 @@ static block_t *DoWork ( filter_t *, block_t * );
 
 static void *Thread( void * );
 
-static char *TitleGet( vlc_object_t * );
-
 /*****************************************************************************
  * Open: open a scope effect plugin
  *****************************************************************************/
@@ -124,21 +119,6 @@ static int Open( vlc_object_t *p_this )
     goom_thread_t  *p_thread;
     video_format_t fmt;
 
-
-    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->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_audio_filter = DoWork;
-
     /* Allocate structure */
     p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
 
@@ -172,25 +152,25 @@ 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->fmt_out.audio.i_rate, 1 );
+    date_Init( &p_thread->date, p_filter->fmt_in.audio.i_rate, 1 );
     date_Set( &p_thread->date, 0 );
     p_thread->i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
 
-    p_thread->psz_title = TitleGet( VLC_OBJECT( p_filter ) );
-
     if( vlc_clone( &p_thread->thread,
                    Thread, p_thread, VLC_THREAD_PRIORITY_LOW ) )
     {
         msg_Err( p_filter, "cannot lauch goom thread" );
-        vlc_object_release( p_thread->p_vout );
         vlc_mutex_destroy( &p_thread->lock );
         vlc_cond_destroy( &p_thread->wait );
-        free( p_thread->psz_title );
+        aout_filter_RequestVout( p_filter, p_thread->p_vout, NULL );
         free( p_thread );
         free( p_sys );
         return VLC_EGENERIC;
     }
 
+    p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32;
+    p_filter->fmt_out.audio = p_filter->fmt_in.audio;
+    p_filter->pf_audio_filter = DoWork;
     return VLC_SUCCESS;
 }
 
@@ -212,7 +192,7 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
         return p_in_buf;
     }
 
-    p_block = block_New( p_sys->p_thread, p_in_buf->i_buffer );
+    p_block = block_Alloc( p_in_buf->i_buffer );
     if( !p_block )
     {
         vlc_mutex_unlock( &p_sys->p_thread->lock );
@@ -344,10 +324,7 @@ static void *Thread( void *p_thread_data )
         if( date_Get( &i_pts ) + GOOM_DELAY <= mdate() ) continue;
 
         plane = goom_update( p_plugin_info, p_data, 0, 0.0,
-                             p_thread->psz_title, NULL );
-
-        free( p_thread->psz_title );
-        p_thread->psz_title = NULL;
+                             NULL, NULL );
 
         while( !( p_pic = vout_GetPicture( p_thread->p_vout ) ) )
         {
@@ -389,7 +366,7 @@ static void Close( vlc_object_t *p_this )
     vlc_join( p_sys->p_thread->thread, NULL );
 
     /* Free data */
-    aout_filter_RequestVout( p_filter, p_sys->p_thread->p_vout, 0 );
+    aout_filter_RequestVout( p_filter, p_sys->p_thread->p_vout, NULL );
     vlc_mutex_destroy( &p_sys->p_thread->lock );
     vlc_cond_destroy( &p_sys->p_thread->wait );
 
@@ -403,27 +380,3 @@ static void Close( vlc_object_t *p_this )
     free( p_sys );
 }
 
-static char *TitleGet( vlc_object_t *p_this )
-{
-    input_thread_t *p_input = playlist_CurrentInput( pl_Get( p_this ) );
-    if( !p_input )
-        return NULL;
-
-    char *psz_title = input_item_GetTitle( input_GetItem( p_input ) );
-    if( EMPTY_STR( psz_title ) )
-    {
-        free( psz_title );
-
-        char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
-        const char *psz = strrchr( psz_uri, '/' );
-        if( psz )
-        {
-            psz_title = strdup( psz + 1 );
-            free( psz_uri );
-        }
-        else
-            psz_title = psz_uri;
-    }
-    vlc_object_release( p_input );
-    return psz_title;
-}