]> git.sesse.net Git - vlc/commitdiff
DJ's first steps in C and vlc decoders ;)
authorDerk-Jan Hartman <hartman@videolan.org>
Fri, 21 Feb 2003 16:31:37 +0000 (16:31 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Fri, 21 Feb 2003 16:31:37 +0000 (16:31 +0000)
* modules/audio_filter/converter/mpgatofixed32.c:
  - fixed an issue that could cause glitches when switching from one stream
    to another. the buffer wasn't entirely getting 0000 because multiple
    channels were not taken into account when doing this.
* ALL:
  - if float32 then clear the buffer with (float)0

modules/audio_filter/converter/mpgatofixed32.c
modules/gui/macosx/aout.m

index 3b4ddabe7d9cf8aa64a6d9b99e008716005d0b9c..728ceeb4d9502be999f14cd0913fff9e434e29c4 100644 (file)
@@ -3,7 +3,7 @@
  * using MAD (MPEG Audio Decoder)
  *****************************************************************************
  * Copyright (C) 2001 by Jean-Paul Saman
- * $Id: mpgatofixed32.c,v 1.6 2003/02/21 15:16:52 hartman Exp $
+ * $Id: mpgatofixed32.c,v 1.7 2003/02/21 16:31:37 hartman Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Jean-Paul Saman <jpsaman@wxs.nl>
@@ -114,7 +114,8 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
 
 
     p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
-    p_out_buf->i_nb_bytes = p_in_buf->i_nb_samples * sizeof(vlc_fixed_t);
+    p_out_buf->i_nb_bytes = p_in_buf->i_nb_samples * sizeof(vlc_fixed_t) * 
+                               aout_FormatNbChannels( &p_filter->input );
 
     /* Do the actual decoding now. */
     mad_stream_buffer( &p_sys->mad_stream, p_in_buf->p_buffer,
@@ -123,7 +124,20 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
     {
         msg_Warn( p_aout, "libmad error: %s",
                   mad_stream_errorstr( &p_sys->mad_stream ) );
-        memset( p_out_buf->p_buffer, 0, p_out_buf->i_nb_bytes );
+        if( p_filter->output.i_format == VLC_FOURCC('f','l','3','2') )
+        {
+            int i;
+            int i_size = p_out_buf->i_nb_bytes / sizeof(float);
+            
+            float * a = (float *)p_out_buf->p_buffer;
+            for ( i = 0 ; i < i_size ; i++ )
+                *a++ = 0.0;
+        }
+        else
+        {
+            memset( p_out_buf->p_buffer, 0, p_out_buf->i_nb_bytes );
+        }
+        return;
     }
     mad_synth_frame( &p_sys->mad_synth, &p_sys->mad_frame );
 
index 9b89e9a8bc795facf472e4c0ae6ac086b6a12b09..e3471c40a3622439a92ded60cd54cd68c87f1ca0 100644 (file)
@@ -2,7 +2,7 @@
  * aout.m: CoreAudio output plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: aout.m,v 1.22 2003/01/21 00:47:43 jlj Exp $
+ * $Id: aout.m,v 1.23 2003/02/21 16:31:37 hartman Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
@@ -468,8 +468,20 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
     }
     else
     {
-        memset( outOutputData->mBuffers[ 0 ].mData, 
+        if( p_aout->output.output.i_format == VLC_FOURCC('f','l','3','2') )
+        {
+            int i;
+            int i_size = p_sys->i_buffer_size / sizeof(float);
+            
+            float * a = (float *)outOutputData->mBuffers[ 0 ].mData;
+            for ( i = 0 ; i < i_size ; i++ )
+                *a++ = 0.0;
+        }
+        else
+        {
+            memset( outOutputData->mBuffers[ 0 ].mData, 
                 0, p_sys->i_buffer_size );
+        }
     }
 
     return( noErr );