]> git.sesse.net Git - vlc/blobdiff - include/aout_internal.h
* modules/audio_output/directx.c: backport of directx audio changes (13374). Needs...
[vlc] / include / aout_internal.h
index 4dbb532479c5129f79a3dea01f3eb7ef0eb33da6..76aef0417c13875a14b3430c623d1c8ae80743d5 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * aout_internal.h : internal defines for audio output
  *****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: aout_internal.h,v 1.23 2002/10/20 12:23:47 massiot Exp $
+ * Copyright (C) 2002 the VideoLAN team
+ * $Id$
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -10,7 +10,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
@@ -34,6 +34,18 @@ typedef struct aout_alloc_t
 #define AOUT_ALLOC_STACK    1
 #define AOUT_ALLOC_HEAP     2
 
+#ifdef HAVE_ALLOCA
+#   define ALLOCA_TEST( p_alloc, p_new_buffer )                             \
+        if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_STACK )                  \
+        {                                                                   \
+            (p_new_buffer) = alloca( i_alloc_size + sizeof(aout_buffer_t) );\
+            i_alloc_type = AOUT_ALLOC_STACK;                                \
+        }                                                                   \
+        else
+#else
+#   define ALLOCA_TEST( p_alloc, p_new_buffer )
+#endif
+
 #define aout_BufferAlloc( p_alloc, i_nb_usec, p_previous_buffer,            \
                           p_new_buffer )                                    \
     if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_NONE )                       \
@@ -42,20 +54,17 @@ typedef struct aout_alloc_t
     }                                                                       \
     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( i_alloc_size + sizeof(aout_buffer_t) );\
-        }                                                                   \
-        else                                                                \
+        int i_alloc_size, i_alloc_type;                                     \
+        i_alloc_size = (int)( (uint64_t)(p_alloc)->i_bytes_per_sec          \
+                                            * (i_nb_usec) / 1000000 + 1 );  \
+        ALLOCA_TEST( p_alloc, p_new_buffer )                                \
         {                                                                   \
             (p_new_buffer) = malloc( i_alloc_size + sizeof(aout_buffer_t) );\
+            i_alloc_type = AOUT_ALLOC_HEAP;                                 \
         }                                                                   \
         if ( p_new_buffer != NULL )                                         \
         {                                                                   \
-            (p_new_buffer)->i_alloc_type = (p_alloc)->i_alloc_type;         \
+            (p_new_buffer)->i_alloc_type = i_alloc_type;                    \
             (p_new_buffer)->i_size = i_alloc_size;                          \
             (p_new_buffer)->p_buffer = (byte_t *)(p_new_buffer)             \
                                          + sizeof(aout_buffer_t);           \
@@ -90,7 +99,7 @@ struct aout_fifo_t
 /*****************************************************************************
  * aout_filter_t : audio output filter
  *****************************************************************************/
-typedef struct aout_filter_t
+struct aout_filter_t
 {
     VLC_COMMON_MEMBERS
 
@@ -105,7 +114,8 @@ typedef struct aout_filter_t
                                          struct aout_buffer_t *,
                                          struct aout_buffer_t * );
     vlc_bool_t              b_in_place;
-} aout_filter_t;
+    vlc_bool_t              b_continuity;
+};
 
 /*****************************************************************************
  * aout_mixer_t : audio output mixer
@@ -120,7 +130,7 @@ typedef struct aout_mixer_t
     void                 (* pf_do_work)( struct aout_instance_t *,
                                          struct aout_buffer_t * );
 
-    /* If b_error == 1, there is no mixer nor audio output pipeline. */
+    /* If b_error == 1, there is no mixer. */
     vlc_bool_t              b_error;
     /* Multiplier used to raise or lower the volume of the sound in
      * software. Beware, this creates sound distortion and should be avoided
@@ -131,6 +141,9 @@ typedef struct aout_mixer_t
 /*****************************************************************************
  * aout_input_t : input stream for the audio output
  *****************************************************************************/
+#define AOUT_RESAMPLING_NONE     0
+#define AOUT_RESAMPLING_UP       1
+#define AOUT_RESAMPLING_DOWN     2
 struct aout_input_t
 {
     /* When this lock is taken, the pipeline cannot be changed by a
@@ -147,16 +160,29 @@ struct aout_input_t
     /* resamplers */
     aout_filter_t *         pp_resamplers[AOUT_MAX_FILTERS];
     int                     i_nb_resamplers;
+    int                     i_resampling_type;
+    mtime_t                 i_resamp_start_date;
+    int                     i_resamp_start_drift;
 
     aout_fifo_t             fifo;
 
     /* Mixer information */
     byte_t *                p_first_byte_to_mix;
 
+    /* If b_restart == 1, the input pipeline will be re-created. */
+    vlc_bool_t              b_restart;
+
     /* If b_error == 1, there is no input pipeline. */
     vlc_bool_t              b_error;
-    /* Did we just change the output format ? (expect buffer inconsistencies) */
+
+    /* Did we just change the output format? (expect buffer inconsistencies) */
     vlc_bool_t              b_changed;
+
+    /* internal caching delay from input */
+    int                     i_pts_delay;
+    /* desynchronisation delay request by the user */
+    int                     i_desync;
+
 };
 
 /*****************************************************************************
@@ -165,6 +191,9 @@ struct aout_input_t
 typedef struct aout_output_t
 {
     audio_sample_format_t   output;
+    /* Indicates whether the audio output is currently starving, to avoid
+     * printing a 1,000 "output is starving" messages. */
+    vlc_bool_t              b_starving;
 
     /* post-filters */
     aout_filter_t *         pp_filters[AOUT_MAX_FILTERS];
@@ -183,6 +212,9 @@ typedef struct aout_output_t
     /* Current volume for the output - it's just a placeholder, the plug-in
      * may or may not use it. */
     audio_volume_t          i_volume;
+
+    /* If b_error == 1, there is no audio output pipeline. */
+    vlc_bool_t              b_error;
 } aout_output_t;
 
 /*****************************************************************************
@@ -228,24 +260,14 @@ int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                     aout_buffer_t * p_buffer );
 
 /* From filters.c : */
-int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
-                                aout_filter_t ** pp_filters,
-                                int * pi_nb_filters,
-                                const audio_sample_format_t * p_input_format,
-                                const audio_sample_format_t * p_output_format );
-void aout_FiltersDestroyPipeline( aout_instance_t * p_aout,
-                                  aout_filter_t ** pp_filters,
-                                  int i_nb_filters );
-void aout_FiltersHintBuffers( aout_instance_t * p_aout,
-                              aout_filter_t ** pp_filters,
-                              int i_nb_filters, aout_alloc_t * p_first_alloc );
-void aout_FiltersPlay( aout_instance_t * p_aout,
-                       aout_filter_t ** pp_filters,
-                       int i_nb_filters, aout_buffer_t ** pp_input_buffer );
+VLC_EXPORT( int, aout_FiltersCreatePipeline, ( aout_instance_t * p_aout, aout_filter_t ** pp_filters, int * pi_nb_filters, const audio_sample_format_t * p_input_format, const audio_sample_format_t * p_output_format ) );
+VLC_EXPORT( void, aout_FiltersDestroyPipeline, ( aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters ) );
+VLC_EXPORT( void, aout_FiltersPlay, ( aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_buffer_t ** pp_input_buffer ) );
+void aout_FiltersHintBuffers( aout_instance_t * p_aout, aout_filter_t ** pp_filters, int i_nb_filters, aout_alloc_t * p_first_alloc );
 
 /* From mixer.c : */
 int aout_MixerNew( aout_instance_t * p_aout );
-int aout_MixerDelete( aout_instance_t * p_aout );
+void aout_MixerDelete( aout_instance_t * p_aout );
 void aout_MixerRun( aout_instance_t * p_aout );
 int aout_MixerMultiplierSet( aout_instance_t * p_aout, float f_multiplier );
 int aout_MixerMultiplierGet( aout_instance_t * p_aout, float * pf_multiplier );
@@ -258,17 +280,19 @@ void aout_OutputDelete( aout_instance_t * p_aout );
 VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, vlc_bool_t ) );
 
 /* From common.c : */
-VLC_EXPORT( int, aout_FormatNbChannels, ( audio_sample_format_t * p_format ) );
-void aout_FormatPrepare( audio_sample_format_t * p_format );
-VLC_EXPORT( void, aout_FormatPrint, ( aout_instance_t * p_aout, const char * psz_text, audio_sample_format_t * p_format ) );
-VLC_EXPORT( void, aout_FormatsPrint, ( aout_instance_t * p_aout, const char * psz_text, audio_sample_format_t * p_format1, audio_sample_format_t * p_format2 ) );
-void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 );
+VLC_EXPORT( unsigned int, aout_FormatNbChannels, ( const audio_sample_format_t * p_format ) );
+VLC_EXPORT( void, aout_FormatPrepare, ( audio_sample_format_t * p_format ) );
+VLC_EXPORT( void, aout_FormatPrint, ( aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format ) );
+VLC_EXPORT( void, aout_FormatsPrint, ( aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format1, const audio_sample_format_t * p_format2 ) );
+VLC_EXPORT( const char *, aout_FormatPrintChannels, ( const audio_sample_format_t * ) );
+void aout_FifoInit( aout_instance_t *, aout_fifo_t *, uint32_t );
 mtime_t aout_FifoNextStart( aout_instance_t *, aout_fifo_t * );
 void aout_FifoPush( aout_instance_t *, aout_fifo_t *, aout_buffer_t * );
 void aout_FifoSet( aout_instance_t *, aout_fifo_t *, mtime_t );
 void aout_FifoMoveDates( aout_instance_t *, aout_fifo_t *, mtime_t );
 VLC_EXPORT( aout_buffer_t *, aout_FifoPop, ( aout_instance_t * p_aout, aout_fifo_t * p_fifo ) );
 void aout_FifoDestroy( aout_instance_t * p_aout, aout_fifo_t * p_fifo );
+VLC_EXPORT( mtime_t, aout_FifoFirstDate, ( aout_instance_t *, aout_fifo_t * ) );
 
 /* From intf.c :*/
 VLC_EXPORT( void, aout_VolumeSoftInit, ( aout_instance_t * ) );