]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/file.c
Remove useless test before a free()
[vlc] / modules / audio_output / file.c
index 788671ff4a84664f505fdecb2f8ce1c9260a0074..c21300609d399f74adb88699b3b8a1cccddf904a 100644 (file)
  *****************************************************************************/
 #include <errno.h>
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 #include <vlc_aout.h>
 #include <vlc_codecs.h> /* WAVEHEADER */
@@ -101,7 +105,7 @@ static int format_int[] = { VLC_FOURCC('u','8',' ',' '),
                             VLC_FOURCC('s','p','i','f') };
 
 #define FILE_TEXT N_("Output file")
-#define FILE_LONGTEXT N_("File to which the audio samples will be written to.")
+#define FILE_LONGTEXT N_("File to which the audio samples will be written to. (\"-\" for stdout")
 
 vlc_module_begin();
     set_description( _("File audio output") );
@@ -142,7 +146,7 @@ static int Open( vlc_object_t * p_this )
     if( !psz_name || !*psz_name )
     {
         msg_Err( p_aout, "you need to specify an output file name" );
-        if( psz_name ) free( psz_name );
+        free( psz_name );
         return VLC_EGENERIC;
     }
 
@@ -154,7 +158,11 @@ static int Open( vlc_object_t * p_this )
         return VLC_EGENERIC;
     }
 
-    p_aout->output.p_sys->p_file = utf8_fopen( psz_name, "wb" );
+    if( !strcmp( psz_name, "-" ) )
+        p_aout->output.p_sys->p_file = stdout;
+    else
+        p_aout->output.p_sys->p_file = utf8_fopen( psz_name, "wb" );
+
     free( psz_name );
     if ( p_aout->output.p_sys->p_file == NULL )
     {
@@ -182,7 +190,8 @@ static int Open( vlc_object_t * p_this )
     {
         msg_Err( p_aout, "cannot understand the format string (%s)",
                  psz_format );
-        fclose( p_aout->output.p_sys->p_file );
+        if( p_aout->output.p_sys->p_file != stdout )
+            fclose( p_aout->output.p_sys->p_file );
         free( p_aout->output.p_sys );
         return VLC_EGENERIC;
     }
@@ -309,7 +318,8 @@ static void Close( vlc_object_t * p_this )
         }
     }
 
-    fclose( p_aout->output.p_sys->p_file );
+    if( p_aout->output.p_sys->p_file != stdout )
+        fclose( p_aout->output.p_sys->p_file );
     free( p_aout->output.p_sys );
 }