]> 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 184ae3f692fdd92a50298b197d6e0f8c94af2013..701e116194f2b9fef1cdca696ae19c99782a8485 100644 (file)
@@ -74,15 +74,36 @@ 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
  *****************************************************************************/
 aout_thread_t *aout_CreateThread( int *pi_status )
 {
     aout_thread_t * p_aout;                             /* thread descriptor */
-    char * psz_method;
+    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 */
@@ -92,32 +113,41 @@ aout_thread_t *aout_CreateThread( int *pi_status )
         return( NULL );
     }
 
-    /* Request an interface plugin */
-    psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD );
-    
-    if( RequestPlugin( &p_aout->aout_plugin, "aout", psz_method ) )
+    /* Get a suitable audio plugin */
+    for( i_index = 0 ; i_index < p_main->p_bank->i_plugin_count ; i_index++ )
+    {
+        /* If there's a plugin in p_info ... */
+        if( p_main->p_bank->p_info[ i_index ] != NULL )
+        {
+            /* ... and if this plugin provides the functions we want ... */
+            if( p_main->p_bank->p_info[ i_index ]->aout_GetPlugin != NULL )
+            {
+                /* ... 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 )
     {
-        intf_ErrMsg( "error: could not open audio plugin aout_%s.so\n", psz_method );
         free( p_aout );
         return( NULL );
     }
 
-    /* Get plugins */
-    p_aout->p_sys_open =         GetPluginFunction( p_aout->aout_plugin, "aout_SysOpen" );
-    p_aout->p_sys_reset =        GetPluginFunction( p_aout->aout_plugin, "aout_SysReset" );
-    p_aout->p_sys_setformat =    GetPluginFunction( p_aout->aout_plugin, "aout_SysSetFormat" );
-    p_aout->p_sys_setchannels =  GetPluginFunction( p_aout->aout_plugin, "aout_SysSetChannels" );
-    p_aout->p_sys_setrate =      GetPluginFunction( p_aout->aout_plugin, "aout_SysSetRate" );
-    p_aout->p_sys_getbufinfo =   GetPluginFunction( p_aout->aout_plugin, "aout_SysGetBufInfo" );
-    p_aout->p_sys_playsamples =  GetPluginFunction( p_aout->aout_plugin, "aout_SysPlaySamples" );
-    p_aout->p_sys_close =        GetPluginFunction( p_aout->aout_plugin, "aout_SysClose" );
+    /* Get the plugin functions */
+    ( (aout_getplugin_t *)
+      p_main->p_bank->p_info[ i_best_index ]->aout_GetPlugin )( p_aout );
 
     /*
      * Initialize audio device
      */
     if ( p_aout->p_sys_open( p_aout ) )
     {
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
@@ -128,36 +158,30 @@ aout_thread_t *aout_CreateThread( int *pi_status )
     if ( p_aout->p_sys_reset( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
     if ( p_aout->p_sys_setformat( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
     if ( p_aout->p_sys_setchannels( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
     if ( p_aout->p_sys_setrate( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
 
     /* Initialize the vomue level */
     p_aout->vol = VOL;
-
-
     
     /* FIXME: maybe it would be cleaner to change SpawnThread prototype
      * see vout to handle status correctly ?? however, it is not critical since
@@ -165,7 +189,6 @@ aout_thread_t *aout_CreateThread( int *pi_status )
     if( aout_SpawnThread( p_aout ) )
     {
         p_aout->p_sys_close( p_aout );
-        TrashPlugin( p_aout->aout_plugin );
         free( p_aout );
         return( NULL );
     }
@@ -332,9 +355,6 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
     p_aout->p_sys_close( p_aout );
     intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->psz_device);
 
-    /* Close plugin */
-    TrashPlugin( p_aout->aout_plugin );
-
     /* Free structure */
     free( p_aout );
 }
@@ -466,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
  *****************************************************************************/
@@ -581,18 +582,18 @@ void aout_Thread_U8_Mono( aout_thread_t * p_aout )
     {
         vlc_mutex_lock( &p_aout->fifos_lock );
         for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
-       {
+        {
             switch ( p_aout->fifo[i_fifo].i_type )
-           {
+            {
                case AOUT_EMPTY_FIFO:
                     break;
 
                case AOUT_INTF_MONO_FIFO:
                     if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
-                   {
+                    {
                         l_buffer = 0;
                         while ( l_buffer < (p_aout->l_units /*<< 1*/) ) /* p_aout->b_stereo == 1 */
-                       {
+                        {
                             p_aout->s32_buffer[l_buffer++] +=
                                 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
                             p_aout->s32_buffer[l_buffer++] +=
@@ -602,10 +603,10 @@ void aout_Thread_U8_Mono( aout_thread_t * p_aout )
                         p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
                     }
                     else
-                   {
+                    {
                         l_buffer = 0;
                         while ( l_buffer < (p_aout->fifo[i_fifo].l_units /*<< 1*/) ) /* p_aout->b_stereo == 1 */
-                       {
+                        {
                             p_aout->s32_buffer[l_buffer++] +=
                                 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
                             p_aout->s32_buffer[l_buffer++] +=
@@ -620,10 +621,10 @@ void aout_Thread_U8_Mono( aout_thread_t * p_aout )
 
                 case AOUT_INTF_STEREO_FIFO:
                     if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
-                   {
+                    {
                         l_buffer = 0;
                         while ( l_buffer < (p_aout->l_units /*<< 1*/) ) /* p_aout->b_stereo == 1 */
-                       {
+                        {
                             p_aout->s32_buffer[l_buffer++] +=
                                 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
                             p_aout->s32_buffer[l_buffer++] +=
@@ -633,10 +634,10 @@ void aout_Thread_U8_Mono( aout_thread_t * p_aout )
                         p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
                     }
                     else
-                   {
+                    {
                         l_buffer = 0;
                         while ( l_buffer < (p_aout->fifo[i_fifo].l_units /*<< 1*/) ) /* p_aout->b_stereo == 1 */
-                       {
+                        {
                             p_aout->s32_buffer[l_buffer++] +=
                                 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
                             p_aout->s32_buffer[l_buffer++] +=
@@ -748,7 +749,7 @@ void aout_Thread_U8_Mono( aout_thread_t * p_aout )
                             }
                         }
 #define SOUND 1
-#define DEBUG 0
+#define ADEBUG 0
 #define COEFF 2
                         if ( p_aout->fifo[i_fifo].l_units > l_units )
                         {
@@ -773,7 +774,7 @@ l_buffer++;
 */
 #endif
 
-#if DEBUG 
+#if ADEBUG 
 //intf_DbgMsg( "p_aout->s32_buffer[l_buffer] 11 : %x (%d)",p_aout->s32_buffer[l_buffer-1],p_aout->s32_buffer[l_buffer-1] );
 intf_DbgMsg( "p_aout->fifo %ld\n",COEFF*p_aout->fifo[i_fifo].l_unit );
 intf_DbgMsg( "%d - p_aout->s32b %ld\n", l_buffer, (s32) ( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ) );
@@ -824,7 +825,7 @@ if( COEFF*p_aout->fifo[i_fifo].l_unit < 60000 )
 */
 #endif
 
-#if DEBUG
+#if ADEBUG
 //intf_DbgMsg( "p_aout->s32_buffer[l_buffer] 21 : %x (%d)",p_aout->s32_buffer[l_buffer-1],p_aout->s32_buffer[l_buffer-1] );
 intf_DbgMsg( "p_aout->fifo %ld\n",COEFF*p_aout->fifo[i_fifo].l_unit );
 intf_DbgMsg( "%d - p_aout->s32b %ld\n", l_buffer, (s32) ( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ) );
@@ -927,7 +928,6 @@ intf_DbgMsg( "%d - p_aout->s32b %ld\n", l_buffer, (s32) ( ((s16 *)p_aout->fifo[i
     }
     vlc_mutex_unlock( &p_aout->fifos_lock );
 
-
 }
 
 void aout_Thread_U8_Stereo( aout_thread_t * p_aout )