]> git.sesse.net Git - vlc/blobdiff - modules/audio_filter/converter/mpgatofixed32.c
Debug the timeshift granularity in MB, not Bytes...
[vlc] / modules / audio_filter / converter / mpgatofixed32.c
index c4386e3fdd9d699829129c26f135bab0b3650062..357ccb8b6c88cab7bd1dff3f5e83e2c6c58171cb 100644 (file)
@@ -12,7 +12,7 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>                                              /* strdup() */
 
 #include <mad.h>
 
-#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_block.h>
 #include "vlc_filter.h"
@@ -41,7 +44,7 @@
  *****************************************************************************/
 static int  Create    ( vlc_object_t * );
 static void Destroy   ( vlc_object_t * );
-static void DoWork    ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,  
+static void DoWork    ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
                         aout_buffer_t * );
 
 static int  OpenFilter ( vlc_object_t * );
@@ -63,21 +66,21 @@ struct filter_sys_t
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_ACODEC );
-    set_description( _("MPEG audio decoder") );
-    set_capability( "audio filter", 100 );
-    set_callbacks( Create, Destroy );
-
-    add_submodule();
-    set_description( _("MPEG audio decoder") );
-    set_capability( "audio filter2", 100 );
-    set_callbacks( OpenFilter, CloseFilter );
-vlc_module_end();
+vlc_module_begin ()
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACODEC )
+    set_description( N_("MPEG audio decoder") )
+    set_capability( "audio filter", 100 )
+    set_callbacks( Create, Destroy )
+
+    add_submodule ()
+    set_description( N_("MPEG audio decoder") )
+    set_capability( "audio filter2", 100 )
+    set_callbacks( OpenFilter, CloseFilter )
+vlc_module_end ()
 
 /*****************************************************************************
- * Create: 
+ * Create:
  *****************************************************************************/
 static int Create( vlc_object_t *p_this )
 {
@@ -101,10 +104,7 @@ static int Create( vlc_object_t *p_this )
     p_sys = malloc( sizeof(filter_sys_t) );
     p_filter->p_sys = (struct aout_filter_sys_t *)p_sys;
     if( p_sys == NULL )
-    {
-        msg_Err( p_filter, "out of memory" );
         return -1;
-    }
 
     /* Initialize libmad */
     mad_stream_init( &p_sys->mad_stream );
@@ -128,7 +128,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
     filter_sys_t *p_sys = (filter_sys_t *)p_filter->p_sys;
 
     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->output );
 
     /* Do the actual decoding now. */
@@ -213,8 +213,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
             break;
 
         case 1:
-            p_filter->p_libvlc->pf_memcpy( p_samples, p_left,
-                                        i_samples * sizeof(mad_fixed_t) );
+            vlc_memcpy( p_samples, p_left, i_samples * sizeof(mad_fixed_t) );
             break;
 
         default:
@@ -298,7 +297,7 @@ static void Destroy( vlc_object_t *p_this )
 }
 
 /*****************************************************************************
- * OpenFilter: 
+ * OpenFilter:
  *****************************************************************************/
 static int OpenFilter( vlc_object_t *p_this )
 {
@@ -314,10 +313,7 @@ static int OpenFilter( vlc_object_t *p_this )
     /* Allocate the memory needed to store the module's structure */
     p_sys = p_filter->p_sys = malloc( sizeof(filter_sys_t) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_filter, "out of memory" );
         return -1;
-    }
     p_sys->i_reject_count = 0;
 
     p_filter->pf_audio_filter = Convert;
@@ -333,6 +329,8 @@ static int OpenFilter( vlc_object_t *p_this )
     else
         p_filter->fmt_out.i_codec = VLC_FOURCC('f','i','3','2');
     p_filter->fmt_out.audio.i_format = p_filter->fmt_out.i_codec;
+    p_filter->fmt_out.audio.i_bitspersample =
+        aout_BitsPerSample( p_filter->fmt_out.i_codec );
 
     p_filter->fmt_out.audio.i_rate = p_filter->fmt_in.audio.i_rate;
 
@@ -367,7 +365,8 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
 
     if( !p_block || !p_block->i_samples )
     {
-        if( p_block ) p_block->pf_release( p_block );
+        if( p_block )
+            block_Release( p_block );
         return NULL;
     }
 
@@ -379,7 +378,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     if( !p_out )
     {
         msg_Warn( p_filter, "can't get output buffer" );
-        p_block->pf_release( p_block );
+        block_Release( p_block );
         return NULL;
     }
 
@@ -395,7 +394,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     aout_filter.output.i_format = p_filter->fmt_out.i_codec;
 
     in_buf.p_buffer = p_block->p_buffer;
-    in_buf.b_discontinuity = VLC_FALSE;
+    in_buf.b_discontinuity = false;
     in_buf.i_nb_bytes = p_block->i_buffer;
     in_buf.i_nb_samples = p_block->i_samples;
     out_buf.p_buffer = p_out->p_buffer;
@@ -404,7 +403,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
 
     DoWork( (aout_instance_t *)p_filter, &aout_filter, &in_buf, &out_buf );
 
-    p_block->pf_release( p_block );
+    block_Release( p_block );
 
     p_out->i_buffer = out_buf.i_nb_bytes;
     p_out->i_samples = out_buf.i_nb_samples;