Commit f8da8c95 authored by Sam Hocevar's avatar Sam Hocevar

. all plugins now compile with -fPIC.

 . made the audio_output API a bit simpler.

 . got rid of modules_config.h.

 . fixed `make install' rule.

 . fixed warnings in the MMX YUV compilation.

 . probably fixed a bug in the input : pp_foo structures were free()d at
   the end, but this was useless since the last call to realloc() is
   equivalent to free(), and two consecutive calls to free() aren't a
   goo idea.

 . we check that the version number match and that we don't already have
   a module by that name when loading a new module.

 . all public module_* functions now properly lock the module bank.

 . the audio_output now uses the new module API ; EsounD and DSP modules
   have been ported, which should be enough for Henri to port the ALSA one.


   The new plugin API is now much simpler ; it's now just a matter of
calling module_Need( p_main->p_module_bank, MODULE_CAPABILITY_FOO, p_data );
and if successful we get the best module. Capabilities can be ORed, so that
one can ask for a plugin that does VOUT _and_ INTF actions for instance.

   It's not complete yet though -- by making it generic I had to do a few
ugly casts here and there, which I am going to fix ASAP. Also, command line
selection of a plugin does not work yet.

   The switch to the new plugin API has probably broken the BeOS audio
output ; we can either wait until the whole vlc has switched to the new
plugins, or create a separate beos_sound.so that conforms to the new API.
parent b7b3386b
......@@ -150,9 +150,7 @@ endif
#
# C compiler flags: plugin compilation
#
ifneq (,$(findstring solaris,$(SYS)))
PCFLAGS += -fPIC
endif
#
# C compiler flags: dependancies
......@@ -407,9 +405,9 @@ install:
mkdir -p $(prefix)/bin
$(INSTALL) vlc $(prefix)/bin
# ugly
for alias in "" @ALIASES@ ; do if test $$alias ; then ln -s vlc $(prefix)/bin/$$alias ; fi ; done
for alias in "" @ALIASES@ ; do if test $$alias ; then rm -f $(prefix)/bin/$$alias && ln -s vlc $(prefix)/bin/$$alias ; fi ; done
mkdir -p $(prefix)/lib/videolan/vlc
$(INSTALL) -m 644 $(PLUGINS) $(prefix)/lib/videolan/vlc
$(INSTALL) -m 644 $(PLUGINS:%=lib/%.so) $(prefix)/lib/videolan/vlc
mkdir -p $(prefix)/share/videolan
$(INSTALL) -m 644 share/*.psf $(prefix)/share/videolan
$(INSTALL) -m 644 share/*.png $(prefix)/share/videolan
......@@ -478,11 +476,11 @@ $(STD_PLUGIN_OBJ): %.o: %.c
$(PLUGIN_GNOME): %.o: Makefile.dep
$(PLUGIN_GNOME): %.o: %.c
$(CC) $(CFLAGS) `gnome-config --cflags gnomeui` -c -o $@ $<
$(CC) $(CFLAGS) $(PCFLAGS) `gnome-config --cflags gnomeui` -c -o $@ $<
$(PLUGIN_GLIDE): %.o: Makefile.dep
$(PLUGIN_GLIDE): %.o: %.c
$(CC) $(CFLAGS) -I/usr/include/glide -c -o $@ $<
$(CC) $(CFLAGS) $(PCFLAGS) -I/usr/include/glide -c -o $@ $<
#
# Real targets
......@@ -501,56 +499,56 @@ lib/beos.so: $(PLUGIN_BEOS)
lib/esd.so: $(PLUGIN_ESD)
ifneq (,$(findstring bsd,$(SYS)))
$(CC) $(LCFLAGS) -shared -lesd -o $@ $^
$(CC) -shared -lesd -o $@ $^ $(LCFLAGS) -lesd
else
$(CC) $(LCFLAGS) -shared -laudiofile -lesd -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS) -laudiofile -lesd
endif
lib/dsp.so: $(PLUGIN_DSP)
$(CC) $(LCFLAGS) -shared -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS)
lib/alsa.so: $(PLUGIN_ALSA)
$(CC) $(LCFLAGS) -shared -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS)
lib/null.so: $(PLUGIN_NULL)
$(CC) $(LCFLAGS) -shared -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS)
lib/dummy.so: $(PLUGIN_DUMMY)
$(CC) $(LCFLAGS) -shared -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS)
lib/fb.so: $(PLUGIN_FB)
$(CC) $(LCFLAGS) -shared -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS)
lib/x11.so: $(PLUGIN_X11)
$(CC) $(LCFLAGS) -shared -L/usr/X11R6/lib -lX11 -lXext -o $@ $^
$(CC) -shared -L/usr/X11R6/lib -o $@ $^ $(LCFLAGS) -lX11 -lXext
lib/mga.so: $(PLUGIN_MGA)
$(CC) $(LCFLAGS) -shared -L/usr/X11R6/lib -lX11 -lXext -o $@ $^
$(CC) -shared -L/usr/X11R6/lib -o $@ $^ $(LCFLAGS) -lX11 -lXext
lib/gnome.so: $(PLUGIN_GNOME)
$(CC) $(LCFLAGS) -shared `gnome-config --libs gnomeui | sed 's,-rdynamic,,'` -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS) `gnome-config --libs gnomeui | sed 's,-rdynamic,,'`
lib/glide.so: $(PLUGIN_GLIDE)
$(CC) $(LCFLAGS) -shared $(LIB_GLIDE) -o $@ $^
$(CC) -shared $(LIB_GLIDE) -o $@ $^ $(LCFLAGS)
lib/ggi.so: $(PLUGIN_GGI)
$(CC) $(LCFLAGS) -shared $(LIB_GGI) -o $@ $^
$(CC) -shared $(LIB_GGI) -o $@ $^ $(LCFLAGS)
lib/sdl.so: $(PLUGIN_SDL)
$(CC) $(LCFLAGS) -shared $(LIB_SDL) -o $@ $^
$(CC) -shared $(LIB_SDL) -o $@ $^ $(LCFLAGS)
lib/yuv.so: $(PLUGIN_YUV)
ifeq ($(SYS),beos)
$(CC) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
else
$(CC) $(LCFLAGS) -shared -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS)
endif
lib/yuvmmx.so: $(PLUGIN_YUVMMX)
ifeq ($(SYS),beos)
$(CC) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
else
$(CC) $(LCFLAGS) -shared -o $@ $^
$(CC) -shared -o $@ $^ $(LCFLAGS)
endif
################################################################################
......
......@@ -6,7 +6,7 @@
#export DH_VERBOSE=1
# This is the debhelper compatability version to use.
export DH_COMPAT=1
export DH_COMPAT=3
build: build-stamp
build-stamp:
......@@ -15,9 +15,9 @@ build-stamp:
./configure --prefix=/usr \
--mandir=\$${prefix}/share/man \
--infodir=\$${prefix}/share/info \
--enable-mmx --enable-gnome --enable-fb \
--enable-ggi --enable-esd --enable-glide \
--enable-sdl
--enable-gnome --enable-fb \
--with-ggi --enable-esd --with-glide \
--with-sdl
$(MAKE)
touch build-stamp
......
......@@ -120,16 +120,13 @@ typedef struct
/*****************************************************************************
* aout_thread_t : audio output thread descriptor
*****************************************************************************/
typedef int (aout_sys_open_t) ( p_aout_thread_t p_aout );
typedef int (aout_sys_reset_t) ( p_aout_thread_t p_aout );
typedef int (aout_sys_setformat_t) ( p_aout_thread_t p_aout );
typedef int (aout_sys_setchannels_t) ( p_aout_thread_t p_aout );
typedef int (aout_sys_setrate_t) ( p_aout_thread_t p_aout );
typedef long (aout_sys_getbufinfo_t) ( p_aout_thread_t p_aout,
long l_buffer_limit );
typedef void (aout_sys_playsamples_t) ( p_aout_thread_t p_aout,
byte_t *buffer, int i_size );
typedef void (aout_sys_close_t) ( p_aout_thread_t p_aout );
typedef int (aout_open_t) ( p_aout_thread_t p_aout );
typedef int (aout_setformat_t) ( p_aout_thread_t p_aout );
typedef long (aout_getbufinfo_t) ( p_aout_thread_t p_aout,
long l_buffer_limit );
typedef void (aout_play_t) ( p_aout_thread_t p_aout,
byte_t *buffer, int i_size );
typedef void (aout_close_t) ( p_aout_thread_t p_aout );
typedef struct aout_thread_s
{
......@@ -140,15 +137,13 @@ typedef struct aout_thread_s
vlc_mutex_t fifos_lock;
aout_fifo_t fifo[ AOUT_MAX_FIFOS ];
/* Plugins */
aout_sys_open_t * p_sys_open;
aout_sys_reset_t * p_sys_reset;
aout_sys_setformat_t * p_sys_setformat;
aout_sys_setchannels_t * p_sys_setchannels;
aout_sys_setrate_t * p_sys_setrate;
aout_sys_getbufinfo_t * p_sys_getbufinfo;
aout_sys_playsamples_t * p_sys_playsamples;
aout_sys_close_t * p_sys_close;
/* Plugin used and shortcuts to access its capabilities */
struct module_s * p_module;
aout_open_t * p_open;
aout_setformat_t * p_setformat;
aout_getbufinfo_t * p_getbufinfo;
aout_play_t * p_play;
aout_close_t * p_close;
void * buffer;
/* The s32 buffer is used to mix all the audio fifos together before
......
......@@ -31,8 +31,90 @@ typedef void * module_handle_t;
#endif
/*****************************************************************************
* Configuration structure
* Module capabilities.
*****************************************************************************/
#define MODULE_CAPABILITY_NULL 0 /* The Module can't do anything */
#define MODULE_CAPABILITY_INTF 1<<0 /* Interface */
#define MODULE_CAPABILITY_INPUT 1<<1 /* Input */
#define MODULE_CAPABILITY_DECAPS 1<<2 /* Decaps */
#define MODULE_CAPABILITY_ADEC 1<<3 /* Audio decoder */
#define MODULE_CAPABILITY_VDEC 1<<4 /* Video decoder */
#define MODULE_CAPABILITY_AOUT 1<<5 /* Audio output */
#define MODULE_CAPABILITY_VOUT 1<<6 /* Video output */
#define MODULE_CAPABILITY_YUV 1<<7 /* YUV colorspace conversion */
#define MODULE_CAPABILITY_AFX 1<<8 /* Audio effects */
#define MODULE_CAPABILITY_VFX 1<<9 /* Video effects */
/* FIXME: not yet used */
typedef struct probedata_s
{
struct
{
char * psz_data;
} aout;
} probedata_t;
/* FIXME: find a nicer way to do this. */
typedef struct function_list_s
{
int ( * p_probe ) ( probedata_t * p_data );
union
{
struct
{
int ( * p_open ) ( struct aout_thread_s * p_aout );
int ( * p_setformat ) ( struct aout_thread_s * p_aout );
long ( * p_getbufinfo ) ( struct aout_thread_s * p_aout,
long l_buffer_info );
void ( * p_play ) ( struct aout_thread_s * p_aout,
byte_t *buffer, int i_size );
void ( * p_close ) ( struct aout_thread_s * p_aout );
} aout;
} functions;
} function_list_t;
typedef struct module_functions_s
{
/* The order here has to be the same as above for the #defines */
function_list_t intf;
function_list_t input;
function_list_t decaps;
function_list_t adec;
function_list_t vdec;
function_list_t aout;
function_list_t vout;
function_list_t yuv;
function_list_t afx;
function_list_t vfx;
} module_functions_t;
typedef struct module_functions_s * p_module_functions_t;
/*****************************************************************************
* Macros used to build the configuration structure.
*****************************************************************************/
/* Mandatory first and last parts of the structure */
#define MODULE_CONFIG_ITEM_START 0x01 /* The main window */
#define MODULE_CONFIG_ITEM_END 0x00 /* End of the window */
/* Configuration widgets */
#define MODULE_CONFIG_ITEM_PANE 0x02 /* A notebook pane */
#define MODULE_CONFIG_ITEM_FRAME 0x03 /* A frame */
#define MODULE_CONFIG_ITEM_COMMENT 0x04 /* A comment text */
#define MODULE_CONFIG_ITEM_STRING 0x05 /* A string */
#define MODULE_CONFIG_ITEM_FILE 0x06 /* A file selector */
#define MODULE_CONFIG_ITEM_CHECK 0x07 /* A checkbox */
#define MODULE_CONFIG_ITEM_CHOOSE 0x08 /* A choose box */
#define MODULE_CONFIG_ITEM_RADIO 0x09 /* A radio box */
#define MODULE_CONFIG_ITEM_SCALE 0x0a /* A horizontal ruler */
#define MODULE_CONFIG_ITEM_SPIN 0x0b /* A numerical selector */
typedef struct module_config_s
{
int i_type; /* Configuration widget type */
......@@ -46,7 +128,16 @@ typedef struct module_config_s
* Bank and module description structures
*****************************************************************************/
/* The main module structure */
/* The module bank structure */
typedef struct module_bank_s
{
struct module_s * first; /* First module of the bank */
vlc_mutex_t lock; /* Global lock -- you can't imagine how awful it
is to design thread-safe linked lists. */
} module_bank_t;
/* The module description structure */
typedef struct module_s
{
boolean_t b_builtin; /* Set to true if the module is built in */
......@@ -64,20 +155,12 @@ typedef struct module_s
struct module_s * next; /* Next module */
struct module_s * prev; /* Previous module */
u32 i_capabilities; /* Capability list */
module_config_t * p_config; /* Module configuration structure table */
} module_t;
u32 i_capabilities; /* Capability list */
p_module_functions_t p_functions; /* Capability functions */
/* The module bank structure */
typedef struct module_bank_s
{
module_t * first; /* First module of the bank */
vlc_mutex_t lock; /* Global lock -- you can't imagine how awful it
is to design thread-safe linked lists. */
} module_bank_t;
} module_t;
/*****************************************************************************
* Exported functions.
......@@ -88,6 +171,8 @@ void module_DestroyBank ( module_bank_t * p_bank );
void module_ResetBank ( module_bank_t * p_bank );
void module_ManageBank ( module_bank_t * p_bank );
int module_Need ( module_t * p_module );
int module_Unneed ( module_t * p_module );
module_t * module_Need ( module_bank_t *p_bank,
int i_capabilities, void *p_data );
void module_Unneed ( module_bank_t * p_bank,
module_t * p_module );
/*****************************************************************************
* modules_config.h : Module configuration tools.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Module capabilities.
*****************************************************************************/
#define MODULE_CAPABILITY_NULL 0 /* The Module can't do anything */
#define MODULE_CAPABILITY_INTF 1<<0 /* Interface */
#define MODULE_CAPABILITY_INPUT 1<<1 /* Input */
#define MODULE_CAPABILITY_DECAPS 1<<2 /* Decaps */
#define MODULE_CAPABILITY_ADEC 1<<3 /* Audio decoder */
#define MODULE_CAPABILITY_VDEC 1<<4 /* Video decoder */
#define MODULE_CAPABILITY_AOUT 1<<5 /* Audio output */
#define MODULE_CAPABILITY_VOUT 1<<6 /* Video output */
#define MODULE_CAPABILITY_YUV 1<<7 /* YUV colorspace conversion */
#define MODULE_CAPABILITY_AFX 1<<8 /* Audio effects */
#define MODULE_CAPABILITY_VFX 1<<9 /* Video effects */
/*****************************************************************************
* Macros used to build the configuration structure.
*****************************************************************************/
/* Mandatory first and last parts of the structure */
#define MODULE_CONFIG_ITEM_START 0x01 /* The main window */
#define MODULE_CONFIG_ITEM_END 0x00 /* End of the window */
/* Configuration widgets */
#define MODULE_CONFIG_ITEM_PANE 0x02 /* A notebook pane */
#define MODULE_CONFIG_ITEM_FRAME 0x03 /* A frame */
#define MODULE_CONFIG_ITEM_COMMENT 0x04 /* A comment text */
#define MODULE_CONFIG_ITEM_STRING 0x05 /* A string */
#define MODULE_CONFIG_ITEM_FILE 0x06 /* A file selector */
#define MODULE_CONFIG_ITEM_CHECK 0x07 /* A checkbox */
#define MODULE_CONFIG_ITEM_CHOOSE 0x08 /* A choose box */
#define MODULE_CONFIG_ITEM_RADIO 0x09 /* A radio box */
#define MODULE_CONFIG_ITEM_SCALE 0x0a /* A horizontal ruler */
#define MODULE_CONFIG_ITEM_SPIN 0x0b /* A numerical selector */
......@@ -52,12 +52,9 @@ static void aout_GetPlugin( p_aout_thread_t p_aout );
/* Audio output */
int aout_AlsaOpen ( aout_thread_t *p_aout );
int aout_AlsaReset ( aout_thread_t *p_aout );
int aout_AlsaSetFormat ( aout_thread_t *p_aout );
int aout_AlsaSetChannels ( aout_thread_t *p_aout );
int aout_AlsaSetRate ( aout_thread_t *p_aout );
long aout_AlsaGetBufInfo ( aout_thread_t *p_aout, long l_buffer_info );
void aout_AlsaPlaySamples ( aout_thread_t *p_aout, byte_t *buffer,
void aout_AlsaPlay ( aout_thread_t *p_aout, byte_t *buffer,
int i_size );
void aout_AlsaClose ( aout_thread_t *p_aout );
......@@ -96,12 +93,9 @@ plugin_info_t * GetConfig( void )
static void aout_GetPlugin( p_aout_thread_t p_aout )
{
p_aout->p_sys_open = aout_AlsaOpen;
p_aout->p_sys_reset = aout_AlsaReset;
p_aout->p_sys_setformat = aout_AlsaSetFormat;
p_aout->p_sys_setchannels = aout_AlsaSetChannels;
p_aout->p_sys_setrate = aout_AlsaSetRate;
p_aout->p_sys_getbufinfo = aout_AlsaGetBufInfo;
p_aout->p_sys_playsamples = aout_AlsaPlaySamples;
p_aout->p_sys_close = aout_AlsaClose;
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;
}
......@@ -204,39 +204,6 @@ int aout_AlsaSetFormat ( aout_thread_t *p_aout )
return ( 0 );
}
/*****************************************************************************
* aout_AlsaReset: resets the dsp
*****************************************************************************/
int aout_AlsaReset ( aout_thread_t *p_aout )
{
/* TODO : put something in here, such as close and open again
* or check status, drain, flush, .... */
return ( 0 );
}
/*****************************************************************************
* aout_AlsaSetChannels: sets mono, stereo and other modes
*****************************************************************************/
int aout_AlsaSetChannels ( aout_thread_t *p_aout )
{
/* TODO : normally, nothing
* everything should be done in the AlsaSetFormat, as far a I understand
* the alsa documentation
*/
return ( 0 );
}
/*****************************************************************************
* aout_AlsaSetRate: sets the audio output rate
*****************************************************************************
* As in the previous function, the rate is supposed to be set in the
* AlsaSetFormat function
*****************************************************************************/
int aout_AlsaSetRate ( aout_thread_t *p_aout )
{
return ( 0 );
}
/*****************************************************************************
* aout_AlsaGetBufInfo: buffer status query
*****************************************************************************/
......@@ -286,9 +253,9 @@ long aout_AlsaGetBufInfo ( aout_thread_t *p_aout, long l_buffer_limit )
}
/*****************************************************************************
* aout_AlsaPlaySamples
* aout_AlsaPlay
*****************************************************************************/
void aout_AlsaPlaySamples ( aout_thread_t *p_aout, byte_t *buffer, int i_size )
void aout_AlsaPlay ( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{
int i_write_returns;
......
......@@ -2,7 +2,7 @@
* aout_beos.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: aout_beos.cpp,v 1.7 2001/01/05 18:46:43 massiot Exp $
* $Id: aout_beos.cpp,v 1.8 2001/01/07 16:17:58 sam Exp $
*
* Authors:
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -135,13 +135,6 @@ int aout_BeOpen( aout_thread_t *p_aout )
return( 0 );
}
/*****************************************************************************
* aout_BeReset: resets the dsp
*****************************************************************************/
int aout_BeReset( aout_thread_t *p_aout )
{
return( 0 );
}
/*****************************************************************************
* aout_BeSetFormat: sets the dsp output format
......@@ -151,22 +144,6 @@ int aout_BeSetFormat( aout_thread_t *p_aout )
return( 0 );
}
/*****************************************************************************
* aout_BeSetChannels: sets the dsp's stereo or mono mode
*****************************************************************************/
int aout_BeSetChannels( aout_thread_t *p_aout )
{
return( 0 );
}
/*****************************************************************************
* aout_BeSetRate: sets the dsp's audio output rate
*****************************************************************************/
int aout_BeSetRate( aout_thread_t *p_aout )
{
return( 0 );
}
/*****************************************************************************
* aout_BeGetBufInfo: buffer status query
*****************************************************************************/
......@@ -185,11 +162,11 @@ long aout_BeGetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
}
/*****************************************************************************
* aout_BePlaySamples: plays a sound samples buffer
* aout_BePlay: plays a sound samples buffer
*****************************************************************************
* This function writes a buffer of i_length bytes in the dsp
*****************************************************************************/
void aout_BePlaySamples( aout_thread_t *p_aout, byte_t *buffer, int i_size )
void aout_BePlay( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{
long i_newbuf_pos;
......
......@@ -54,7 +54,7 @@ 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_BePlaySamples ( aout_thread_t *p_aout, byte_t *buffer,
void aout_BePlay ( aout_thread_t *p_aout, byte_t *buffer,
int i_size );
void aout_BeClose ( aout_thread_t *p_aout );
......@@ -102,14 +102,11 @@ plugin_info_t * GetConfig( void )
static void aout_GetPlugin( p_aout_thread_t p_aout )
{
p_aout->p_sys_open = aout_BeOpen;
p_aout->p_sys_reset = aout_BeReset;
p_aout->p_sys_setformat = aout_BeSetFormat;
p_aout->p_sys_setchannels = aout_BeSetChannels;
p_aout->p_sys_setrate = aout_BeSetRate;
p_aout->p_sys_getbufinfo = aout_BeGetBufInfo;
p_aout->p_sys_playsamples = aout_BePlaySamples;
p_aout->p_sys_close = aout_BeClose;
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 )
......
......@@ -3,7 +3,8 @@
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
* Authors:
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* 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
......@@ -22,10 +23,9 @@
/* TODO:
*
* - an aout_DspGetFormats() function
* - an aout_GetFormats() function
* - dsp inline/static
* - make this library portable (see mpg123)
* - macroify aout_DspPlaySamples &/| aout_DspGetBufInfo ?
*
*/
......@@ -61,8 +61,10 @@
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "main.h"
#include "modules.h"
/*****************************************************************************
* vout_dsp_t: dsp audio output method descriptor
* aout_sys_t: dsp audio output method descriptor
*****************************************************************************
* This structure is part of the audio output thread descriptor.
* It describes the dsp specific properties of an audio device.
......@@ -74,31 +76,82 @@ typedef struct aout_sys_s
} aout_sys_t;
/*****************************************************************************
* aout_DspOpen: opens the audio device (the digital sound processor)
* 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 dsp_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: 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 )
{
char * psz_device = main_GetPszVariable( AOUT_DSP_VAR, AOUT_DSP_DEFAULT );
int i_fd = open( psz_device, O_WRONLY|O_NONBLOCK );
/* If we were unable to open the device, there is no way we can use
* the plugin. Return a score of 0. */
if( i_fd < 0 )
{
return( 0 );
}
/* Otherwise, there are good chances we can use this plugin, return 100. */
close( i_fd );
return( 100 );
}
/*****************************************************************************
* aout_Open: opens the audio device (the digital sound processor)
*****************************************************************************
* - This function opens the dsp as an usual non-blocking write-only file, and
* modifies the p_aout->p_sys->i_fd with the file's descriptor.
* This function opens the dsp as a usual non-blocking write-only file, and
* modifies the p_aout->i_fd with the file's descriptor.
*****************************************************************************/
int aout_DspOpen( aout_thread_t *p_aout )
static int aout_Open( aout_thread_t *p_aout )
{
/* Allocate structure */
p_aout->p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->p_sys == NULL )
{
intf_ErrMsg("error: %s", strerror(ENOMEM) );
intf_ErrMsg("aout error: %s", strerror(ENOMEM) );
return( 1 );
}
/* Initialize some variables */
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->psz_device = main_GetPszVariable( AOUT_DSP_VAR, AOUT_DSP_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 );
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 );
/* Open the sound device */
if ( (p_aout->i_fd = open( p_aout->psz_device, O_WRONLY|O_NONBLOCK )) < 0 )
if( (p_aout->i_fd = open( p_aout->psz_device, O_WRONLY|O_NONBLOCK )) < 0 )
{
intf_ErrMsg( "aout error: can't open audio device (%s)", p_aout->psz_device );
intf_ErrMsg( "aout error: can't open audio device (%s)",
p_aout->psz_device );
return( -1 );
}
......@@ -106,92 +159,72 @@ int aout_DspOpen( aout_thread_t *p_aout )
}
/*****************************************************************************
* aout_DspReset: resets the dsp
*****************************************************************************/
int aout_DspReset( aout_thread_t *p_aout )
{
if ( ioctl( p_aout->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 )
{
intf_ErrMsg( "aout error: can't reset audio device (%s)", p_aout->psz_device );
return( -1 );
}
return( 0 );
}
/*****************************************************************************
* aout_DspSetFormat: sets the dsp output format
* aout_SetFormat: resets the dsp and sets its format
*****************************************************************************
* This functions tries to initialize the dsp output format with the value
* contained in the dsp structure, and if this value could not be set, the
* default value returned by ioctl is set.
* This functions resets the DSP device, tries to initialize the output
* format with the value contained in the dsp structure, and if this value
* could not be set, the default value returned by ioctl is set. It then
* does the same for the stereo mode, and for the output rate.
*****************************************************************************/
int aout_DspSetFormat( aout_thread_t *p_aout )
static int aout_SetFormat( aout_thread_t *p_aout )
{
int i_format;
long l_rate;
boolean_t b_stereo = p_aout->b_stereo;
/* Reset the DSP device */
if( ioctl( p_aout->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 )
{
intf_ErrMsg( "aout error: can't reset audio device (%s)",
p_aout->psz_device );
return( -1 );
}
/* Set the output format */
i_format = p_aout->i_format;
if ( ioctl( p_aout->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 )
if( ioctl( p_aout->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 )
{
intf_ErrMsg( "aout error: can't set audio output format (%i)", p_aout->i_format );