]> git.sesse.net Git - vlc/commitdiff
* Changed aout_FormatTo* ; aout_FormatToSize does no longer exist.
authorChristophe Massiot <massiot@videolan.org>
Wed, 14 Aug 2002 00:23:59 +0000 (00:23 +0000)
committerChristophe Massiot <massiot@videolan.org>
Wed, 14 Aug 2002 00:23:59 +0000 (00:23 +0000)
  p_buffer now has a i_nb_bytes member. It is possible to indicate for a
  format its byterate (necessary for AC3 and SPDIF).
* S/PDIF output seems to be working at last (tested with the file output).

23 files changed:
include/aout_internal.h
include/audio_output.h
include/defs.h.in
include/vlc_symbols.h
modules/audio_filter/converter/a52tospdif.c
modules/audio_filter/converter/float32tos16.c
modules/audio_filter/converter/float32tos8.c
modules/audio_filter/converter/float32tou16.c
modules/audio_filter/converter/float32tou8.c
modules/audio_mixer/spdif.c
modules/audio_output/arts.c
modules/audio_output/esd.c
modules/audio_output/file.c
modules/audio_output/oss.c
modules/codec/a52.c
modules/codec/spdif.c
modules/misc/dummy/aout.c
src/audio_output/audio_output.c
src/audio_output/filters.c
src/audio_output/input.c
src/audio_output/mixer.c
src/audio_output/output.c
src/misc/modules_plugin.h

index a36733210dcaf73765cf475bf4232c8bb48d592a..3355ff3d2889ae8f0e446d605c0a844b1dd58d53 100644 (file)
@@ -2,7 +2,7 @@
  * aout_internal.h : internal defines for audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout_internal.h,v 1.3 2002/08/12 22:12:50 massiot Exp $
+ * $Id: aout_internal.h,v 1.4 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -35,30 +35,29 @@ typedef struct aout_alloc_t
 #define AOUT_ALLOC_STACK    1
 #define AOUT_ALLOC_HEAP     2
 
-#define aout_BufferAlloc( p_alloc, i_nb_usec, p_previous_buffer, p_new_buffer ) \
+#define aout_BufferAlloc( p_alloc, i_nb_usec, p_previous_buffer,            \
+                          p_new_buffer )                                    \
     if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_NONE )                       \
     {                                                                       \
         (p_new_buffer) = p_previous_buffer;                                 \
     }                                                                       \
     else                                                                    \
     {                                                                       \
+        int i_alloc_size;                                                   \
+        i_alloc_size = (u64)(p_alloc)->i_bytes_per_sec                      \
+                                            * (i_nb_usec) / 1000000 + 1;    \
         if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_STACK )                  \
         {                                                                   \
-            (p_new_buffer) = alloca( (u64)(p_alloc)->i_bytes_per_sec        \
-                                 * (i_nb_usec)                              \
-                                 / 1000000 + 1 + sizeof(aout_buffer_t) );   \
+            (p_new_buffer) = alloca( i_alloc_size + sizeof(aout_buffer_t) );\
         }                                                                   \
         else                                                                \
         {                                                                   \
-            (p_new_buffer) = malloc( (u64)(p_alloc)->i_bytes_per_sec        \
-                                 * (i_nb_usec)                              \
-                                 / 1000000 + 1 + sizeof(aout_buffer_t) );   \
+            (p_new_buffer) = malloc( i_alloc_size + sizeof(aout_buffer_t) );\
         }                                                                   \
         if ( p_new_buffer != NULL )                                         \
         {                                                                   \
             (p_new_buffer)->i_alloc_type = (p_alloc)->i_alloc_type;         \
-            (p_new_buffer)->i_size = (u64)(p_alloc)->i_bytes_per_sec        \
-                                            * (i_nb_usec) / 1000000 + 1;    \
+            (p_new_buffer)->i_size = i_alloc_size;                          \
             (p_new_buffer)->p_buffer = (byte_t *)(p_new_buffer)             \
                                          + sizeof(aout_buffer_t);           \
             if ( (p_previous_buffer) != NULL )                              \
index f9a5874349c4cfb3546c8615e8359d5fc3dc7e46..addf857056a2b3d04d5b81a4e61562ecb695b3d9 100644 (file)
@@ -2,7 +2,7 @@
  * audio_output.h : audio output interface
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: audio_output.h,v 1.57 2002/08/11 23:26:28 massiot Exp $
+ * $Id: audio_output.h,v 1.58 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -31,6 +31,8 @@ struct audio_sample_format_t
     int                 i_format;
     int                 i_rate;
     int                 i_channels;
+    /* Optional - for A52, SPDIF and DTS types */
+    int                 i_bytes_per_sec;
 };
 
 #define AOUT_FMT_MU_LAW     0x00000001
@@ -62,7 +64,7 @@ struct audio_sample_format_t
 #   define AOUT_FMT_U16_NE AOUT_FMT_U16_LE
 #endif
 
-#define AOUT_FMT_IS_SPDIF( p_format )                                      \
+#define AOUT_FMT_NON_LINEAR( p_format )                                    \
     ( ((p_format)->i_format == AOUT_FMT_SPDIF)                             \
        || ((p_format)->i_format == AOUT_FMT_A52)                           \
        || ((p_format)->i_format == AOUT_FMT_DTS) )
@@ -94,7 +96,6 @@ typedef s32 vlc_fixed_t;
 #define FIXED32_ONE ((vlc_fixed_t) 0x10000000)
 
 
-
 /*****************************************************************************
  * aout_buffer_t : audio output buffer
  *****************************************************************************/
@@ -102,7 +103,9 @@ struct aout_buffer_t
 {
     byte_t *                p_buffer;
     int                     i_alloc_type;
-    size_t                  i_size;
+    /* i_size is the real size of the buffer (normally unused), i_nb_bytes
+     * is the number of significative bytes in it. */
+    size_t                  i_size, i_nb_bytes;
     int                     i_nb_samples;
     mtime_t                 start_date, end_date;
 
@@ -122,9 +125,7 @@ VLC_EXPORT( void,              aout_DeleteInstance, ( aout_instance_t * ) );
 VLC_EXPORT( aout_buffer_t *, aout_BufferNew, ( aout_instance_t *, aout_input_t *, size_t ) );
 VLC_EXPORT( void, aout_BufferDelete, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
 VLC_EXPORT( void, aout_BufferPlay, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
-VLC_EXPORT( int, aout_FormatTo, ( audio_sample_format_t * p_format, int ) );
-#define aout_FormatToByterate(a,b) aout_FormatTo(a,b)
-#define aout_FormatToSize(a,b) aout_FormatTo(a,b)
+VLC_EXPORT( int, aout_FormatToByterate, ( audio_sample_format_t * p_format ) );
 
 /* From input.c : */
 #define aout_InputNew(a,b,c) __aout_InputNew(VLC_OBJECT(a),b,c)
index d963a95f9f2bbd9765e860cacac054169c0acf55..3fd8eabe61cd2550304189f68ad68688d875c278 100644 (file)
@@ -1,4 +1,4 @@
-/* include/defs.h.in.  Generated automatically from configure.in by autoheader 2.13.  */
+/* include/defs.h.in.  Generated automatically from configure.in by autoheader.  */
 
 /* Define if using alloca.c.  */
 #undef C_ALLOCA
index 5d06d0c96976e1d0d0f808f807feb7190df4c81c..4074523c8c59303dc79b977070d3a6b2dd14d923 100644 (file)
@@ -36,7 +36,7 @@ struct module_symbols_t
     int (* __vlc_thread_create_inner) ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), vlc_bool_t ) ;
     int (* __vlc_threads_end_inner) ( vlc_object_t * ) ;
     int (* __vlc_threads_init_inner) ( vlc_object_t * ) ;
-    int (* aout_FormatTo_inner) ( audio_sample_format_t * p_format, int ) ;
+    int (* aout_FormatToByterate_inner) ( audio_sample_format_t * p_format ) ;
     int (* input_AccessInit_inner) ( input_thread_t * ) ;
     int (* input_AddInfo_inner) ( input_info_category_t *, char *, char *, ... ) ;
     int (* input_ChangeArea_inner) ( input_thread_t *, input_area_t * ) ;
@@ -206,7 +206,7 @@ struct module_symbols_t
 #   define aout_BufferNew p_symbols->aout_BufferNew_inner
 #   define aout_BufferPlay p_symbols->aout_BufferPlay_inner
 #   define aout_DeleteInstance p_symbols->aout_DeleteInstance_inner
-#   define aout_FormatTo p_symbols->aout_FormatTo_inner
+#   define aout_FormatToByterate p_symbols->aout_FormatToByterate_inner
 #   define aout_InputDelete p_symbols->aout_InputDelete_inner
 #   define aout_OutputNextBuffer p_symbols->aout_OutputNextBuffer_inner
 #   define config_Duplicate p_symbols->config_Duplicate_inner
index ae0f5c123ccf234f6439a658c18b32df2cb52c5c..84105371bd59893aa89dab5a2f824561e9f3a3de 100644 (file)
@@ -2,7 +2,7 @@
  * a52tospdif.c : encapsulates A/52 frames into S/PDIF packets
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: a52tospdif.c,v 1.6 2002/08/13 16:11:15 sam Exp $
+ * $Id: a52tospdif.c,v 1.7 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -120,6 +120,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
     p_filter->p_vlc->pf_memset( p_out + 8 + i_length, 0,
                                AOUT_SPDIF_SIZE - i_length - 8 );
 
-    p_out_buf->i_nb_samples = 1;
+    p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
+    p_out_buf->i_nb_bytes = AOUT_SPDIF_SIZE;
 }
 
index 8a77a36fe9b5392ecba580c3c2de72ac6dd261b7..0353d774dc57c14e6620766e9d81becee75d1edf 100644 (file)
@@ -2,7 +2,7 @@
  * float32tos16.c : converter from float32 to signed 16 bits integer
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: float32tos16.c,v 1.6 2002/08/13 22:42:23 massiot Exp $
+ * $Id: float32tos16.c,v 1.7 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -107,5 +107,6 @@ 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_bytes / 2;
 }
 
index c51b5294fdb32df49d982227489900c97f7bb390..da6185575eee0cf70e899f7882253708da0941a0 100644 (file)
@@ -2,7 +2,7 @@
  * float32tos8.c : converter from float32 to signed 8 bits integer
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: float32tos8.c,v 1.1 2002/08/13 22:42:23 massiot Exp $
+ * $Id: float32tos8.c,v 1.2 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Xavier Maillard <zedek@fxgsproject.org>
  *
@@ -96,5 +96,6 @@ 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_bytes / 4;
 }
 
index 566a1963686dcbd9756978c4a683b6e60884c71e..b5aa6a3e96c56ccf6d541e36326a0acfc3e3b644 100644 (file)
@@ -2,7 +2,7 @@
  * float32tou16.c : converter from float32 to unsigned 16 bits integer
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: float32tou16.c,v 1.1 2002/08/13 22:42:23 massiot Exp $
+ * $Id: float32tou16.c,v 1.2 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Xavier Maillard <zedek@fxgsproject.org>
  *
@@ -59,7 +59,7 @@ static int Create( vlc_object_t *p_this )
     aout_filter_t * p_filter = (aout_filter_t *)p_this;
 
     if ( p_filter->input.i_format != AOUT_FMT_FLOAT32
-          && p_filter->output.i_format != AOUT_FMT_U16_NE )
+          || p_filter->output.i_format != AOUT_FMT_U16_NE )
     {
         return -1;
     }
@@ -95,5 +95,6 @@ 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_bytes / 2;
 }
 
index 2f245a77dce560f6474ce00a16bb28a16cd5149c..185cd0299ac5fa092d5cb0c9b7da24b2778ba7f5 100644 (file)
@@ -2,7 +2,7 @@
  * float32tou8.c : converter from float32 to unsigned 8 bits integer
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: float32tou8.c,v 1.1 2002/08/13 22:42:23 massiot Exp $
+ * $Id: float32tou8.c,v 1.2 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Xavier Maillard <zedek@fxgsproject.org>
  *
@@ -59,7 +59,7 @@ static int Create( vlc_object_t *p_this )
     aout_filter_t * p_filter = (aout_filter_t *)p_this;
 
     if ( p_filter->input.i_format != AOUT_FMT_FLOAT32
-          && p_filter->output.i_format != AOUT_FMT_U8 )
+          || p_filter->output.i_format != AOUT_FMT_U8 )
     {
         return -1;
     }
@@ -96,5 +96,6 @@ 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_bytes / 4;
 }
 
index 8ee4d623758a2b6facdf6859491555c583a4a85b..307056959e55bfe8397afd207447f35cf0e9966b 100644 (file)
@@ -2,7 +2,7 @@
  * spdif.c : dummy mixer for S/PDIF output (1 input only)
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: spdif.c,v 1.2 2002/08/12 07:40:23 massiot Exp $
+ * $Id: spdif.c,v 1.3 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -56,7 +56,7 @@ static int Create( vlc_object_t *p_this )
 {
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
 
-    if ( p_aout->mixer.output.i_format != AOUT_FMT_SPDIF )
+    if ( !AOUT_FMT_NON_LINEAR(&p_aout->mixer.output) )
     {
         return -1;
     }
index ce202fc383f6b30307dc4eec6678a84c4e4bdcb9..c00d85f40fb22699ae2ea2bac18bfe11390eb99f 100644 (file)
@@ -210,13 +210,13 @@ static int aRtsThread( aout_instance_t * p_aout )
         if ( p_buffer != NULL )
         {
             p_bytes = p_buffer->p_buffer;
-            i_size = aout_FormatToSize( &p_aout->output.output,
-                                        p_buffer->i_nb_samples );
+            i_size = p_buffer->i_nb_bytes;
         }
         else
         {
-            i_size = aout_FormatToSize( &p_aout->output.output,
-                                        p_sys->i_size );
+            i_size = aout_FormatToByterate( &p_aout->output.output )
+                      * p_sys->i_size
+                      / p_aout->output.output.i_rate;
             p_bytes = alloca( i_size );
             memset( p_bytes, 0, i_size );
         }
index 99a7e271063bea1709c06da0a3b7df108bf32382..4db499ecd7407a7e343e309bea42ed2838f773dc 100644 (file)
@@ -2,7 +2,7 @@
  * esd.c : EsounD module
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: esd.c,v 1.3 2002/08/13 14:53:46 sam Exp $
+ * $Id: esd.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -150,8 +150,7 @@ static int SetFormat( aout_instance_t *p_aout )
                     * p_aout->output.output.i_rate / ESD_DEFAULT_RATE
                     * aout_FormatTo( &p_aout->output.output, 1 ) )
       * (mtime_t)1000000
-      / (mtime_t)aout_FormatToByterate( &p_aout->output.output,
-                                        p_aout->output.output.i_rate );
+      / (mtime_t)aout_FormatToByterate( &p_aout->output.output );
 
     p_sys->b_initialized = VLC_TRUE;
 
@@ -207,13 +206,13 @@ static int ESDThread( aout_instance_t * p_aout )
         if ( p_buffer != NULL )
         {
             p_bytes = p_buffer->p_buffer;
-            i_size = aout_FormatToSize( &p_aout->output.output,
-                                        p_buffer->i_nb_samples );
+            i_size = p_buffer->i_nb_bytes;
         }
         else
         {
-            i_size = aout_FormatToSize( &p_aout->output.output,
-                                        ESD_BUF_SIZE * 2 );
+            i_size = aout_FormatToByterate( &p_aout->output.output )
+                      * ESD_BUF_SIZE * 2
+                      / p_aout->output.output.i_rate;
             p_bytes = alloca( i_size );
             memset( p_bytes, 0, i_size );
         }
index 4ec06747e128df4e3dcb2cedf0596b5277aa8598..84de6fc5ee6000a228f98092b863ae3b4ddf0fae 100644 (file)
@@ -2,7 +2,7 @@
  * file.c : audio output which writes the samples to a file
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: file.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
+ * $Id: file.c,v 1.5 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -34,6 +34,7 @@
 #include "aout_internal.h"
 
 #define FRAME_SIZE 2048
+#define A52_FRAME_NB 1536
 
 /*****************************************************************************
  * Local prototypes.
@@ -57,7 +58,7 @@ static char *format_list[] = { "u8", "s8", "u16", "s16", "u16_le", "s16_le",
 static int format_int[] = { AOUT_FMT_U8, AOUT_FMT_S8, AOUT_FMT_U16_NE,
                             AOUT_FMT_S16_NE, AOUT_FMT_U16_LE, AOUT_FMT_S16_LE,
                             AOUT_FMT_U16_BE, AOUT_FMT_S16_BE, AOUT_FMT_FIXED32,
-                            AOUT_FMT_FLOAT32, AOUT_FMT_A52 };
+                            AOUT_FMT_FLOAT32, AOUT_FMT_SPDIF };
 
 #define PATH_TEXT N_("Path of the output file")
 #define PATH_LONGTEXT N_("By default samples.raw")
@@ -82,7 +83,8 @@ static int Open( vlc_object_t * p_this )
     FILE * p_file;
     char * psz_name = config_GetPsz( p_this, "path" );
 
-    (FILE *)p_aout->output.p_sys = p_file = fopen( psz_name, "wb" );
+    p_file = fopen( psz_name, "wb" );
+    p_aout->output.p_sys = (void *)p_file;
     free( psz_name );
     if ( p_file == NULL ) return -1;
 
@@ -128,7 +130,16 @@ static int SetFormat( aout_instance_t * p_aout )
     }
 
     p_aout->output.output.i_format = format_int[i];
-    p_aout->output.i_nb_samples = FRAME_SIZE;
+    if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF )
+    {
+        p_aout->output.i_nb_samples = A52_FRAME_NB;
+        p_aout->output.output.i_bytes_per_sec = p_aout->output.output.i_rate
+                                     * AOUT_SPDIF_SIZE / A52_FRAME_NB;
+    }
+    else
+    {
+        p_aout->output.i_nb_samples = FRAME_SIZE;
+    }
     return 0;
 }
 
@@ -137,9 +148,7 @@ static int SetFormat( aout_instance_t * p_aout )
  *****************************************************************************/
 static void Play( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
 {
-    if( fwrite( p_buffer->p_buffer,
-                aout_FormatToSize( &p_aout->output.output,
-                                   p_buffer->i_nb_samples ), 1,
+    if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1,
                 (FILE *)p_aout->output.p_sys ) != 1 )
     {
         msg_Err( p_aout, "write error (%s)", strerror(errno) );
index 09350b6e76a665d231c8333dbfb629860c53461c..7e1f67d2054c0fd4d968e2b2f489da2750e18109 100644 (file)
@@ -2,7 +2,7 @@
  * oss.c : OSS /dev/dsp module for vlc
  *****************************************************************************
  * Copyright (C) 2000-2002 VideoLAN
- * $Id: oss.c,v 1.8 2002/08/13 11:59:36 sam Exp $
+ * $Id: oss.c,v 1.9 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -65,7 +65,8 @@ struct aout_sys_t
     volatile vlc_bool_t   b_initialized;
 };
 
-#define DEFAULT_FRAME_SIZE 2048
+#define FRAME_SIZE 2048
+#define A52_FRAME_NB 1536
 
 /*****************************************************************************
  * Local prototypes
@@ -167,15 +168,16 @@ static int SetFormat( aout_instance_t *p_aout )
     }
 
     /* Set the output format */
-    if ( AOUT_FMT_IS_SPDIF( &p_aout->output.output ) )
+    if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF )
     {
-        p_aout->output.output.i_format = i_format = AOUT_FMT_SPDIF;
-        p_aout->output.i_nb_samples = 1;
+        p_aout->output.i_nb_samples = A52_FRAME_NB;
+        p_aout->output.output.i_bytes_per_sec = p_aout->output.output.i_rate
+                                     * AOUT_SPDIF_SIZE / A52_FRAME_NB;
     }
     else
     {
         p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE;
-        p_aout->output.i_nb_samples = DEFAULT_FRAME_SIZE;
+        p_aout->output.i_nb_samples = FRAME_SIZE;
     }
 
     if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0
@@ -186,7 +188,7 @@ static int SetFormat( aout_instance_t *p_aout )
         return -1;
     }
 
-    if ( !AOUT_FMT_IS_SPDIF( &p_aout->output.output ) )
+    if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF )
     {
         /* FIXME */
         if ( p_aout->output.output.i_channels > 2 )
@@ -308,8 +310,7 @@ static int OSSThread( aout_instance_t * p_aout )
              * Order is important here, since GetBufInfo is believed to take
              * more time than mdate(). */
             next_date = (mtime_t)GetBufInfo( p_aout ) * 1000000
-                      / aout_FormatToByterate( &p_aout->output.output,
-                                               p_aout->output.output.i_rate );
+                      / aout_FormatToByterate( &p_aout->output.output );
             next_date += mdate();
         }
 
@@ -318,13 +319,13 @@ static int OSSThread( aout_instance_t * p_aout )
         if ( p_buffer != NULL )
         {
             p_bytes = p_buffer->p_buffer;
-            i_size = aout_FormatToSize( &p_aout->output.output,
-                                        p_buffer->i_nb_samples );
+            i_size = p_buffer->i_nb_bytes;
         }
         else
         {
-            i_size = aout_FormatToSize( &p_aout->output.output,
-                                        DEFAULT_FRAME_SIZE );
+            i_size = aout_FormatToByterate( &p_aout->output.output )
+                      * FRAME_SIZE
+                      / p_aout->output.output.i_rate;
             p_bytes = alloca( i_size );
             memset( p_bytes, 0, i_size );
         }
index c9a8e3f57260ac5b1b6b489cc3ef19907c86ee13..f48e40dcc4a85c77b2fa3b0ba28b1529f7090eed 100644 (file)
@@ -4,7 +4,7 @@
  *   (http://liba52.sf.net/).
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: a52.c,v 1.3 2002/08/13 11:59:36 sam Exp $
+ * $Id: a52.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -49,7 +49,7 @@
 #   include "a52dec/a52.h"
 #endif
 
-#define A52_FRAME_SIZE 1536 
+#define A52_FRAME_NB 1536 
 
 /*****************************************************************************
  * a52_thread_t : a52 decoder thread descriptor
@@ -301,10 +301,10 @@ static int DecodeFrame( a52_thread_t * p_dec, byte_t * p_frame_buffer )
     }
 
     p_buffer = aout_BufferNew( p_dec->p_aout, p_dec->p_aout_input,
-                               A52_FRAME_SIZE );
+                               A52_FRAME_NB );
     if ( p_buffer == NULL ) return -1;
     p_buffer->start_date = p_dec->last_date;
-    p_dec->last_date += (mtime_t)(A52_FRAME_SIZE * 1000000)
+    p_dec->last_date += (mtime_t)(A52_FRAME_NB * 1000000)
                           / p_dec->output_format.i_rate;
     p_buffer->end_date = p_dec->last_date;
 
index 433f6635e4983fe7b698f665353e82cc64643f2a..758f9f72519e8820223ce395c9a0e31ad6ce2e70 100644 (file)
@@ -2,7 +2,7 @@
  * spdif.c: A52 pass-through to external decoder with enabled soundcard
  *****************************************************************************
  * Copyright (C) 2001-2002 VideoLAN
- * $Id: spdif.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
+ * $Id: spdif.c,v 1.5 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *          Juha Yrjola <jyrjola@cc.hut.fi>
@@ -40,7 +40,7 @@
 #   include <unistd.h>
 #endif
 
-#define A52_FRAME_SIZE 1536 
+#define A52_FRAME_NB 1536 
 
 /*****************************************************************************
  * spdif_thread_t : A52 pass-through thread descriptor
@@ -137,8 +137,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
         return -1;
     }
 
-    /* liba52 decoder thread's main loop */
-    while( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
+    /* decoder thread's main loop */
+    while ( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
     {
         int i_frame_size, i_flags, i_rate, i_bit_rate;
         mtime_t pts;
@@ -148,8 +148,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
 
         /* Look for sync word - should be 0x0b77 */
         RealignBits( &p_dec->bit_stream );
-        while( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 && 
-               (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error))
+        while ( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 && 
+                (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error))
         {
             RemoveBits( &p_dec->bit_stream, 8 );
         }
@@ -169,7 +169,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
         }
 
         if( (p_dec->p_aout_input != NULL) &&
-            ( (p_dec->output_format.i_rate != i_rate) ) )
+            ( (p_dec->output_format.i_rate != i_rate)
+                || (p_dec->output_format.i_bytes_per_sec != i_bit_rate * 1000 / 8) ) )
         {
             /* Parameters changed - this should not happen. */
             aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input );
@@ -180,6 +181,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
         if( p_dec->p_aout_input == NULL )
         {
             p_dec->output_format.i_rate = i_rate;
+            p_dec->output_format.i_bytes_per_sec = i_bit_rate * 1000 / 8;
             /* p_dec->output_format.i_channels = i_channels; */
             p_dec->p_aout_input = aout_InputNew( p_dec->p_fifo,
                                                  &p_dec->p_aout,
@@ -209,10 +211,10 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
         }
 
         p_buffer = aout_BufferNew( p_dec->p_aout, p_dec->p_aout_input,
-                                   i_frame_size );
+                                   A52_FRAME_NB );
         if ( p_buffer == NULL ) return -1;
         p_buffer->start_date = last_date;
-        last_date += (mtime_t)(A52_FRAME_SIZE * 1000000)
+        last_date += (mtime_t)(A52_FRAME_NB * 1000000)
                        / p_dec->output_format.i_rate;
         p_buffer->end_date = last_date;
 
index 09b67bf073d578ce4e2427b1b14603b0067a129c..3c40338d78c00146f9ded060551b03b798b103a7 100644 (file)
@@ -2,7 +2,7 @@
  * aout_dummy.c : dummy audio output plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: aout.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
+ * $Id: aout.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -33,6 +33,7 @@
 #include "aout_internal.h"
 
 #define FRAME_SIZE 2048
+#define A52_FRAME_NB 1536
 
 /*****************************************************************************
  * Local prototypes.
@@ -58,7 +59,16 @@ int E_(OpenAudio) ( vlc_object_t * p_this )
  *****************************************************************************/
 static int SetFormat( aout_instance_t * p_aout )
 {
-    p_aout->output.i_nb_samples = FRAME_SIZE;
+    if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF )
+    {
+        p_aout->output.i_nb_samples = A52_FRAME_NB;
+        p_aout->output.output.i_bytes_per_sec = p_aout->output.output.i_rate
+                                     * AOUT_SPDIF_SIZE / A52_FRAME_NB;
+    }
+    else
+    {
+        p_aout->output.i_nb_samples = FRAME_SIZE;
+    }
     return 0;
 }
 
index 1bda239b78483b70a81732a5f95ab97a7bfc76b0..15605d8f4db74685b4c3365ccbba19332ecfb907 100644 (file)
@@ -2,7 +2,7 @@
  * audio_output.c : audio output instance
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: audio_output.c,v 1.94 2002/08/12 09:34:15 sam Exp $
+ * $Id: audio_output.c,v 1.95 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -88,12 +88,15 @@ aout_buffer_t * aout_BufferNew( aout_instance_t * p_aout,
                                 size_t i_nb_samples )
 {
     aout_buffer_t * p_buffer;
+    mtime_t duration = (1000000 * (mtime_t)i_nb_samples)
+                        / p_input->input.i_rate;
 
     /* This necessarily allocates in the heap. */
-    aout_BufferAlloc( &p_input->input_alloc, (u64)(1000000 * i_nb_samples)
-                                         / p_input->input.i_rate,
-                      NULL, p_buffer );
+    aout_BufferAlloc( &p_input->input_alloc, duration, NULL, p_buffer );
     p_buffer->i_nb_samples = i_nb_samples;
+    p_buffer->i_nb_bytes = duration
+                              * aout_FormatToByterate( &p_input->input )
+                              / 1000000;
 
     if ( p_buffer == NULL )
     {
@@ -161,10 +164,9 @@ void aout_BufferPlay( aout_instance_t * p_aout, aout_input_t * p_input,
 }
 
 /*****************************************************************************
- * aout_FormatTo : compute the number of bytes/sample for format (used for
- * aout_FormatToByterate and aout_FormatToSize)
+ * aout_FormatToByterate : compute the number of bytes per second
  *****************************************************************************/
-int aout_FormatTo( audio_sample_format_t * p_format, int i_multiplier )
+int aout_FormatToByterate( audio_sample_format_t * p_format )
 {
     int i_result;
 
@@ -188,17 +190,16 @@ int aout_FormatTo( audio_sample_format_t * p_format, int i_multiplier )
         break;
 
     case AOUT_FMT_SPDIF:
-    case AOUT_FMT_A52: /* Actually smaller and variable, but who cares ? */
-    case AOUT_FMT_DTS: /* Unimplemented and untested */
-        /* Please note that we don't multiply by multiplier, because i_rate
-         * and i_nb_samples do not have any sense for S/PDIF (yes, it
-         * _is_ kludgy). --Meuuh */
-        return AOUT_SPDIF_SIZE;
+    case AOUT_FMT_A52:
+    case AOUT_FMT_DTS:
+        /* For these formats the caller has to indicate the number of bytes
+         * per second it evaluates. */
+        return p_format->i_bytes_per_sec;
 
     default:
         return 0; /* will segfault much sooner... */
     }
 
-    return i_result * p_format->i_channels * i_multiplier;
+    return i_result * p_format->i_channels * p_format->i_rate;
 }
 
index 5c4d340c51d572126bd09647de51ce7c8c4746b5..7afe654444a3c85cfd1f35addea0ac8660cebe06 100644 (file)
@@ -2,7 +2,7 @@
  * filters.c : audio output filters management
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: filters.c,v 1.3 2002/08/12 09:34:15 sam Exp $
+ * $Id: filters.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -161,10 +161,8 @@ void aout_FiltersHintBuffers( aout_instance_t * p_aout,
     {
         aout_filter_t * p_filter = pp_filters[i];
 
-        int i_output_size = aout_FormatToByterate( &p_filter->output,
-                                                   p_filter->output.i_rate );
-        int i_input_size = aout_FormatToByterate( &p_filter->input,
-                                                  p_filter->input.i_rate );
+        int i_output_size = aout_FormatToByterate( &p_filter->output );
+        int i_input_size = aout_FormatToByterate( &p_filter->input );
 
         p_first_alloc->i_bytes_per_sec = __MAX( p_first_alloc->i_bytes_per_sec,
                                                 i_output_size );
@@ -209,8 +207,8 @@ void aout_FiltersPlay( aout_instance_t * p_aout,
             msg_Err( p_aout, "out of memory" );
             return;
         }
-        /* Please note that p_output_buffer->i_nb_samples shall be set by
-         * the filter plug-in. */
+        /* Please note that p_output_buffer->i_nb_samples & i_nb_bytes
+         * shall be set by the filter plug-in. */
 
         p_filter->pf_do_work( p_aout, p_filter, *pp_input_buffer,
                               p_output_buffer );
index b1ce100d963be09228bf9bab8877bb1ff7bb9188..4b915306f906e47971aa2a480152f923d111c576 100644 (file)
@@ -2,7 +2,7 @@
  * input.c : internal management of input streams for the audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: input.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
+ * $Id: input.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -64,6 +64,8 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
 
     memcpy( &p_input->input, p_format,
             sizeof(audio_sample_format_t) );
+    p_input->input.i_bytes_per_sec =
+                            aout_FormatToByterate( &p_input->input );
 
     /* Prepare FIFO. */
     aout_FifoInit( p_aout, &p_input->fifo );
@@ -117,8 +119,7 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
     /* i_bytes_per_sec is still == -1 if no filters */
     p_input->input_alloc.i_bytes_per_sec = __MAX(
                                     p_input->input_alloc.i_bytes_per_sec,
-                                    aout_FormatToByterate( &p_input->input,
-                                                   p_input->input.i_rate ) );
+                                    p_input->input.i_bytes_per_sec );
     /* Allocate in the heap, it is more convenient for the decoder. */
     p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
 
index 040c7d62548417f95b571056436fd0e2cde24ff7..2aa2204066eb036b2293d9eb434b5384d679fe99 100644 (file)
@@ -2,7 +2,7 @@
  * mixer.c : audio output mixing operations
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: mixer.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
+ * $Id: mixer.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -122,6 +122,9 @@ void aout_MixerRun( aout_instance_t * p_aout )
         return;
     }
     p_output_buffer->i_nb_samples = p_aout->output.i_nb_samples;
+    p_output_buffer->i_nb_bytes = (wanted_date - first_date)
+                              * aout_FormatToByterate( &p_aout->mixer.output )
+                              / 1000000;
     p_output_buffer->start_date = first_date;
     p_output_buffer->end_date = wanted_date;
     p_aout->output.last_date = wanted_date;
index 48e61e612290315f511414acd9e7d19dbffea8c2..bde793c5b257d64a0c48830b28bedfcf5cb07446 100644 (file)
@@ -2,7 +2,7 @@
  * output.c : internal management of output streams for the audio output
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: output.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
+ * $Id: output.c,v 1.5 2002/08/14 00:23:59 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -61,7 +61,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
     memcpy( &p_aout->output.output, p_format, sizeof(audio_sample_format_t) );
     if ( i_rate != -1 ) p_aout->output.output.i_rate = i_rate;
     if ( i_channels != -1 ) p_aout->output.output.i_channels = i_channels;
-    if ( AOUT_FMT_IS_SPDIF(&p_aout->output.output) )
+    if ( AOUT_FMT_NON_LINEAR(&p_aout->output.output) )
     {
         p_aout->output.output.i_format = AOUT_FMT_SPDIF;
     }
@@ -88,22 +88,30 @@ int aout_OutputNew( aout_instance_t * p_aout,
     /* Calculate the resulting mixer output format. */
     p_aout->mixer.output.i_channels = p_aout->output.output.i_channels;
     p_aout->mixer.output.i_rate = p_aout->output.output.i_rate;
-    if ( AOUT_FMT_IS_SPDIF(&p_aout->output.output) )
-    {
-        p_aout->mixer.output.i_format = AOUT_FMT_SPDIF;
-    }
-    else
+    if ( !AOUT_FMT_NON_LINEAR(&p_aout->output.output) )
     {
         /* Non-S/PDIF mixer only deals with float32 or fixed32. */
         p_aout->mixer.output.i_format
                      = (p_aout->p_vlc->i_cpu & CPU_CAPABILITY_FPU) ?
                         AOUT_FMT_FLOAT32 : AOUT_FMT_FIXED32;
+        p_aout->mixer.output.i_bytes_per_sec
+                     = aout_FormatToByterate( &p_aout->mixer.output );
     }
+    else
+    {
+        p_aout->mixer.output.i_format = p_format->i_format;
+        p_aout->mixer.output.i_bytes_per_sec = p_format->i_bytes_per_sec;
+    }
+
+    msg_Dbg( p_aout, "mixer format=%d rate=%d channels=%d",
+             p_aout->mixer.output.i_format, p_aout->mixer.output.i_rate,
+             p_aout->mixer.output.i_channels );
 
     /* Calculate the resulting mixer input format. */
     p_aout->mixer.input.i_channels = -1; /* unchanged */
     p_aout->mixer.input.i_rate = p_aout->mixer.output.i_rate;
     p_aout->mixer.input.i_format = p_aout->mixer.output.i_format;
+    p_aout->mixer.input.i_bytes_per_sec = p_aout->mixer.output.i_bytes_per_sec;
 
     /* Create filters. */
     if ( aout_FiltersCreatePipeline( p_aout, p_aout->output.pp_filters,
@@ -119,8 +127,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
     /* Prepare hints for the buffer allocator. */
     p_aout->mixer.output_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
     p_aout->mixer.output_alloc.i_bytes_per_sec
-         = aout_FormatToByterate( &p_aout->output.output,
-                                  p_aout->output.output.i_rate );
+         = aout_FormatToByterate( &p_aout->output.output );
 
     aout_FiltersHintBuffers( p_aout, p_aout->output.pp_filters,
                              p_aout->output.i_nb_filters,
index 442c46116dc5dc0bcc0ead2e813a73d942b822c7..6d7368d47c1d46fc56c16967b7f6b4d45c1d288a 100644 (file)
@@ -184,7 +184,7 @@ static const char * module_error( char *psz_buffer )
     (p_symbols)->aout_BufferNew_inner = aout_BufferNew; \
     (p_symbols)->aout_BufferDelete_inner = aout_BufferDelete; \
     (p_symbols)->aout_BufferPlay_inner = aout_BufferPlay; \
-    (p_symbols)->aout_FormatTo_inner = aout_FormatTo; \
+    (p_symbols)->aout_FormatToByterate_inner = aout_FormatToByterate; \
     (p_symbols)->__aout_InputNew_inner = __aout_InputNew; \
     (p_symbols)->aout_InputDelete_inner = aout_InputDelete; \
     (p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \