]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/jack.c
Use <vlc_cpu.h>
[vlc] / modules / audio_output / jack.c
index e1d10c8f45a4aa71e195c40c4af57d52b0f1a4cf..a88128d5e61bab7016faf1e445a3f35955886c9e 100644 (file)
  *****************************************************************************/
 #include <unistd.h>                                      /* write(), close() */
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_aout.h>
 
 #include <jack/jack.h>
@@ -74,20 +79,18 @@ static int  Process      ( jack_nframes_t i_frames, void *p_arg );
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_shortname( "JACK" );
-    set_description( _("JACK audio output") );
-    set_capability( "audio output", 100 );
-    set_category( CAT_AUDIO );
-    set_subcategory( SUBCAT_AUDIO_AOUT );
-    add_bool( AUTO_CONNECT_OPTION, 0, NULL, AUTO_CONNECT_TEXT,
-              AUTO_CONNECT_LONGTEXT, VLC_TRUE );
-        change_safe();
+vlc_module_begin ()
+    set_shortname( "JACK" )
+    set_description( N_("JACK audio output") )
+    set_capability( "audio output", 100 )
+    set_category( CAT_AUDIO )
+    set_subcategory( SUBCAT_AUDIO_AOUT )
+    add_bool( AUTO_CONNECT_OPTION, false, NULL, AUTO_CONNECT_TEXT,
+              AUTO_CONNECT_LONGTEXT, true )
     add_string( CONNECT_REGEX_OPTION, NULL, NULL, CONNECT_REGEX_TEXT,
-                CONNECT_REGEX_LONGTEXT, VLC_TRUE );
-        change_safe();
-    set_callbacks( Open, Close );
-vlc_module_end();
+                CONNECT_REGEX_LONGTEXT, true )
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 /*****************************************************************************
  * Open: create a JACK client
@@ -105,7 +108,6 @@ static int Open( vlc_object_t *p_this )
     p_sys = calloc( 1, sizeof( aout_sys_t ) );
     if( p_sys == NULL )
     {
-        msg_Err( p_aout, "out of memory" );
         status = VLC_ENOMEM;
         goto error_out;
     }
@@ -129,7 +131,7 @@ static int Open( vlc_object_t *p_this )
     aout_VolumeSoftInit( p_aout );
 
     /* JACK only supports fl32 format */
-    p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2');
+    p_aout->output.output.i_format = VLC_CODEC_FL32;
     // TODO add buffer size callback
     p_aout->output.i_nb_samples = jack_get_buffer_size( p_sys->p_jack_client );
     p_aout->output.output.i_rate = jack_get_sample_rate( p_sys->p_jack_client );
@@ -140,7 +142,6 @@ static int Open( vlc_object_t *p_this )
                                   sizeof(jack_port_t *) );
     if( p_sys->p_jack_ports == NULL )
     {
-        msg_Err( p_aout, "out of memory" );
         status = VLC_ENOMEM;
         goto error_out;
     }
@@ -149,7 +150,6 @@ static int Open( vlc_object_t *p_this )
                                     sizeof(jack_sample_t *) );
     if( p_sys->p_jack_buffers == NULL )
     {
-        msg_Err( p_aout, "out of memory" );
         status = VLC_ENOMEM;
         goto error_out;
     }
@@ -187,6 +187,7 @@ static int Open( vlc_object_t *p_this )
         const char **pp_in_ports = jack_get_ports( p_sys->p_jack_client,
                                                    psz_regex, NULL,
                                                    JackPortIsInput );
+        free( psz_regex );
         /* Count the number of returned ports */
         i_in_ports = 0;
         while( pp_in_ports && pp_in_ports[i_in_ports] )
@@ -212,10 +213,7 @@ static int Open( vlc_object_t *p_this )
                          psz_out, psz_in );
             }
         }
-        if( pp_in_ports )
-        {
-            free( pp_in_ports );
-        }
+        free( pp_in_ports );
     }
 
     msg_Dbg( p_aout, "JACK audio output initialized (%d channels, buffer "
@@ -231,14 +229,8 @@ error_out:
             jack_deactivate( p_sys->p_jack_client );
             jack_client_close( p_sys->p_jack_client );
         }
-        if( p_sys->p_jack_ports )
-        {
-            free( p_sys->p_jack_ports );
-        }
-        if( p_sys->p_jack_buffers )
-        {
-            free( p_sys->p_jack_buffers );
-        }
+        free( p_sys->p_jack_ports );
+        free( p_sys->p_jack_buffers );
         free( p_sys );
     }
     return status;