summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Roitzsch <mroi@users.sourceforge.net>2002-09-09 13:57:12 +0000
committerMichael Roitzsch <mroi@users.sourceforge.net>2002-09-09 13:57:12 +0000
commitb3cb8d528ee17a4ce2ac4c2257a7d82a1729c343 (patch)
tree751d43d6095335465c267be6210e566edf0a9bfc /src
parentcec70fdee25601338fc945825ec2e080de9aa280 (diff)
downloadxine-lib-b3cb8d528ee17a4ce2ac4c2257a7d82a1729c343.tar.gz
xine-lib-b3cb8d528ee17a4ce2ac4c2257a7d82a1729c343.tar.bz2
allow multiple decoders per stream type, sort them by priority and
fallback, if one refuses to work CVS patchset: 2635 CVS date: 2002/09/09 13:57:12
Diffstat (limited to 'src')
-rw-r--r--src/xine-engine/load_plugins.c175
-rw-r--r--src/xine-engine/plugin_catalog.h13
2 files changed, 116 insertions, 72 deletions
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index ad5719e91..a0328ba18 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.86 2002/09/08 14:24:20 mroi Exp $
+ * $Id: load_plugins.c,v 1.87 2002/09/09 13:57:12 mroi Exp $
*
*
* Load input/demux/audio_out/video_out/codec plugins
@@ -110,8 +110,6 @@ static void _insert_plugin (xine_list_t *list,
uint32_t *types;
int i;
- /* FIXME: TODO: insert replacement/priority logic here */
-
entry = xine_xmalloc(sizeof(plugin_node_t));
entry->filename = _strclone(filename);
entry->info = xine_xmalloc(sizeof(plugin_info_t));
@@ -159,11 +157,6 @@ static void _insert_plugin (xine_list_t *list,
break;
}
- /*
- * insert plugin into list
- * FIXME: find right place depending on plugin priority
- */
-
xine_list_append_content (list, entry);
}
@@ -384,7 +377,7 @@ static void map_decoders (xine_t *this) {
plugin_catalog_t *catalog = this->plugin_catalog;
plugin_node_t *node;
- int i;
+ int i, pos;
#ifdef LOG
printf ("load_plugins: map_decoders\n");
@@ -393,11 +386,11 @@ static void map_decoders (xine_t *this) {
/* clean up */
for (i=0; i<DECODER_MAX; i++) {
- catalog->audio_decoder_map[i]=NULL;
- catalog->video_decoder_map[i]=NULL;
- catalog->spu_decoder_map[i]=NULL;
+ catalog->audio_decoder_map[i][0]=NULL;
+ catalog->video_decoder_map[i][0]=NULL;
+ catalog->spu_decoder_map[i][0]=NULL;
}
-
+
/*
* map audio decoders
*/
@@ -417,26 +410,29 @@ static void map_decoders (xine_t *this) {
while (type && (*type)) {
int streamtype = ((*type)>>16) & 0xFF;
- int priority;
#ifdef LOG
printf ("load_plugins: decoder handles stream type %02x, priority %d\n",
streamtype, di->priority);
#endif
- if (catalog->audio_decoder_map[streamtype]) {
- priority = ((decoder_info_t *) catalog->audio_decoder_map[streamtype]->info->special_info)->priority;
- } else
- priority = 0;
-
- if (di->priority > priority) {
+ /* find the right place based on the priority */
+ for (pos = 0; pos < PLUGINS_PER_TYPE; pos++)
+ if (!catalog->audio_decoder_map[streamtype][pos] ||
+ ((decoder_info_t *)catalog->audio_decoder_map[streamtype][pos]->info->special_info)->priority <=
+ di->priority)
+ break;
+
+ /* shift the decoder list for this type by one to make room for new decoder */
+ for (i = PLUGINS_PER_TYPE; i > pos; i--)
+ catalog->audio_decoder_map[streamtype][i] = catalog->audio_decoder_map[streamtype][i - 1];
+
+ /* insert new decoder */
+ catalog->audio_decoder_map[streamtype][pos] = node;
#ifdef LOG
- printf ("load_plugins: using decoder %s for stream type %02x\n",
- node->info->id, streamtype);
+ printf("load_plugins: decoder inserted in decoder map at %d\n", pos);
#endif
- catalog->audio_decoder_map[streamtype] = node;
- }
-
+
type++;
}
@@ -462,26 +458,29 @@ static void map_decoders (xine_t *this) {
while (type && (*type)) {
int streamtype = ((*type)>>16) & 0xFF;
- int priority;
#ifdef LOG
printf ("load_plugins: decoder handles stream type %02x, priority %d\n",
streamtype, di->priority);
#endif
- if (catalog->video_decoder_map[streamtype]) {
- priority = ((decoder_info_t *) catalog->video_decoder_map[streamtype]->info->special_info)->priority;
- } else
- priority = 0;
-
- if (di->priority > priority) {
+ /* find the right place based on the priority */
+ for (pos = 0; pos < PLUGINS_PER_TYPE; pos++)
+ if (!catalog->video_decoder_map[streamtype][pos] ||
+ ((decoder_info_t *)catalog->video_decoder_map[streamtype][pos]->info->special_info)->priority <=
+ di->priority)
+ break;
+
+ /* shift the decoder list for this type by one to make room for new decoder */
+ for (i = PLUGINS_PER_TYPE; i > pos; i--)
+ catalog->video_decoder_map[streamtype][i] = catalog->video_decoder_map[streamtype][i - 1];
+
+ /* insert new decoder */
+ catalog->video_decoder_map[streamtype][pos] = node;
#ifdef LOG
- printf ("load_plugins: using decoder %s for stream type %02x\n",
- node->info->id, streamtype);
+ printf("load_plugins: decoder inserted in decoder map at %d\n", pos);
#endif
- catalog->video_decoder_map[streamtype] = node;
- }
-
+
type++;
}
@@ -507,26 +506,29 @@ static void map_decoders (xine_t *this) {
while (type && (*type)) {
int streamtype = ((*type)>>16) & 0xFF;
- int priority;
#ifdef LOG
printf ("load_plugins: decoder handles stream type %02x, priority %d\n",
streamtype, di->priority);
#endif
- if (catalog->spu_decoder_map[streamtype]) {
- priority = ((decoder_info_t *) catalog->spu_decoder_map[streamtype]->info->special_info)->priority;
- } else
- priority = 0;
-
- if (di->priority > priority) {
+ /* find the right place based on the priority */
+ for (pos = 0; pos < PLUGINS_PER_TYPE; pos++)
+ if (!catalog->spu_decoder_map[streamtype][pos] ||
+ ((decoder_info_t *)catalog->spu_decoder_map[streamtype][pos]->info->special_info)->priority <=
+ di->priority)
+ break;
+
+ /* shift the decoder list for this type by one to make room for new decoder */
+ for (i = PLUGINS_PER_TYPE; i > pos; i--)
+ catalog->spu_decoder_map[streamtype][i] = catalog->spu_decoder_map[streamtype][i - 1];
+
+ /* insert new decoder */
+ catalog->spu_decoder_map[streamtype][pos] = node;
#ifdef LOG
- printf ("load_plugins: using decoder %s for stream type %02x\n",
- node->info->id, streamtype);
+ printf("load_plugins: decoder inserted in decoder map at %d\n", pos);
#endif
- catalog->spu_decoder_map[streamtype] = node;
- }
-
+
type++;
}
@@ -813,61 +815,100 @@ const xine_mrl_t *const *xine_get_browse_mrls (xine_p this, const char *plugin_i
video_decoder_t *get_video_decoder (xine_t *this, uint8_t stream_type) {
plugin_node_t *node;
+ int i, j;
#ifdef LOG
printf ("load_plugins: looking for video decoder for streamtype %02x\n",
stream_type);
#endif
- node = this->plugin_catalog->video_decoder_map[stream_type];
+ for (i = 0; i < PLUGINS_PER_TYPE; i++) {
+ node = this->plugin_catalog->video_decoder_map[stream_type][i];
- if (!node)
- return NULL;
+ if (!node)
+ return NULL;
- if (!node->plugin)
- node->plugin = _load_plugin(this, node->filename, node->info, NULL);
+ if (!node->plugin)
+ node->plugin = _load_plugin(this, node->filename, node->info, NULL);
- return node->plugin;
+ if (node->plugin)
+ return node->plugin;
+ else {
+ /* remove non working plugin from catalog */
+ for (j = i + 1; j < PLUGINS_PER_TYPE; j++)
+ this->plugin_catalog->video_decoder_map[stream_type][j - 1] =
+ this->plugin_catalog->video_decoder_map[stream_type][j];
+ this->plugin_catalog->video_decoder_map[stream_type][PLUGINS_PER_TYPE] = NULL;
+ i--;
+ }
+ }
+ return NULL;
}
audio_decoder_t *get_audio_decoder (xine_t *this, uint8_t stream_type) {
plugin_node_t *node;
+ int i, j;
#ifdef LOG
printf ("load_plugins: looking for audio decoder for streamtype %02x\n",
stream_type);
#endif
- node = this->plugin_catalog->audio_decoder_map[stream_type];
+ for (i = 0; i < PLUGINS_PER_TYPE; i++) {
+ node = this->plugin_catalog->audio_decoder_map[stream_type][i];
- if (!node)
- return NULL;
+ if (!node)
+ return NULL;
- if (!node->plugin)
- node->plugin = _load_plugin(this, node->filename, node->info, NULL);
+ if (!node->plugin)
+ node->plugin = _load_plugin(this, node->filename, node->info, NULL);
- return node->plugin;
+ if (node->plugin)
+ return node->plugin;
+ else {
+ /* remove non working plugin from catalog */
+ for (j = i + 1; j < PLUGINS_PER_TYPE; j++)
+ this->plugin_catalog->audio_decoder_map[stream_type][j - 1] =
+ this->plugin_catalog->audio_decoder_map[stream_type][j];
+ this->plugin_catalog->audio_decoder_map[stream_type][PLUGINS_PER_TYPE] = NULL;
+ i--;
+ }
+ }
+ return NULL;
}
spu_decoder_t *get_spu_decoder (xine_t *this, uint8_t stream_type) {
plugin_node_t *node;
+ int i, j;
#ifdef LOG
printf ("load_plugins: looking for spu decoder for streamtype %02x\n",
stream_type);
#endif
- node = this->plugin_catalog->spu_decoder_map[stream_type];
+ for (i = 0; i < PLUGINS_PER_TYPE; i++) {
+ node = this->plugin_catalog->spu_decoder_map[stream_type][i];
- if (!node)
- return NULL;
+ if (!node)
+ return NULL;
- if (!node->plugin)
- node->plugin = _load_plugin(this, node->filename, node->info, NULL);
+ if (!node->plugin)
+ node->plugin = _load_plugin(this, node->filename, node->info, NULL);
- return node->plugin;
+ if (node->plugin)
+ return node->plugin;
+ else {
+ /* remove non working plugin from catalog */
+ for (j = i + 1; j < PLUGINS_PER_TYPE; j++)
+ this->plugin_catalog->spu_decoder_map[stream_type][j - 1] =
+ this->plugin_catalog->spu_decoder_map[stream_type][j];
+ this->plugin_catalog->spu_decoder_map[stream_type][PLUGINS_PER_TYPE] = NULL;
+ i--;
+ }
+ }
+ return NULL;
}
diff --git a/src/xine-engine/plugin_catalog.h b/src/xine-engine/plugin_catalog.h
index d65ea8e25..9e166d813 100644
--- a/src/xine-engine/plugin_catalog.h
+++ b/src/xine-engine/plugin_catalog.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: plugin_catalog.h,v 1.4 2002/09/06 18:13:12 mroi Exp $
+ * $Id: plugin_catalog.h,v 1.5 2002/09/09 13:57:13 mroi Exp $
*
* xine-internal header: Definitions for plugin lists
*
@@ -32,6 +32,9 @@
#define DECODER_MAX 256
#define PLUGIN_MAX 256
+/* the engine takes this many plugins for one stream type */
+#define PLUGINS_PER_TYPE 10
+
typedef struct {
char *filename;
plugin_info_t *info;
@@ -47,10 +50,10 @@ struct plugin_catalog_s {
xine_list_t *aout;
xine_list_t *vout;
- plugin_node_t *audio_decoder_map[DECODER_MAX];
- plugin_node_t *video_decoder_map[DECODER_MAX];
- plugin_node_t *spu_decoder_map[DECODER_MAX];
-
+ plugin_node_t *audio_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE];
+ plugin_node_t *video_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE];
+ plugin_node_t *spu_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE];
+
const char *ids[PLUGIN_MAX];
};