]> git.sesse.net Git - vlc/blobdiff - plugins/esd/aout_esd.c
* Fixed the BeOS compile typo.
[vlc] / plugins / esd / aout_esd.c
index ea35b162acc776b92bc53196bb6ffe5989ddb6cf..182fd18afa97f29b09a48b65a56369f500c067af 100644 (file)
@@ -2,6 +2,7 @@
  * aout_esd.c : Esound functions library
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
+ * $Id: aout_esd.c,v 1.13 2001/05/30 17:03:12 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -20,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME esd
+#include "modules_inner.h"
+
 /* TODO:
  *
  * - use the libesd function to get latency when it's not buggy anymore
@@ -44,7 +48,7 @@
 #include "common.h"                                     /* boolean_t, byte_t */
 #include "threads.h"
 #include "mtime.h"
-#include "plugins.h"
+#include "tests.h"
 
 #include "audio_output.h"                                   /* aout_thread_t */
 
@@ -52,6 +56,7 @@
 #include "main.h"
 
 #include "modules.h"
+#include "modules_export.h"
 
 /*****************************************************************************
  * aout_sys_t: esd audio output method descriptor
@@ -80,7 +85,7 @@ static void    aout_Close       ( aout_thread_t *p_aout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void aout_getfunctions( function_list_t * p_function_list )
+void _M( aout_getfunctions )( function_list_t * p_function_list )
 {
     p_function_list->pf_probe = aout_Probe;
     p_function_list->functions.aout.pf_open = aout_Open;
@@ -98,6 +103,11 @@ void aout_getfunctions( function_list_t * p_function_list )
  *****************************************************************************/
 static int aout_Probe( probedata_t *p_data )
 {
+    if( TestMethod( AOUT_METHOD_VAR, "esd" ) )
+    {
+        return( 999 );
+    }
+
     /* We don't have to test anything -- if we managed to open this plugin,
      * it means we have the appropriate libs. */
     return( 50 );
@@ -132,9 +142,13 @@ static int aout_Open( aout_thread_t *p_aout )
     p_aout->p_sys->esd_format = (i_bits | i_mode | i_func) & (~ESD_MASK_CHAN);
 
     if( p_aout->i_channels == 1 )
+    {
         p_aout->p_sys->esd_format |= ESD_MONO;
+    }
     else
+    {
         p_aout->p_sys->esd_format |= ESD_STEREO;
+    }
 
     /* open a socket for playing a stream
      * and try to open /dev/dsp if there's no EsounD */
@@ -148,6 +162,10 @@ static int aout_Open( aout_thread_t *p_aout )
         return( -1 );
     }
 
+    intf_ErrMsg( "aout error: you are using the Esound plugin. There is no way yet to get the\n"
+                 "            driver latency because esd_get_latency() hangs, so expect a one\n"
+                 "            second delay with sound. Type `esdctl off' to disable esd." );
+
     return( 0 );
 }
 
@@ -175,25 +193,31 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
  *****************************************************************************/
 static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
 {
-    int amount;
+    int i_amount;
 
     if (p_aout->p_sys->esd_format & ESD_STEREO)
     {
         if (p_aout->p_sys->esd_format & ESD_BITS16)
-            amount = (44100 * (ESD_BUF_SIZE + 64)) / p_aout->l_rate;
+        {
+            i_amount = (44100 * (ESD_BUF_SIZE + 64)) / p_aout->l_rate;
+        }
         else
-            amount = (44100 * (ESD_BUF_SIZE + 128)) / p_aout->l_rate;
+        {
+            i_amount = (44100 * (ESD_BUF_SIZE + 128)) / p_aout->l_rate;
+        }
     }
     else
     {
         if (p_aout->p_sys->esd_format & ESD_BITS16)
-            amount = (2 * 44100 * (ESD_BUF_SIZE + 128)) / p_aout->l_rate;
+        {
+            i_amount = (2 * 44100 * (ESD_BUF_SIZE + 128)) / p_aout->l_rate;
+        }
         else
-            amount = (2 * 44100 * (ESD_BUF_SIZE + 256)) / p_aout->l_rate;
+        {
+            i_amount = (2 * 44100 * (ESD_BUF_SIZE + 256)) / p_aout->l_rate;
+        }
     }
 
-    intf_DbgMsg( "aout: latency is %i", amount );
-
     write( p_aout->i_fd, buffer, i_size );
 }