summaryrefslogtreecommitdiff
path: root/src/xine-engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/xine-engine')
-rw-r--r--src/xine-engine/audio_out.h94
-rw-r--r--src/xine-engine/load_plugins.c118
-rw-r--r--src/xine-engine/video_out.h15
-rw-r--r--src/xine-engine/xine.c5
4 files changed, 155 insertions, 77 deletions
diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h
index 9b332e72d..98bbc4683 100644
--- a/src/xine-engine/audio_out.h
+++ b/src/xine-engine/audio_out.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: audio_out.h,v 1.2 2001/04/27 10:42:38 f1rmb Exp $
+ * $Id: audio_out.h,v 1.3 2001/04/28 19:47:42 guenter Exp $
*/
#ifndef HAVE_AUDIO_OUT_H
#define HAVE_AUDIO_OUT_H
@@ -30,90 +30,96 @@
#endif
-#define AUDIO_OUT_PLUGIN_IFACE_VERSION 1
+#define AUDIO_OUT_IFACE_VERSION 1
/*
* audio output modes Used as Bitfield in AC3 decoder
*/
#define AO_MODE_AC3 1
-#define AO_MODE_MONO 2 /* 1 sample == 2 bytes */
-#define AO_MODE_STEREO 4 /* 1 sample == 4 bytes */
-#define AO_MODE_4CHANNEL 8 /* 1 sample == 8 bytes */
-#define AO_MODE_5CHANNEL 16 /* 1 sample == 10 bytes */
+#define AO_MODE_AC5 2
+#define AO_MODE_MONO 4 /* 1 sample == 2 bytes */
+#define AO_MODE_STEREO 8 /* 1 sample == 4 bytes */
+#define AO_MODE_4CHANNEL 16 /* 1 sample == 8 bytes */
+#define AO_MODE_5CHANNEL 32 /* 1 sample == 10 bytes */
-typedef struct ao_functions_s
-{
+/*
+ * ao_functions_s contains the functions every audio output
+ * driver plugin has to implement.
+ */
+
+typedef struct ao_functions_s ao_functions_t;
+
+struct ao_functions_s {
/*
- * plugin interface version, lower versions _may_ be supported
+ * find out what output modes are supported by this plugin
+ * (constants for the bit vector to return see above)
*/
- int interface_version;
+ uint32_t (*get_supported_modes) (ao_functions_t *this);
/*
- * find out if desired output mode is supported by
- * this driver
+ * connect this driver to the xine engine
*/
-
- int (*is_mode_supported) (int mode);
+ void (*connect) (ao_functions_t *this, metronom_t *metronom);
/*
- * init device - buffer will be flushed(!)
+ * open the driver and make it ready to receive audio data
+ * buffers may be flushed(!)
+ *
* return value: <=0 : failure, 1 : ok
*/
- int (*open)(metronom_t *metronom, uint32_t bits, uint32_t rate, int mode);
+ int (*open)(ao_functions_t *this, uint32_t bits, uint32_t rate, int mode);
/*
* write audio data to output buffer - may block
* audio driver must sync sample playback with metronom
*/
- void (*write_audio_data)(metronom_t *metronom,
+ void (*write_audio_data)(ao_functions_t *this,
int16_t* audio_data, uint32_t num_samples,
uint32_t pts);
/*
- * close the audio driver
+ * this is called when the decoder no longer uses the audio
+ * output driver - the driver should get ready to get opened() again
*/
- void (*close)(void);
+ void (*close)(ao_functions_t *this);
/*
- * return human readable identifier for this plugin
+ * shut down this audio output driver plugin and
+ * free all resources allocated
*/
- char* (*get_identifier) (void);
-
-} ao_functions_t;
+ void (*exit) (ao_functions_t *this);
-/*
- * available drivers:
- */
+} ;
-#define AO_DRIVER_UNSET -1
-#define AO_DRIVER_NULL 0
-#define AO_DRIVER_OSS 1
-#if defined(HAVE_ALSA)
-# define AO_DRIVER_ALSA 2
-# if defined(HAVE_ESD)
-# define AO_DRIVER_ESD 3
-# endif
-#else /* no ALSA */
-# if defined(HAVE_ESD)
-# define AO_DRIVER_ESD 2
-# endif
-#endif
/*
- * find right device driver, init it
+ * to build a dynamic audio output plugin,
+ * you have to implement these functions:
+ *
+ *
+ * ao_functions_t *init_audio_out_plugin (config_values_t *config)
+ *
+ * init this plugin, check if device is available
+ *
+ * ao_info_t *get_audio_out_plugin_info ()
+ *
+ * peek at some (static) information about the plugin without initializing it
+ *
*/
-//ao_functions_t *ao_init(char *driver_name) ;
-
-ao_functions_t *init_audio_out_plugin(int iface, config_values_t *cfg);
+typedef struct ao_info_s {
-char *ao_get_available_drivers ();
+ int interface_version;
+ char *id;
+ char *description;
+ int priority;
+} ao_info_t ;
#endif
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index fde565b03..7e35e4f6b 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: load_plugins.c,v 1.11 2001/04/27 23:51:52 guenter Exp $
+ * $Id: load_plugins.c,v 1.12 2001/04/28 19:47:42 guenter Exp $
*
*
* Load input/demux/audio_out/video_out/codec plugins
@@ -458,8 +458,77 @@ vo_driver_t *xine_load_video_output_plugin(config_values_t *config,
return NULL;
}
-ao_functions_t *xine_load_audio_output_plugin(config_values_t *config,
- char *id) {
+char **xine_list_audio_output_plugins() {
+
+ char **plugin_ids;
+ int num_plugins = 0;
+ DIR *dir;
+
+ plugin_ids = xmalloc (50 * sizeof (char *));
+ plugin_ids[0] = NULL;
+
+ dir = opendir (XINE_PLUGINDIR);
+
+ if (dir) {
+ struct dirent *dir_entry;
+
+ while ((dir_entry = readdir (dir)) != NULL) {
+ char str[1024];
+ void *plugin;
+ int nLen = strlen (dir_entry->d_name);
+
+ if ((strncasecmp(dir_entry->d_name,
+ XINE_AUDIO_OUT_PLUGIN_PREFIXNAME,
+ XINE_AUDIO_OUT_PLUGIN_PREFIXNAME_LENGTH) == 0) &&
+ ((dir_entry->d_name[nLen-3]=='.')
+ && (dir_entry->d_name[nLen-2]=='s')
+ && (dir_entry->d_name[nLen-1]=='o'))) {
+
+ sprintf (str, "%s/%s", XINE_PLUGINDIR, dir_entry->d_name);
+
+ /*
+ * now, see if we can open this plugin,
+ * and get it's id
+ */
+
+ if(!(plugin = dlopen (str, RTLD_LAZY))) {
+
+ /* printf("load_plugins: cannot load plugin %s (%s)\n",
+ str, dlerror()); */
+
+ } else {
+
+ ao_info_t* (*getinfo) ();
+ ao_info_t *ao_info;
+
+ if ((getinfo = dlsym(plugin, "get_audio_out_plugin_info")) != NULL) {
+ ao_info = getinfo();
+
+ if ( ao_info->interface_version == AUDIO_OUT_IFACE_VERSION) {
+
+ /* FIXME: sort the list by ao_info->priority */
+
+ plugin_ids[num_plugins] = ao_info->id;
+ num_plugins++;
+ plugin_ids[num_plugins] = NULL;
+ }
+ } else {
+
+ printf("load_plugins: %s seems to be an invalid plugin (lacks get_audio_out_plugin_info() function)\n", str);
+
+ }
+ }
+ }
+ }
+ } else {
+ perror ("load_plugins: get_available_audio_output_plugins - cannot access plugin dir:");
+ }
+
+ return plugin_ids;
+}
+
+ao_functions_t *xine_load_audio_output_plugin(config_values_t *config, char *id) {
+
DIR *dir;
ao_functions_t *aod = NULL;
@@ -486,23 +555,30 @@ ao_functions_t *xine_load_audio_output_plugin(config_values_t *config,
sprintf (str, "%s/%s", XINE_PLUGINDIR, pEntry->d_name);
if(!(plugin = dlopen (str, RTLD_LAZY))) {
- fprintf(stderr, "%s(%d): %s doesn't seem to be installed (%s)\n",
- __FILE__, __LINE__, str, dlerror());
- exit(1);
- }
- else {
- void *(*initplug) (int, config_values_t *);
+ printf("load_plugins: audio output plugin %s failed to link: %s\n",
+ str, dlerror());
+ return NULL;
+ } else {
+ void *(*initplug) (config_values_t *);
+ ao_info_t* (*getinfo) ();
+ ao_info_t *ao_info;
+
+ if ((getinfo = dlsym(plugin, "get_audio_out_plugin_info")) != NULL) {
+ ao_info = getinfo();
- if((initplug = dlsym(plugin, "init_audio_out_plugin")) != NULL) {
-
- aod = (ao_functions_t *) initplug(AUDIO_OUT_PLUGIN_IFACE_VERSION,
- config);
-
- printf("audio output plugin found : %s(ID: %s, iface: %d)\n",
- str, aod->get_identifier(), aod->interface_version);
+ if (!strcmp(id, ao_info->id)) {
- if(!strcasecmp(id, aod->get_identifier())) {
- return aod;
+ if((initplug = dlsym(plugin, "init_audio_out_plugin")) != NULL) {
+
+ aod = (ao_functions_t *) initplug(config);
+
+ if (aod)
+ printf("load_plugins: audio output plugin %s sucessfully loaded.\n", str);
+ else
+ printf("load_plugins: audio output plugin %s: init_audio_out_plugin failed.\n", str);
+
+ return aod;
+ }
}
}
}
@@ -512,9 +588,3 @@ ao_functions_t *xine_load_audio_output_plugin(config_values_t *config,
return NULL;
}
-char **xine_list_audio_output_plugins() {
-
- printf ("load_plugins: FIXME: list_audio_output_plugins not implemented yet\n");
-
- return NULL;
-}
diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h
index 864132660..6998a7c26 100644
--- a/src/xine-engine/video_out.h
+++ b/src/xine-engine/video_out.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out.h,v 1.3 2001/04/27 23:51:52 guenter Exp $
+ * $Id: video_out.h,v 1.4 2001/04/28 19:47:42 guenter Exp $
*
*
* xine version of video_out.h
@@ -205,7 +205,7 @@ struct vo_instance_s {
#define VO_CAP_COLORKEY 0x00000100 /* driver can set COLORKEY value */
/*
- * vo_driver_s contains the function every display driver
+ * vo_driver_s contains the functions every display driver
* has to implement. The vo_new_instance function (see below)
* should then be used to construct a vo_instance using this
* driver. Some of the function pointers will be copied
@@ -266,25 +266,26 @@ vo_instance_t *vo_new_instance (vo_driver_t *driver, metronom_t *metronom) ;
* you have to implement these functions:
*
*
- * init_video_out_plugin init and set up driver so it is fully operational
+ * vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual);
+ *
+ * init and set up driver so it is fully operational
*
* parameters: config - config object pointer
* visual - driver specific info (e.g. Display*)
*
* return value: video_driver_t* in case of success,
- * NULL on failure (e.g. wrong interface version, wrong visual type...)
+ * NULL on failure (e.g. wrong interface version,
+ * wrong visual type...)
*
- * vo_driver_t *init_video_out_plugin (config_values_t *config, void *visual);
*
*
- * get_video_out_plugin_info
+ * vo_info_t *get_video_out_plugin_info ();
*
* peek at some (static) information about the plugin without initializing it
*
* parameters: none
*
* return value: vo_info_t* : some information about the plugin
- * vo_info_t *get_video_out_plugin_info ();
*/
typedef struct vo_info_s {
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 70f9bf8f2..32b40a33a 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine.c,v 1.7 2001/04/24 21:10:42 guenter Exp $
+ * $Id: xine.c,v 1.8 2001/04/28 19:47:42 guenter Exp $
*
* top-level xine functions
*
@@ -96,7 +96,7 @@ void xine_stop (xine_t *this) {
this->spu_fifo->clear(this->spu_fifo);
if (this->audio_out)
- this->audio_out->close ();
+ this->audio_out->close (this->audio_out);
this->metronom->reset(this->metronom);
this->metronom->stop_clock (this->metronom);
@@ -438,6 +438,7 @@ xine_t *xine_init (vo_driver_t *vo,
video_decoder_init (this);
this->audio_out = ao;
+ this->audio_out->connect (this->audio_out, this->metronom);
audio_decoder_init (this);
/*