]> git.sesse.net Git - vlc/blobdiff - src/audio_output/aout_internal.h
aout: remove aout_DecIsEmpty()
[vlc] / src / audio_output / aout_internal.h
index 1e3997fdc8fd5887356b8da629aa448324ca3fc4..ec729fbc37ec8224000f2fd0ff668518b2b60be1 100644 (file)
@@ -1,29 +1,31 @@
 /*****************************************************************************
  * aout_internal.h : internal defines for audio output
  *****************************************************************************
- * Copyright (C) 2002 the VideoLAN team
+ * Copyright (C) 2002 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifndef LIBVLC_AOUT_INTERNAL_H
 # define LIBVLC_AOUT_INTERNAL_H 1
 
+# include <vlc_atomic.h>
+
 /* Max input rate factor (1/4 -> 4) */
 # define AOUT_MAX_INPUT_RATE (4)
 
@@ -33,80 +35,53 @@ enum {
     AOUT_RESAMPLING_DOWN
 };
 
-typedef struct
+struct aout_request_vout
 {
     struct vout_thread_t  *(*pf_request_vout)( void *, struct vout_thread_t *,
                                                video_format_t *, bool );
     void *p_private;
-} aout_request_vout_t;
-
-struct filter_owner_sys_t
-{
-    audio_output_t *p_aout;
-    aout_input_t    *p_input;
 };
 
-block_t *aout_FilterBufferNew( filter_t *, int );
-
-/** an input stream for the audio output */
-struct aout_input_t
-{
-    audio_sample_format_t   input;
-    float                   multiplier; /**< Replay gain multiplier */
-
-    /* pre-filters */
-    filter_t *              pp_filters[AOUT_MAX_FILTERS];
-    int                     i_nb_filters;
-
-    filter_t *              p_playback_rate_filter;
-
-    /* resamplers */
-    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;
-
-    /* Mixer information */
-    audio_replay_gain_t     replay_gain;
-
-    /* If b_restart == 1, the input pipeline will be re-created. */
-    bool              b_restart;
-
-    /* If b_error == 1, there is no input pipeline. */
-    bool              b_error;
-
-    /* last rate from input */
-    int               i_last_input_rate;
-
-    /* */
-    int               i_buffer_lost;
-
-    /* */
-    bool                b_recycle_vout;
-    aout_request_vout_t request_vout;
-
-    /* */
-    date_t                  date;
-};
+typedef struct aout_volume aout_volume_t;
+typedef struct aout_dev aout_dev_t;
 
 typedef struct
 {
+    vlc_mutex_t lock;
     module_t *module; /**< Output plugin (or NULL if inactive) */
-    aout_input_t *input;
+    aout_filters_t *filters;
+    aout_volume_t *volume;
 
     struct
     {
         vlc_mutex_t lock;
-        float multiplier; /**< Software volume amplification multiplier */
-        struct audio_mixer *mixer; /**< Software volume plugin */
-    } volume; /**< Volume and gain management (FIXME: input manager?) */
+        char *device;
+        float volume;
+        signed char mute;
+    } req;
 
+    struct
+    {
+        vlc_mutex_t lock;
+        aout_dev_t *list;
+        unsigned count;
+    } dev;
+
+    struct
+    {
+        mtime_t end; /**< Last seen PTS */
+        unsigned resamp_start_drift; /**< Resampler drift absolute value */
+        int resamp_type; /**< Resampler mode (FIXME: redundant / resampling) */
+        bool discontinuity;
+    } sync;
+
+    audio_sample_format_t input_format;
     audio_sample_format_t mixer_format;
 
-    /* Filters between mixer and output */
-    filter_t *filters[AOUT_MAX_FILTERS];
-    int       nb_filters;
+    aout_request_vout_t request_vout;
+
+    atomic_uint buffers_lost;
+    atomic_uchar restart;
 } aout_owner_t;
 
 typedef struct
@@ -124,117 +99,52 @@ static inline aout_owner_t *aout_owner (audio_output_t *aout)
  * Prototypes
  *****************************************************************************/
 
-/* From input.c : */
-int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * );
-int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input );
-block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
-                         block_t *p_buffer, int i_input_rate );
-void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input );
-
-/* From filters.c : */
-int aout_FiltersCreatePipeline( audio_output_t *, filter_t **, int *,
-    const audio_sample_format_t *, const audio_sample_format_t * );
-void aout_FiltersDestroyPipeline( filter_t *const *, unsigned );
-void aout_FiltersPlay( filter_t *const *, unsigned, aout_buffer_t ** );
-
 /* From mixer.c : */
-struct audio_mixer *aout_MixerNew(vlc_object_t *, vlc_fourcc_t);
-#define aout_MixerNew(o, f) aout_MixerNew(VLC_OBJECT(o), f)
-void aout_MixerDelete(struct audio_mixer *);
-void aout_MixerRun(struct audio_mixer *, block_t *, float);
+aout_volume_t *aout_volume_New(vlc_object_t *, const audio_replay_gain_t *);
+#define aout_volume_New(o, g) aout_volume_New(VLC_OBJECT(o), g)
+int aout_volume_SetFormat(aout_volume_t *, vlc_fourcc_t);
+void aout_volume_SetVolume(aout_volume_t *, float);
+int aout_volume_Amplify(aout_volume_t *, block_t *);
+void aout_volume_Delete(aout_volume_t *);
+
 
 /* From output.c : */
-int aout_OutputNew( audio_output_t * p_aout,
-                    const audio_sample_format_t * p_format );
-void aout_OutputPlay( audio_output_t * p_aout, aout_buffer_t * p_buffer );
+audio_output_t *aout_New (vlc_object_t *);
+#define aout_New(a) aout_New(VLC_OBJECT(a))
+void aout_Destroy (audio_output_t *);
+
+int aout_OutputNew(audio_output_t *, audio_sample_format_t *);
+int aout_OutputTimeGet(audio_output_t *, mtime_t *);
+void aout_OutputPlay(audio_output_t *, block_t *);
 void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
 void aout_OutputFlush( audio_output_t * p_aout, bool );
 void aout_OutputDelete( audio_output_t * p_aout );
+void aout_OutputLock(audio_output_t *);
+void aout_OutputUnlock(audio_output_t *);
 
 
 /* From common.c : */
-/* Release with vlc_object_release() */
-audio_output_t *aout_New ( vlc_object_t * );
-#define aout_New(a) aout_New(VLC_OBJECT(a))
-
-void aout_FifoInit( vlc_object_t *, aout_fifo_t *, uint32_t );
-#define aout_FifoInit(o, f, r) aout_FifoInit(VLC_OBJECT(o), f, r)
-//void aout_FifoPush( aout_fifo_t *, aout_buffer_t * );
-void aout_FifoReset( aout_fifo_t * );
-void aout_FifoMoveDates( aout_fifo_t *, mtime_t );
-void aout_FifoDestroy( aout_fifo_t * p_fifo );
-void aout_FormatsPrint( audio_output_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format1, const audio_sample_format_t * p_format2 );
-bool aout_ChangeFilterString( vlc_object_t *, audio_output_t *, const char *psz_variable, const char *psz_name, bool b_add );
+void aout_FormatsPrint(vlc_object_t *, const char *,
+                       const audio_sample_format_t *,
+                       const audio_sample_format_t *);
+#define aout_FormatsPrint(o, t, a, b) \
+        aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
+bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout,
+                              const char *var, const char *name, bool b_add );
 
 /* From dec.c */
-aout_input_t *aout_DecNew( audio_output_t *, audio_sample_format_t *,
-                   const audio_replay_gain_t *, const aout_request_vout_t * );
-void aout_DecDelete ( audio_output_t *, aout_input_t * );
-aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
-void aout_DecDeleteBuffer( audio_output_t *, aout_input_t *, aout_buffer_t * );
-int aout_DecPlay( audio_output_t *, aout_input_t *, aout_buffer_t *, int i_input_rate );
-int aout_DecGetResetLost( audio_output_t *, aout_input_t * );
-void aout_DecChangePause( audio_output_t *, aout_input_t *, bool b_paused, mtime_t i_date );
-void aout_DecFlush( audio_output_t *, aout_input_t * );
-bool aout_DecIsEmpty( audio_output_t * p_aout, aout_input_t * p_input );
-
-/* Audio output locking */
-
-#if !defined (NDEBUG) \
- && defined __linux__ && (defined (__i386__) || defined (__x86_64__))
-# define AOUT_DEBUG 1
-#endif
-
-#ifdef AOUT_DEBUG
-enum
-{
-    OUTPUT_LOCK=1,
-    VOLUME_LOCK=2,
-};
-
-void aout_lock_check (unsigned);
-void aout_unlock_check (unsigned);
-
-#else
-# define aout_lock_check( i )   (void)0
-# define aout_unlock_check( i ) (void)0
-#endif
-
-static inline void aout_lock( audio_output_t *p_aout )
-{
-    aout_lock_check( OUTPUT_LOCK );
-    vlc_mutex_lock( &p_aout->lock );
-}
-
-static inline void aout_unlock( audio_output_t *p_aout )
-{
-    aout_unlock_check( OUTPUT_LOCK );
-    vlc_mutex_unlock( &p_aout->lock );
-}
-
-static inline void aout_lock_volume( audio_output_t *p_aout )
-{
-    aout_lock_check( VOLUME_LOCK );
-    vlc_mutex_lock( &aout_owner(p_aout)->volume.lock );
-}
-
-static inline void aout_unlock_volume( audio_output_t *p_aout )
-{
-    aout_unlock_check( VOLUME_LOCK );
-    vlc_mutex_unlock( &aout_owner(p_aout)->volume.lock );
-}
-
-/* Helpers */
-
-/**
- * This function will safely mark aout input to be restarted as soon as
- * possible to take configuration changes into account */
-static inline void AoutInputsMarkToRestart( audio_output_t *p_aout )
+int aout_DecNew(audio_output_t *, const audio_sample_format_t *,
+                const audio_replay_gain_t *, const aout_request_vout_t *);
+void aout_DecDelete(audio_output_t *);
+int aout_DecPlay(audio_output_t *, block_t *, int i_input_rate);
+int aout_DecGetResetLost(audio_output_t *);
+void aout_DecChangePause(audio_output_t *, bool b_paused, mtime_t i_date);
+void aout_DecFlush(audio_output_t *, bool wait);
+void aout_RequestRestart (audio_output_t *, unsigned);
+
+static inline void aout_InputRequestRestart(audio_output_t *aout)
 {
-    aout_lock( p_aout );
-    if( aout_owner(p_aout)->input != NULL )
-        aout_owner(p_aout)->input->b_restart = true;
-    aout_unlock( p_aout );
+    aout_RequestRestart(aout, AOUT_RESTART_FILTERS);
 }
 
 #endif /* !LIBVLC_AOUT_INTERNAL_H */