]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/esd.c
Fix memleak in esp audio output.
[vlc] / modules / audio_output / esd.c
index 7b96a48555b2efefa1226909c8e07a172545b734..b56b99cb9890facf6927a0e228a3700306096683 100644 (file)
  * Preamble
  *****************************************************************************/
 #include <errno.h>                                                 /* ENOMEM */
-#include <string.h>                                            /* strerror() */
 #include <unistd.h>                                      /* write(), close() */
-#include <stdlib.h>                            /* calloc(), malloc(), free() */
 
-#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 <sys/socket.h>
@@ -64,10 +67,10 @@ static void Play         ( aout_instance_t * );
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("EsounD audio output") );
+    set_description( N_("EsounD audio output") );
     set_shortname( "EsounD" );
     set_capability( "audio output", 50 );
-    add_string( "esdserver", "", NULL, N_("Esound server"), NULL, VLC_FALSE );
+    add_string( "esdserver", "", NULL, N_("Esound server"), NULL, false );
     set_category( CAT_AUDIO );
     set_subcategory( SUBCAT_AUDIO_AOUT );
     set_callbacks( Open, Close );
@@ -88,10 +91,7 @@ static int Open( vlc_object_t *p_this )
     /* Allocate structure */
     p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
 
     p_aout->output.p_sys = p_sys;
 
@@ -146,6 +146,7 @@ static int Open( vlc_object_t *p_this )
     {
         msg_Err( p_aout, "cannot open esound socket (format 0x%08x at %d Hz)",
                          p_sys->esd_format, p_aout->output.output.i_rate );
+        free( psz_server );
         free( p_sys );
         return VLC_EGENERIC;
     }
@@ -180,6 +181,7 @@ static int Open( vlc_object_t *p_this )
       / p_aout->output.output.i_bytes_per_frame
       / p_aout->output.output.i_rate;
 
+    free( psz_server );
     close( i_newfd );
     return VLC_SUCCESS;
 }
@@ -206,7 +208,7 @@ static void Play( aout_instance_t *p_aout )
             i_tmp = write( p_sys->i_fd, data + pos, ESD_BUF_SIZE );
             if( i_tmp < 0 )
             {
-                msg_Err( p_aout, "write failed (%s)", strerror(errno) );
+                msg_Err( p_aout, "write failed (%m)" );
             }
         }
         aout_BufferFree( p_buffer );
@@ -231,7 +233,7 @@ static void Close( vlc_object_t *p_this )
  *****************************************************************************
  * This function writes a buffer of i_length bytes in the socket
  *****************************************************************************/
-static void Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
+static void Play( aout_thread_t *p_aout, uint8_t *buffer, int i_size )
 {
     int i_amount;