]> git.sesse.net Git - vlc/blobdiff - plugins/esd/aout_esd.c
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / plugins / esd / aout_esd.c
index 62b188b2fa1f48b55e7df135028f9d0a69abcd20..92b2d2f8116e22421677e795b5a2cfd696f47b42 100644 (file)
@@ -3,7 +3,7 @@
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
  *
- * Authors:
+ * Authors: Samuel Hocevar <sam@zoy.org>
  *
  * 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
@@ -20,6 +20,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
 #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 */
 
 #include "intf_msg.h"                        /* intf_DbgMsg(), intf_ErrMsg() */
 #include "main.h"
 
+#include "modules.h"
+
 /*****************************************************************************
  * aout_sys_t: esd audio output method descriptor
  *****************************************************************************
@@ -64,26 +69,68 @@ typedef struct aout_sys_s
 } aout_sys_t;
 
 /*****************************************************************************
- * aout_EsdOpen: opens an esd socket
+ * Local prototypes.
+ *****************************************************************************/
+static int     aout_Probe       ( probedata_t *p_data );
+static int     aout_Open        ( aout_thread_t *p_aout );
+static int     aout_SetFormat   ( aout_thread_t *p_aout );
+static long    aout_GetBufInfo  ( aout_thread_t *p_aout, long l_buffer_info );
+static void    aout_Play        ( aout_thread_t *p_aout,
+                                  byte_t *buffer, int i_size );
+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 _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;
+    p_function_list->functions.aout.pf_setformat = aout_SetFormat;
+    p_function_list->functions.aout.pf_getbufinfo = aout_GetBufInfo;
+    p_function_list->functions.aout.pf_play = aout_Play;
+    p_function_list->functions.aout.pf_close = aout_Close;
+}
+
+/*****************************************************************************
+ * aout_Probe: probes the audio device and return a score
+ *****************************************************************************
+ * This function tries to open the dps and returns a score to the plugin
+ * manager so that it can 
+ *****************************************************************************/
+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 );
+}
+
+/*****************************************************************************
+ * aout_Open: open an esd socket
  *****************************************************************************/
-int aout_EsdOpen( aout_thread_t *p_aout )
+static int aout_Open( aout_thread_t *p_aout )
 {
     /* mpg123 does it this way */
     int i_bits = ESD_BITS16;
     int i_mode = ESD_STREAM;
     int i_func = ESD_PLAY;
 
-    fprintf(stderr, "aout-esd !!\n");
     /* Allocate structure */
     p_aout->p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_aout->p_sys == NULL )
     {
-        intf_ErrMsg("error: %s\n", strerror(ENOMEM) );
+        intf_ErrMsg("error: %s", strerror(ENOMEM) );
         return( 1 );
     }
 
     /* Initialize some variables */
-    p_aout->i_format = AOUT_DEFAULT_FORMAT;
+    p_aout->i_format = AOUT_FORMAT_DEFAULT;
     p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR, AOUT_STEREO_DEFAULT );
     p_aout->l_rate     = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT );
 
@@ -104,7 +151,7 @@ int aout_EsdOpen( aout_thread_t *p_aout )
                 p_aout->l_rate, NULL, "vlc")) < 0 )
     {
         intf_ErrMsg( "aout error: can't open esound socket"
-                     " (format 0x%08x at %ld Hz)\n",
+                     " (format 0x%08x at %ld Hz)",
                      p_aout->p_sys->esd_format, p_aout->l_rate );
         return( -1 );
     }
@@ -113,52 +160,28 @@ int aout_EsdOpen( aout_thread_t *p_aout )
 }
 
 /*****************************************************************************
- * aout_EsdReset: resets the dsp
- *****************************************************************************/
-int aout_EsdReset( aout_thread_t *p_aout )
-{
-    return( 0 );
-}
-
-/*****************************************************************************
- * aout_EsdSetFormat: sets the dsp output format
- *****************************************************************************/
-int aout_EsdSetFormat( aout_thread_t *p_aout )
-{
-    return( 0 );
-}
-
-/*****************************************************************************
- * aout_EsdSetChannels: sets the dsp's stereo or mono mode
- *****************************************************************************/
-int aout_EsdSetChannels( aout_thread_t *p_aout )
-{
-    return( 0 );
-}
-
-/*****************************************************************************
- * aout_EsdSetRate: sets the dsp's audio output rate
+ * aout_SetFormat: set the output format
  *****************************************************************************/
-int aout_EsdSetRate( aout_thread_t *p_aout )
+static int aout_SetFormat( aout_thread_t *p_aout )
 {
     return( 0 );
 }
 
 /*****************************************************************************
- * aout_EsdGetBufInfo: buffer status query
+ * aout_GetBufInfo: buffer status query
  *****************************************************************************/
-long aout_EsdGetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
+static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
 {
     /* arbitrary value that should be changed */
     return( l_buffer_limit );
 }
 
 /*****************************************************************************
- * aout_EsdPlaySamples: plays a sound samples buffer
+ * aout_Play: play a sound samples buffer
  *****************************************************************************
- * This function writes a buffer of i_length bytes in the dsp
+ * This function writes a buffer of i_length bytes in the socket
  *****************************************************************************/
-void aout_EsdPlaySamples( aout_thread_t *p_aout, byte_t *buffer, int i_size )
+static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
 {
     int amount;
 
@@ -177,15 +200,15 @@ void aout_EsdPlaySamples( aout_thread_t *p_aout, byte_t *buffer, int i_size )
             amount = (2 * 44100 * (ESD_BUF_SIZE + 256)) / p_aout->l_rate;
     }
 
-    intf_DbgMsg( "aout: latency is %i\n", amount );
+    intf_DbgMsg( "aout: latency is %i", amount );
 
     write( p_aout->i_fd, buffer, i_size );
 }
 
 /*****************************************************************************
- * aout_EsdClose: closes the dsp audio device
+ * aout_Close: close the Esound socket
  *****************************************************************************/
-void aout_EsdClose( aout_thread_t *p_aout )
+static void aout_Close( aout_thread_t *p_aout )
 {
     close( p_aout->i_fd );
 }