]> git.sesse.net Git - vlc/commitdiff
. Attempt to port the BeOS audio plugin to the new module API. Will
authorSam Hocevar <sam@videolan.org>
Fri, 12 Jan 2001 13:15:42 +0000 (13:15 +0000)
committerSam Hocevar <sam@videolan.org>
Fri, 12 Jan 2001 13:15:42 +0000 (13:15 +0000)
    probably need a few fixes to work or even compile.

plugins/beos/aout_beos.cpp
plugins/beos/beos.cpp
plugins/dsp/aout_dsp.c

index b1d22457e787afd16de82e7f3b4d1fcef9bc775f..d9f334537a4497ac0746e883255891ef7da263e5 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
- * aout_beos.cpp: beos interface
+ * aout_beos.cpp: BeOS audio output
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: aout_beos.cpp,v 1.8 2001/01/07 16:17:58 sam Exp $
+ * $Id: aout_beos.cpp,v 1.9 2001/01/12 13:15:42 sam Exp $
  *
  * Authors:
  * Samuel Hocevar <sam@via.ecp.fr>
@@ -50,15 +50,16 @@ extern "C"
 #include "audio_output.h"
 
 #include "intf_msg.h"
-
 #include "main.h"
+
+#include "modules.h"
 }
 
 /*****************************************************************************
- * aout_sys_t: esd audio output method descriptor
+ * aout_sys_t: BeOS audio output method descriptor
  *****************************************************************************
  * This structure is part of the audio output thread descriptor.
- * It describes some esd specific variables.
+ * It describes some BeOS specific variables.
  *****************************************************************************/
 typedef struct aout_sys_s
 {
@@ -74,9 +75,44 @@ extern "C"
 {
 
 /*****************************************************************************
- * aout_BeOpen: opens a BPushGameSound
+ * 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 aout_getfunctions( function_list_t * p_function_list )
+{
+    p_function_list->p_probe = aout_Probe;
+    p_function_list->functions.aout.p_open = aout_Open;
+    p_function_list->functions.aout.p_setformat = aout_SetFormat;
+    p_function_list->functions.aout.p_getbufinfo = aout_GetBufInfo;
+    p_function_list->functions.aout.p_play = aout_Play;
+    p_function_list->functions.aout.p_close = aout_Close;
+}
+
+/*****************************************************************************
+ * aout_Probe: probe the audio device and return a score
+ *****************************************************************************/
+int aout_Probe( aout_thread_t *p_aout )
+{
+    /* We don't test anything since I don't know what to test. However
+     * if the module could be loaded it is quite likely to work. */
+    return( 100 );
+}
+
+/*****************************************************************************
+ * aout_Open: opens a BPushGameSound
  *****************************************************************************/
-int aout_BeOpen( aout_thread_t *p_aout )
+int aout_Open( aout_thread_t *p_aout )
 {
     /* Allocate structure */
     p_aout->p_sys = (aout_sys_t*) malloc( sizeof( aout_sys_t ) );
@@ -137,17 +173,17 @@ int aout_BeOpen( aout_thread_t *p_aout )
 }
 
 /*****************************************************************************
- * aout_BeSetFormat: sets the dsp output format
+ * aout_SetFormat: sets the dsp output format
  *****************************************************************************/
-int aout_BeSetFormat( aout_thread_t *p_aout )
+int aout_SetFormat( aout_thread_t *p_aout )
 {
     return( 0 );
 }
 
 /*****************************************************************************
- * aout_BeGetBufInfo: buffer status query
+ * aout_GetBufInfo: buffer status query
  *****************************************************************************/
-long aout_BeGetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
+long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
 {
     /* Each value is 4 bytes long (stereo signed 16 bits) */
     long i_hard_pos = 4 * p_aout->p_sys->p_sound->CurrentPosition();
@@ -162,11 +198,11 @@ long aout_BeGetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
 }
 
 /*****************************************************************************
- * aout_BePlay: plays a sound samples buffer
+ * aout_Play: plays a sound samples buffer
  *****************************************************************************
  * This function writes a buffer of i_length bytes in the dsp
  *****************************************************************************/
-void aout_BePlay( aout_thread_t *p_aout, byte_t *buffer, int i_size )
+void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
 {
     long i_newbuf_pos;
 
@@ -196,9 +232,9 @@ void aout_BePlay( aout_thread_t *p_aout, byte_t *buffer, int i_size )
 }
 
 /*****************************************************************************
- * aout_BeClose: closes the dsp audio device
+ * aout_Close: closes the dsp audio device
  *****************************************************************************/
-void aout_BeClose( aout_thread_t *p_aout )
+void aout_Close( aout_thread_t *p_aout )
 {
     p_aout->p_sys->p_sound->UnlockCyclic();
     p_aout->p_sys->p_sound->StopPlaying( );
index 916e583dcf3143cab592c7ec55e76e9be1198c7c..6f38039f1f0454cc33f76568d40924968636b5c1 100644 (file)
@@ -20,6 +20,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME beos
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -40,24 +42,87 @@ extern "C"
 #include "video.h"
 #include "video_output.h"
 
+#include "modules.h"
+#include "modules_inner.h"
+
+/*****************************************************************************
+ * Build configuration tree.
+ *****************************************************************************/
+MODULE_CONFIG_START
+ADD_WINDOW( "Configuration for BeOS module" )
+    ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
+MODULE_CONFIG_END
+
+/*****************************************************************************
+ * Capabilities defined in the other files.
+ *****************************************************************************/
+extern void aout_getfunctions( function_list_t * p_function_list );
+
+/*****************************************************************************
+ * InitModule: get the module structure and configuration.
+ *****************************************************************************
+ * We have to fill psz_name, psz_longname and psz_version. These variables
+ * will be strdup()ed later by the main application because the module can
+ * be unloaded later to save memory, and we want to be able to access this
+ * data even after the module has been unloaded.
+ *****************************************************************************/
+int InitModule( module_t * p_module )
+{
+    p_module->psz_name = MODULE_STRING;
+    p_module->psz_longname = "BeOS standard API module";
+    p_module->psz_version = VERSION;
+
+    p_module->i_capabilities = MODULE_CAPABILITY_NULL
+                                | MODULE_CAPABILITY_AOUT;
+
+    return( 0 );
+}
+
+/*****************************************************************************
+ * ActivateModule: set the module to an usable state.
+ *****************************************************************************
+ * This function fills the capability functions and the configuration
+ * structure. Once ActivateModule() has been called, the i_usage can
+ * be set to 0 and calls to NeedModule() be made to increment it. To unload
+ * the module, one has to wait until i_usage == 0 and call DeactivateModule().
+ *****************************************************************************/
+int ActivateModule( module_t * p_module )
+{
+    p_module->p_functions = malloc( sizeof( module_functions_t ) );
+    if( p_module->p_functions == NULL )
+    {
+        return( -1 );
+    }
+
+    aout_getfunctions( &p_module->p_functions->aout );
+
+    p_module->p_config = p_config;
+
+    return( 0 );
+}
+
+/*****************************************************************************
+ * DeactivateModule: make sure the module can be unloaded.
+ *****************************************************************************
+ * This function must only be called when i_usage == 0. If it successfully
+ * returns, i_usage can be set to -1 and the module unloaded. Be careful to
+ * lock usage_lock during the whole process.
+ *****************************************************************************/
+int DeactivateModule( module_t * p_module )
+{
+    free( p_module->p_functions );
+
+    return( 0 );
+}
+
+/* OLD MODULE STRUCTURE -- soon to be removed */
+
 /*****************************************************************************
  * Exported prototypes
  *****************************************************************************/
-static void aout_GetPlugin( p_aout_thread_t p_aout );
 static void vout_GetPlugin( p_vout_thread_t p_vout );
 static void intf_GetPlugin( p_intf_thread_t p_intf );
 
-/* Audio output */
-int     aout_BeOpen         ( aout_thread_t *p_aout );
-int     aout_BeReset        ( aout_thread_t *p_aout );
-int     aout_BeSetFormat    ( aout_thread_t *p_aout );
-int     aout_BeSetChannels  ( aout_thread_t *p_aout );
-int     aout_BeSetRate      ( aout_thread_t *p_aout );
-long    aout_BeGetBufInfo   ( aout_thread_t *p_aout, long l_buffer_info );
-void    aout_BePlay         ( aout_thread_t *p_aout, byte_t *buffer,
-                              int i_size );
-void    aout_BeClose        ( aout_thread_t *p_aout );
-
 /* Video output */
 int     vout_BeCreate       ( vout_thread_t *p_vout, char *psz_display,
                               int i_root_window, void *p_data );
@@ -85,7 +150,7 @@ plugin_info_t * GetConfig( void )
     p_info->psz_version = VERSION;
     p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
 
-    p_info->aout_GetPlugin = aout_GetPlugin;
+    p_info->aout_GetPlugin = NULL;
     p_info->vout_GetPlugin = vout_GetPlugin;
     p_info->intf_GetPlugin = intf_GetPlugin;
     p_info->yuv_GetPlugin = NULL;
@@ -100,15 +165,6 @@ plugin_info_t * GetConfig( void )
  * Following functions are only called through the p_info structure
  *****************************************************************************/
 
-static void aout_GetPlugin( p_aout_thread_t p_aout )
-{
-    p_aout->p_open        = aout_BeOpen;
-    p_aout->p_setformat   = aout_BeSetFormat;
-    p_aout->p_getbufinfo  = aout_BeGetBufInfo;
-    p_aout->p_play        = aout_BePlay;
-    p_aout->p_close       = aout_BeClose;
-}
-
 static void vout_GetPlugin( p_vout_thread_t p_vout )
 {
     p_vout->p_sys_create  = vout_BeCreate;
index 4569523f8164cf93dce918245b4aa4d212865c33..4f99591424addc96f2df68f66b4b625dd2e7323f 100644 (file)
@@ -101,10 +101,10 @@ void aout_getfunctions( function_list_t * p_function_list )
 }
 
 /*****************************************************************************
- * aout_Probe: probes the audio device and return a score
+ * aout_Probe: probe 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 
+ * This function tries to open the DSP and returns a score to the plugin
+ * manager so that it can choose the most appropriate one.
  *****************************************************************************/
 static int aout_Probe( probedata_t *p_data )
 {