summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Roitzsch <mroi@users.sourceforge.net>2003-01-13 17:43:08 +0000
committerMichael Roitzsch <mroi@users.sourceforge.net>2003-01-13 17:43:08 +0000
commit0f637614aca58c2eaf35231e682188a3177fe2b8 (patch)
treeecfdbde1ceb078ec1ee22e169dd1cffb9d835b6d
parentff6b3b711b74ff5f8b19ca453be261a19aa92177 (diff)
downloadxine-lib-0f637614aca58c2eaf35231e682188a3177fe2b8.tar.gz
xine-lib-0f637614aca58c2eaf35231e682188a3177fe2b8.tar.bz2
autoscan plugins and config entries are ordered now
good news for Daniel: no frontend change is required, the entries are sorted inside the engine I did not change the config entry names for now, because they seem well sorted already, so I avoided breaking everyones config file. But it is now possible to name the config keys in a <section>.<plugin>.<entry> style (instead of the old <section>.<entry> style) resulting in entries of the same plugin being sorted next to each other. CVS patchset: 3901 CVS date: 2003/01/13 17:43:08
-rw-r--r--src/xine-engine/configfile.c117
-rw-r--r--src/xine-engine/load_plugins.c28
2 files changed, 123 insertions, 22 deletions
diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c
index dff921e8b..495b71d17 100644
--- a/src/xine-engine/configfile.c
+++ b/src/xine-engine/configfile.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: configfile.c,v 1.41 2002/12/21 16:25:31 rockyb Exp $
+ * $Id: configfile.c,v 1.42 2003/01/13 17:43:08 mroi Exp $
*
* config object (was: file) management - implementation
*
@@ -60,9 +60,33 @@ static char *copy_string (const char *str) {
return cpy;
}
+static int enum_config_section(const char *sect) {
+ static char *known_section[] = {
+ "gui",
+ "audio",
+ "video",
+ "dxr3",
+ "input",
+ "codec",
+ "post",
+ "decoder",
+ "misc",
+ NULL
+ };
+ int i = 0;
+
+ while (known_section[i])
+ if (strcmp(sect, known_section[i++]) == 0)
+ return i;
+ return i + 1;
+}
+
static cfg_entry_t *xine_config_add (config_values_t *this, const char *key) {
- cfg_entry_t *entry;
+ cfg_entry_t *entry, *cur, *prev;
+ char *new_parse, *new_section, *new_plugin, *new_name;
+ char *cur_parse, *cur_section, *cur_plugin, *cur_name;
+ char *tmp;
entry = (cfg_entry_t *) xine_xmalloc (sizeof (cfg_entry_t));
entry->config = this;
@@ -72,18 +96,93 @@ static cfg_entry_t *xine_config_add (config_values_t *this, const char *key) {
entry->str_sticky = NULL;
entry->str_value = NULL;
- entry->next = NULL;
-
- if (this->last)
- this->last->next = entry;
+ /* extract parts of the new key */
+ new_parse = strdup(key);
+ cur_parse = NULL;
+ if ((tmp = strchr(new_parse, '.'))) {
+ new_section = new_parse;
+ *tmp = '\0';
+ tmp++;
+ if ((new_name = strchr(tmp, '.'))) {
+ new_plugin = tmp;
+ *new_name = '\0';
+ new_name++;
+ } else {
+ new_plugin = NULL;
+ new_name = tmp;
+ }
+ } else {
+ new_section = NULL;
+ new_plugin = NULL;
+ new_name = new_parse;
+ }
+
+ /* search right position */
+ for (cur = this->first, prev = NULL; cur; prev = cur, cur = cur->next) {
+ /* extract parts of the cur key */
+ free(cur_parse);
+ cur_parse = strdup(cur->key);
+ if ((tmp = strchr(cur_parse, '.'))) {
+ cur_section = cur_parse;
+ *tmp = '\0';
+ tmp++;
+ if ((cur_name = strchr(tmp, '.'))) {
+ cur_plugin = tmp;
+ *cur_name = '\0';
+ cur_name++;
+ } else {
+ cur_plugin = NULL;
+ cur_name = tmp;
+ }
+ } else {
+ cur_section = NULL;
+ cur_plugin = NULL;
+ cur_name = cur_parse;
+ }
+
+ /* sort by section name */
+ if (!new_section && cur_section) break;
+ if ( new_section && !cur_section) continue;
+ if ( new_section && cur_section) {
+ int new_sec_num = enum_config_section(new_section);
+ int cur_sec_num = enum_config_section(cur_section);
+ int cmp = strcmp(new_section, cur_section);
+ if (new_sec_num < cur_sec_num) break;
+ if (new_sec_num > cur_sec_num) continue;
+ if (cmp < 0) break;
+ if (cmp > 0) continue;
+ }
+ /* sort by plugin name */
+ if (!new_plugin && cur_plugin) break;
+ if ( new_plugin && !cur_plugin) continue;
+ if ( new_plugin && cur_plugin) {
+ int cmp = strcmp(new_plugin, cur_plugin);
+ if (cmp < 0) break;
+ if (cmp > 0) continue;
+ }
+ /* sort by entry name */
+ {
+ int cmp = strcmp(new_name, cur_name);
+ if (cmp < 0) break;
+ if (cmp > 0) continue;
+ }
+
+ break;
+ }
+
+ entry->next = cur;
+ if (!cur)
+ this->last = entry;
+ if (prev)
+ prev->next = entry;
else
this->first = entry;
-
- this->last = entry;
-
+
#ifdef LOG
printf ("configfile: add entry key=%s\n", key);
#endif
+ free(new_parse);
+ free(cur_parse);
return entry;
}
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index 62083a13c..2f3034176 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.132 2003/01/11 21:22:20 mroi Exp $
+ * $Id: load_plugins.c,v 1.133 2003/01/13 17:43:11 mroi Exp $
*
*
* Load input/demux/audio_out/video_out/codec plugins
@@ -1088,30 +1088,31 @@ demux_plugin_t *find_demux_plugin_by_name(xine_stream_t *stream, const char *nam
const char *const *xine_get_autoplay_input_plugin_ids(xine_t *this) {
plugin_catalog_t *catalog;
- int i;
plugin_node_t *node;
catalog = this->plugin_catalog;
pthread_mutex_lock (&catalog->lock);
- i = 0;
+ catalog->ids[0] = NULL;
node = xine_list_first_content (catalog->input);
while (node) {
input_class_t *ic;
ic = (input_class_t *) node->plugin_class;
if (ic->get_autoplay_list) {
+ int i = 0, j;
- catalog->ids[i] = node->info->id;
+ while (catalog->ids[i] && strcmp(catalog->ids[i], node->info->id) < 0)
+ i++;
+ for (j = PLUGIN_MAX - 1; j > i; j--)
+ catalog->ids[j] = catalog->ids[j - 1];
- i++;
+ catalog->ids[i] = node->info->id;
}
node = xine_list_next_content (catalog->input);
}
- catalog->ids[i] = NULL;
-
pthread_mutex_unlock (&catalog->lock);
return catalog->ids;
@@ -1121,30 +1122,31 @@ const char *const *xine_get_browsable_input_plugin_ids(xine_t *this) {
plugin_catalog_t *catalog;
- int i;
plugin_node_t *node;
catalog = this->plugin_catalog;
pthread_mutex_lock (&catalog->lock);
- i = 0;
+ catalog->ids[0] = NULL;
node = xine_list_first_content (catalog->input);
while (node) {
input_class_t *ic;
ic = (input_class_t *) node->plugin_class;
if (ic->get_dir) {
+ int i = 0, j;
- catalog->ids[i] = node->info->id;
+ while (catalog->ids[i] && strcmp(catalog->ids[i], node->info->id) < 0)
+ i++;
+ for (j = PLUGIN_MAX - 1; j > i; j--)
+ catalog->ids[j] = catalog->ids[j - 1];
- i++;
+ catalog->ids[i] = node->info->id;
}
node = xine_list_next_content (catalog->input);
}
- catalog->ids[i] = NULL;
-
pthread_mutex_unlock (&catalog->lock);
return catalog->ids;