Commit 4af9ab12 authored by Henri Fallon's avatar Henri Fallon

Done :
- ported the alsa plugin to the news vlc module API
- cosmetic changes

To do :
- check if it works with the latest alsa release
- add features ... prepare for 4 or more speakers
parent a85534e5
......@@ -506,7 +506,7 @@ lib/dsp.so: $(PLUGIN_DSP)
$(CC) $(PCFLAGS) -shared -o $@ $^
lib/alsa.so: $(PLUGIN_ALSA)
$(CC) $(PCFLAGS) -shared -o $@ $^
$(CC) $(PCFLAGS) -shared -o $@ $^ -lasound
lib/null.so: $(PLUGIN_NULL)
$(CC) $(PCFLAGS) -shared -o $@ $^
......
/*****************************************************************************
* dsp.c : OSS /dev/dsp plugin for vlc
* alsa.c : alsa plugin for vlc
*****************************************************************************
* Copyright (C) 2000 VideoLAN
*
......@@ -21,81 +21,99 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#define MODULE_NAME alsa
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "defs.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/asoundlib.h> /* for alsa :) */
#include <linux/asound.h>
#include <fcntl.h>
#include <stdlib.h> /* malloc(), free() */
// #include <unistd.h> /* close() */
#include "config.h"
#include "common.h" /* boolean_t, byte_t */
#include "threads.h"
#include "mtime.h"
#include "tests.h"
#include "plugins.h"
#include "interface.h"
#include "audio_output.h"
#include "video.h"
#include "video_output.h"
#include "main.h"
#include "modules.h"
#include "modules_inner.h"
/*****************************************************************************
* Exported prototypes
* Build configuration tree.
*****************************************************************************/
static void aout_GetPlugin( p_aout_thread_t p_aout );
MODULE_CONFIG_START
ADD_COMMENT( "Yeah, alsa rocks !" )
MODULE_CONFIG_END
/* Audio output */
int aout_AlsaOpen ( aout_thread_t *p_aout );
int aout_AlsaSetFormat ( aout_thread_t *p_aout );
long aout_AlsaGetBufInfo ( aout_thread_t *p_aout, long l_buffer_info );
void aout_AlsaPlay ( aout_thread_t *p_aout, byte_t *buffer,
int i_size );
void aout_AlsaClose ( aout_thread_t *p_aout );
/*****************************************************************************
* Capabilities defined in the other files.
*****************************************************************************/
extern void aout_getfunctions( function_list_t * p_function_list );
/*****************************************************************************
* GetConfig: get the plugin structure and configuration
* 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.
*****************************************************************************/
plugin_info_t * GetConfig( void )
int InitModule( module_t * p_module )
{
plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
p_info->psz_name = "Alsa plugin";
p_info->psz_version = VERSION;
p_info->psz_author = "the VideoLAN team <vlc@videolan.org>";
p_info->aout_GetPlugin = aout_GetPlugin;
p_info->vout_GetPlugin = NULL;
p_info->intf_GetPlugin = NULL;
p_info->yuv_GetPlugin = NULL;
/* TODO : test if alsa is available */
p_info->i_score = 0x100;
p_module->psz_name = MODULE_STRING;
p_module->psz_longname = "Alsa audio module";
p_module->psz_version = VERSION;
p_module->i_capabilities = MODULE_CAPABILITY_NULL
| MODULE_CAPABILITY_AOUT;
return( 0 );
}
/* If this plugin was requested, score it higher */
if( TestMethod( AOUT_METHOD_VAR, "alsa" ) )
/*****************************************************************************
* 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 )
{
p_info->i_score += 0x200;
return( -1 );
}
return( p_info );
aout_getfunctions( &p_module->p_functions->aout );
p_module->p_config = p_config;
return( 0 );
}
/*****************************************************************************
* Following functions are only called through the p_info structure
* 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.
*****************************************************************************/
static void aout_GetPlugin( p_aout_thread_t p_aout )
int DeactivateModule( module_t * p_module )
{
p_aout->p_open = aout_AlsaOpen;
p_aout->p_setformat = aout_AlsaSetFormat;
p_aout->p_getbufinfo = aout_AlsaGetBufInfo;
p_aout->p_play = aout_AlsaPlay;
p_aout->p_close = aout_AlsaClose;
free( p_module->p_functions );
return( 0 );
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment