]> git.sesse.net Git - vlc/blobdiff - modules/codec/araw.c
Don't print a message a malloc failed.
[vlc] / modules / codec / araw.c
index 3213963ab3574f1c93c129dfc2190a2a7c2a3b9f..e75e2d4dcc84c794738504f1da90c1c61fcc9a78 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#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 <vlc_codec.h>
 
@@ -41,7 +46,7 @@ static void EncoderClose( vlc_object_t * );
 
 vlc_module_begin();
     /* audio decoder module */
-    set_description( _("Raw/Log Audio decoder") );
+    set_description( N_("Raw/Log Audio decoder") );
     set_capability( "decoder", 100 );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_ACODEC );
@@ -50,7 +55,7 @@ vlc_module_begin();
 #ifdef ENABLE_SOUT
     /* audio encoder submodule */
     add_submodule();
-    set_description( _("Raw audio encoder") );
+    set_description( N_("Raw audio encoder") );
     set_capability( "encoder", 150 );
     set_callbacks( EncoderOpen, EncoderClose );
 #endif
@@ -67,6 +72,7 @@ static block_t *EncoderEncode( encoder_t *, aout_buffer_t * );
 struct decoder_sys_t
 {
     const int16_t *p_logtos16;  /* used with m/alaw to int16_t */
+    int i_bytespersample;
 
     audio_date_t end_date;
 };
@@ -222,10 +228,7 @@ static int DecoderOpen( vlc_object_t *p_this )
     /* Allocate the memory needed to store the decoder's structure */
     if( ( p_dec->p_sys = p_sys =
           (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
-    {
-        msg_Err( p_dec, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
 
     p_sys->p_logtos16 = NULL;
 
@@ -402,6 +405,7 @@ static int DecoderOpen( vlc_object_t *p_this )
 
     aout_DateInit( &p_sys->end_date, p_dec->fmt_out.audio.i_rate );
     aout_DateSet( &p_sys->end_date, 0 );
+    p_sys->i_bytespersample = ( p_dec->fmt_in.audio.i_bitspersample + 7 ) / 8;
 
     p_dec->pf_decode_audio = DecodeBlock;
 
@@ -439,7 +443,7 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     /* Don't re-use the same pts twice */
     p_block->i_pts = 0;
 
-    i_samples = p_block->i_buffer * 8 / p_dec->fmt_in.audio.i_bitspersample /
+    i_samples = p_block->i_buffer / p_sys->i_bytespersample /
         p_dec->fmt_in.audio.i_channels;
 
     if( i_samples <= 0 )
@@ -1419,10 +1423,7 @@ static int EncoderOpen( vlc_object_t *p_this )
     /* Allocate the memory needed to store the encoder's structure */
     if( ( p_enc->p_sys = p_sys =
           (encoder_sys_t *)malloc(sizeof(encoder_sys_t)) ) == NULL )
-    {
-        msg_Err( p_enc, "out of memory" );
-        return VLC_EGENERIC;
-    }
+        return VLC_ENOMEM;
 
     p_enc->pf_encode_audio = EncoderEncode;
     p_enc->fmt_in.i_codec = p_enc->fmt_out.i_codec;
@@ -1459,7 +1460,7 @@ static int EncoderOpen( vlc_object_t *p_this )
  *****************************************************************************/
 static void EncoderClose ( vlc_object_t *p_this )
 {
-    return;
+    VLC_UNUSED(p_this);
 }
 
 /*****************************************************************************