]> git.sesse.net Git - vlc/blobdiff - src/audio_output/audio_output.c
. rajout de l'option -Winline
[vlc] / src / audio_output / audio_output.c
index 7f08657e796455cc0c0ed727213d3d5e9afb1a07..701e116194f2b9fef1cdca696ae19c99782a8485 100644 (file)
@@ -74,6 +74,25 @@ void aout_Thread_U16_Stereo     ( aout_thread_t * p_aout );
 static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator );
 static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date );
 
+/*****************************************************************************
+ * InitializeIncrement
+ *****************************************************************************/
+static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator )
+{
+    p_increment->l_remainder = -l_denominator;
+
+    p_increment->l_euclidean_integer = 0;
+    while ( l_numerator >= l_denominator )
+    {
+        p_increment->l_euclidean_integer++;
+        l_numerator -= l_denominator;
+    }
+
+    p_increment->l_euclidean_remainder = l_numerator;
+
+    p_increment->l_euclidean_denominator = l_denominator;
+}
+
 /*****************************************************************************
  * aout_CreateThread: initialize audio thread
  *****************************************************************************/
@@ -82,8 +101,9 @@ aout_thread_t *aout_CreateThread( int *pi_status )
     aout_thread_t * p_aout;                             /* thread descriptor */
     typedef void    ( aout_getplugin_t ) ( aout_thread_t * p_aout );
     int             i_index;
+    int             i_best_index = 0, i_best_score = 0;
 #if 0
-    int             i_status;                                 /* thread status */
+    int             i_status;                               /* thread status */
 #endif
 
     /* Allocate descriptor */
@@ -102,13 +122,27 @@ aout_thread_t *aout_CreateThread( int *pi_status )
             /* ... and if this plugin provides the functions we want ... */
             if( p_main->p_bank->p_info[ i_index ]->aout_GetPlugin != NULL )
             {
-                /* ... then get these functions */
-                ( (aout_getplugin_t *)
-                  p_main->p_bank->p_info[ i_index ]->aout_GetPlugin )( p_aout );
+                /* ... and if this plugin has a good score ... */
+                if( p_main->p_bank->p_info[ i_index ]->i_score > i_best_score )
+                {
+                    /* ... then take it */
+                    i_best_score = p_main->p_bank->p_info[ i_index ]->i_score;
+                    i_best_index = i_index;
+                }
             }
         }
     }
 
+    if( i_best_score == 0 )
+    {
+        free( p_aout );
+        return( NULL );
+    }
+
+    /* Get the plugin functions */
+    ( (aout_getplugin_t *)
+      p_main->p_bank->p_info[ i_best_index ]->aout_GetPlugin )( p_aout );
+
     /*
      * Initialize audio device
      */
@@ -452,25 +486,6 @@ void aout_DestroyFifo( aout_fifo_t * p_fifo )
 
 /* Following functions are local */
 
-/*****************************************************************************
- * InitializeIncrement
- *****************************************************************************/
-static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator )
-{
-    p_increment->l_remainder = -l_denominator;
-
-    p_increment->l_euclidean_integer = 0;
-    while ( l_numerator >= l_denominator )
-    {
-        p_increment->l_euclidean_integer++;
-        l_numerator -= l_denominator;
-    }
-
-    p_increment->l_euclidean_remainder = l_numerator;
-
-    p_increment->l_euclidean_denominator = l_denominator;
-}
-
 /*****************************************************************************
  * NextFrame
  *****************************************************************************/