[vlc-devel] [PATCH] jack audio output

Julien Plissonneau Duquène julien.plissonneau.duquene at savoirfairelinux.com
Tue Apr 24 03:26:01 CEST 2007


Hi,

When jack_client_new fails, the code currently in svn head will jump to
error handling and will try to free p_sys->p_jack_ports, but the pointer
is not intialized yet (crash). This is fixed by using calloc instead of
malloc for p_sys.

It would be nice to have something to distinguish the client name in
jack, as several VLC instances may be launched simultaneously. This is
fixed below by adding the PID to the client name when registering with
jack.

In the process renamed p_name to psz_name to follow code conventions.

Index: modules/audio_output/jack.c
===================================================================
--- modules/audio_output/jack.c (revision 19922)
+++ modules/audio_output/jack.c (working copy)
@@ -95,11 +95,12 @@
     struct aout_sys_t *p_sys = NULL;
     char **pp_match_ports = NULL;
     char *psz_prefix = NULL;
+    char psz_name[32];
     int status = VLC_SUCCESS;
     unsigned int i;

     /* Allocate structure */
-    p_sys = malloc( sizeof( aout_sys_t ) );
+    p_sys = calloc( 1, sizeof( aout_sys_t ) );
     if( p_sys == NULL )
     {
         msg_Err( p_aout, "out of memory" );
@@ -109,7 +110,8 @@
     p_aout->output.p_sys = p_sys;

     /* Connect to the JACK server */
-    p_sys->p_jack_client = jack_client_new( "vlc" );
+    snprintf( psz_name, 32, "vlc_%d", getpid() );
+    p_sys->p_jack_client = jack_client_new( psz_name );
     if( p_sys->p_jack_client == NULL )
     {
         msg_Err( p_aout, "failed to connect to JACK server" );
@@ -142,10 +144,9 @@
     /* Create the output ports */
     for( i = 0; i < p_sys->i_channels; i++ )
     {
-        char p_name[32];
-        snprintf( p_name, 32, "out_%d", i + 1);
+        snprintf( psz_name, 32, "out_%d", i + 1);
         p_sys->p_jack_ports[i] = jack_port_register(
p_sys->p_jack_client,
-                p_name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0 );
+                psz_name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0
);

         if( p_sys->p_jack_ports[i] == NULL )
         {


--
Julien Plissonneau Duquène


-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html



More information about the vlc-devel mailing list