]> git.sesse.net Git - vlc/blobdiff - src/audio_output/aout_internal.h
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / audio_output / aout_internal.h
index a2acd1809ecb7c340ec0f509bb35a80aad1832c2..0d9da2a5641e1540e5e992202e3399fc0173b003 100644 (file)
@@ -108,6 +108,7 @@ int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input, const aout_
 int aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input );
 int aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input,
                     aout_buffer_t * p_buffer, int i_input_rate );
+void aout_InputCheckAndRestart( aout_instance_t * p_aout, aout_input_t * p_input );
 
 /* From filters.c : */
 int aout_FiltersCreatePipeline ( aout_instance_t * p_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 );
@@ -141,7 +142,7 @@ void aout_FifoSet( aout_instance_t *, aout_fifo_t *, mtime_t );
 void aout_FifoMoveDates( aout_instance_t *, aout_fifo_t *, mtime_t );
 void aout_FifoDestroy( aout_instance_t * p_aout, aout_fifo_t * p_fifo );
 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 );
-
+bool aout_ChangeFilterString( vlc_object_t *, aout_instance_t *, const char *psz_variable, const char *psz_name, bool b_add );
 
 /* From intf.c :*/
 int aout_VolumeSoftGet( aout_instance_t *, audio_volume_t * );
@@ -164,50 +165,94 @@ int aout_DecGetResetLost( aout_instance_t *, aout_input_t * );
 void aout_DecChangePause( aout_instance_t *, aout_input_t *, bool b_paused, mtime_t i_date );
 void aout_DecFlush( aout_instance_t *, aout_input_t * );
 
-/* Helpers */
+/* Audio output locking */
+
+#if !defined (NDEBUG) \
+ && defined __linux__ && (defined (__i386__) || defined (__x86_64__))
+# define AOUT_DEBUG 1
+#endif
+
+#ifdef AOUT_DEBUG
+enum
+{
+    MIXER_LOCK=1,
+    INPUT_LOCK=2,
+    INPUT_FIFO_LOCK=4,
+    OUTPUT_FIFO_LOCK=8,
+    VOLUME_VARS_LOCK=16
+};
+
+void aout_lock (unsigned);
+void aout_unlock (unsigned);
+
+#else
+# define aout_lock( i )   (void)0
+# define aout_unlock( i ) (void)0
+#endif
 
 static inline void aout_lock_mixer( aout_instance_t *p_aout )
 {
+    aout_lock( MIXER_LOCK );
     vlc_mutex_lock( &p_aout->mixer_lock );
 }
 
 static inline void aout_unlock_mixer( aout_instance_t *p_aout )
 {
+    aout_unlock( MIXER_LOCK );
     vlc_mutex_unlock( &p_aout->mixer_lock );
 }
 
 static inline void aout_lock_input_fifos( aout_instance_t *p_aout )
 {
+    aout_lock( INPUT_FIFO_LOCK );
     vlc_mutex_lock( &p_aout->input_fifos_lock );
 }
 
 static inline void aout_unlock_input_fifos( aout_instance_t *p_aout )
 {
+    aout_unlock( INPUT_FIFO_LOCK );
     vlc_mutex_unlock( &p_aout->input_fifos_lock );
 }
 
 static inline void aout_lock_output_fifo( aout_instance_t *p_aout )
 {
+    aout_lock( OUTPUT_FIFO_LOCK );
     vlc_mutex_lock( &p_aout->output_fifo_lock );
 }
 
 static inline void aout_unlock_output_fifo( aout_instance_t *p_aout )
 {
+    aout_unlock( OUTPUT_FIFO_LOCK );
     vlc_mutex_unlock( &p_aout->output_fifo_lock );
 }
 
 static inline void aout_lock_input( aout_instance_t *p_aout, aout_input_t * p_input )
 {
     (void)p_aout;
+    aout_lock( INPUT_LOCK );
     vlc_mutex_lock( &p_input->lock );
 }
 
 static inline void aout_unlock_input( aout_instance_t *p_aout, aout_input_t * p_input )
 {
     (void)p_aout;
+    aout_unlock( INPUT_LOCK );
     vlc_mutex_unlock( &p_input->lock );
 }
 
+static inline void aout_lock_volume( aout_instance_t *p_aout )
+{
+    aout_lock( VOLUME_VARS_LOCK );
+    vlc_mutex_lock( &p_aout->volume_vars_lock );
+}
+
+static inline void aout_unlock_volume( aout_instance_t *p_aout )
+{
+    aout_unlock( VOLUME_VARS_LOCK );
+    vlc_mutex_unlock( &p_aout->volume_vars_lock );
+}
+
+/* Helpers */
 
 /**
  * This function will safely mark aout input to be restarted as soon as
@@ -221,66 +266,4 @@ static inline void AoutInputsMarkToRestart( aout_instance_t *p_aout )
     aout_unlock_mixer( p_aout );
 }
 
-/* This function will add or remove a a module from a string list (comma
- * separated). It will return true if there is a modification
- * In case p_aout is NULL, we will use configuration instead of variable */
-static inline bool AoutChangeFilterString( vlc_object_t *p_obj, aout_instance_t * p_aout,
-                                           const char* psz_variable,
-                                           const char *psz_name, bool b_add )
-{
-    char *psz_val;
-    char *psz_parser;
-
-    if( *psz_name == '\0' )
-        return false;
-
-    if( p_aout )
-        psz_val = var_GetString( p_aout, psz_variable );
-    else
-        psz_val = config_GetPsz( p_obj, "audio-filter" );
-
-    if( !psz_val )
-        psz_val = strdup( "" );
-
-    psz_parser = strstr( psz_val, psz_name );
-
-    if( ( b_add && psz_parser ) || ( !b_add && !psz_parser ) )
-    {
-        /* Nothing to do */
-        free( psz_val );
-        return false;
-    }
-
-    if( b_add )
-    {
-        char *psz_old = psz_val;
-        if( *psz_old )
-        {
-            if( asprintf( &psz_val, "%s:%s", psz_old, psz_name ) == -1 )
-                psz_val = NULL;
-        }
-        else
-            psz_val = strdup( psz_name );
-        free( psz_old );
-    }
-    else
-    {
-        const int i_name = strlen( psz_name );
-        const char *psz_next;
-
-        psz_next = &psz_parser[i_name];
-        if( *psz_next == ':' )
-            psz_next++;
-
-        memmove( psz_parser, psz_next, strlen(psz_next)+1 );
-    }
-
-    if( p_aout )
-        var_SetString( p_aout, psz_variable, psz_val );
-    else
-        config_PutPsz( p_obj, psz_variable, psz_val );
-    free( psz_val );
-    return true;
-}
-
 #endif /* !__LIBVLC_AOUT_INTERNAL_H */