annotate src/crossfade/cfgutil.c @ 3113:90cdddf6f1c1

Flip signedness around to squelch ~15 warnings.
author Tony Vroon <chainsaw@gentoo.org>
date Mon, 04 May 2009 00:00:36 +0100
parents 43a336a7791b
children 3c445626fcc8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3059
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
1 /*
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
2 * XMMS Crossfade Plugin
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
3 * Copyright (C) 2000-2007 Peter Eisenlohr <peter@eisenlohr.org>
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
4 *
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
5 * based on the original OSS Output Plugin
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
6 * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
7 *
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
11 * (at your option) any later version.
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
12 *
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
16 * GNU General Public License for more details.
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
17 *
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
21 * USA.
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
22 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
23
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
25 # include "config.h"
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
26 #endif
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
27
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
28 #undef PRESET_SUPPORT
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
29
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
30 #include "crossfade.h"
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
31 #include "configure.h"
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
32
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
33 #include <stdio.h>
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
34 #include <string.h>
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
35 #include <stdlib.h>
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
36 #include <ctype.h>
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
37
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
38 # define ConfigFile ConfigDb
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
39 # define xmms_cfg_read_int aud_cfg_db_get_int
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
40 # define xmms_cfg_read_string aud_cfg_db_get_string
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
41 # define xmms_cfg_read_boolean aud_cfg_db_get_bool
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
42 # define xmms_cfg_write_int aud_cfg_db_set_int
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
43 # define xmms_cfg_write_string aud_cfg_db_set_string
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
44 # define xmms_cfg_write_boolean aud_cfg_db_set_bool
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
45 # define xmms_cfg_remove_key aud_cfg_db_unset_key
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
46 # define xmms_cfg_open_default_file aud_cfg_db_open
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
47 # define xmms_cfg_write_default_file aud_cfg_db_close
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
48 void xmms_cfg_dummy(ConfigDb *dummy) { }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
49 # define xmms_cfg_free xmms_cfg_dummy
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
50
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
51 /* init with DEFAULT_CFG to make sure all string pointers are set to NULL */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
52 config_t _xfg = CONFIG_DEFAULT; /* also used in configure.c */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
53 static config_t *xfg = &_xfg;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
54
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
55 /*****************************************************************************/
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
56
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
57 static void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
58 update_plugin_config(gchar **config_string, gchar *name, plugin_config_t *pc, gboolean save);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
59
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
60 static void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
61 g_free_f(gpointer data, gpointer user_data)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
62 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
63 g_free(data);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
64 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
65
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
66 /*****************************************************************************/
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
67
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
68 static gchar *strip(gchar *s)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
69 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
70 gchar *p;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
71 if (!s)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
72 return NULL;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
73
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
74 for (; *s == ' '; s++);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
75 if (!*s)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
76 return s;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
77
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
78 for (p = s + strlen(s) - 1; *p == ' '; p--);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
79 *++p = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
80 return s;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
81 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
82
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
83 static void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
84 update_plugin_config(gchar **config_string, gchar *name, plugin_config_t *pc, gboolean save)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
85 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
86 plugin_config_t default_pc = DEFAULT_OP_CONFIG;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
87
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
88 gchar *buffer = NULL;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
89 gchar out[1024];
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
90
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
91 gboolean plugin_found = FALSE;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
92 gchar *plugin, *next_plugin;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
93 gchar *args;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
94
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
95 if (pc && !save)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
96 *pc = default_pc;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
97
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
98 if (!config_string || !*config_string || !name || !pc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
99 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
100 DEBUG(("[crossfade] update_plugin_config: missing arg!\n"));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
101 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
102 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
103
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
104 buffer = g_strdup(*config_string);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
105 out[0] = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
106
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
107 for (plugin = buffer; plugin; plugin = next_plugin)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
108 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
109 if ((next_plugin = strchr(plugin, ';')))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
110 *next_plugin++ = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
111
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
112 if ((args = strchr(plugin, '=')))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
113 *args++ = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
114
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
115 plugin = strip(plugin);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
116 if (!*plugin || !args || !*args)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
117 continue;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
118
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
119 if (save)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
120 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
121 if (strcmp(plugin, name) == 0)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
122 continue;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
123
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
124 if (*out)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
125 strcat(out, "; ");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
126
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
127 strcat(out, plugin);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
128 strcat(out, "=");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
129 strcat(out, args);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
130 continue;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
131 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
132 else if (strcmp(plugin, name))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
133 continue;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
134
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
135 args = strip(args);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
136 sscanf(args, "%d,%d,%d,%d", &pc->throttle_enable, &pc->max_write_enable, &pc->max_write_len, &pc->force_reopen);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
137 pc->max_write_len &= -4;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
138 plugin_found = TRUE;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
139 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
140
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
141 if (save)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
142 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
143 /* only save if settings differ from defaults */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
144 if ((pc->throttle_enable != default_pc.throttle_enable)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
145 || (pc->max_write_enable != default_pc.max_write_enable)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
146 || (pc->max_write_len != default_pc.max_write_len)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
147 || (pc->force_reopen != default_pc.force_reopen))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
148 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
149 if (*out)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
150 strcat(out, "; ");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
151
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
152 sprintf(out + strlen(out), "%s=%d,%d,%d,%d", name,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
153 pc->throttle_enable ? 1 : 0, pc->max_write_enable ? 1 : 0, pc->max_write_len, pc->force_reopen);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
154 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
155 if (*config_string)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
156 g_free(*config_string);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
157
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
158 *config_string = g_strdup(out);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
159 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
160
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
161 g_free(buffer);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
162 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
163
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
164 /*****************************************************************************/
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
165
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
166 #ifdef PRESET_SUPPORT
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
167 static void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
168 scan_presets(gchar *filename)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
169 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
170 struct stat stats;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
171 FILE *fh;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
172 gchar *data, **lines, *tmp, *name;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
173 int i;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
174
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
175 if (lstat(filename, &stats))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
176 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
177 DEBUG(("[crossfade] scan_presets: \"%s\":\n", filename));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
178 PERROR("[crossfade] scan_presets: lstat");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
179 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
180 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
181 if (stats.st_size <= 0)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
182 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
183
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
184 if (!(data = g_malloc(stats.st_size + 1)))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
185 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
186 DEBUG(("[crossfade] scan_presets: g_malloc(%ld) failed!\n", stats.st_size));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
187 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
188 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
189
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
190 if (!(fh = fopen(filename, "r")))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
191 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
192 PERROR("[crossfade] scan_presets: fopen");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
193 g_free(data);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
194 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
195 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
196
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
197 if (fread(data, stats.st_size, 1, fh) != 1)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
198 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
199 DEBUG(("[crossfade] scan_presets: fread() failed!\n"));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
200 g_free(data);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
201 fclose(fh);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
202 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
203 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
204 fclose(fh);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
205 data[stats.st_size] = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
206
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
207 lines = g_strsplit(data, "\n", 0);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
208 g_free(data);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
209
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
210 if (!lines)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
211 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
212 DEBUG(("[crossfade] scan_presets: g_strsplit() failed!\n"));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
213 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
214 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
215
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
216 g_list_foreach(config->presets, g_free_f, NULL);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
217 g_list_free(config->presets);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
218 config->presets = NULL;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
219
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
220 for (i = 0; lines[i]; i++)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
221 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
222 if (lines[i][0] == '[')
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
223 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
224 if ((tmp = strchr(lines[i], ']')))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
225 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
226 *tmp = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
227 if ((name = g_strdup(lines[i] + 1)))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
228 config->presets = g_list_append(config->presets, name);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
229 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
230 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
231 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
232
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
233 g_strfreev(lines);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
234 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
235 #endif
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
236
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
237 static void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
238 read_fade_config(ConfigFile *cfgfile, gchar *section, gchar *key, fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
239 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
240 gchar *s = NULL;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
241 gint n;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
242
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
243 if (!cfgfile || !section || !key || !fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
244 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
245
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
246 xmms_cfg_read_string(cfgfile, section, key, &s);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
247 if (!s)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
248 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
249
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
250 n = sscanf(s,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
251 "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
252 &fc->type,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
253 &fc->pause_len_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
254 &fc->simple_len_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
255 &fc->out_enable,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
256 &fc->out_len_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
257 &fc->out_volume,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
258 &fc->ofs_type,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
259 &fc->ofs_type_wanted,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
260 &fc->ofs_custom_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
261 &fc->in_locked,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
262 &fc->in_enable,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
263 &fc->in_len_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
264 &fc->in_volume,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
265 &fc->flush_pause_enable,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
266 &fc->flush_pause_len_ms, &fc->flush_in_enable, &fc->flush_in_len_ms, &fc->flush_in_volume);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
267
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
268 g_free(s);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
269 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
270
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
271 static void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
272 write_fade_config(ConfigFile *cfgfile, gchar *section, gchar *key, fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
273 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
274 gchar *s;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
275
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
276 if (!cfgfile || !section || !key || !fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
277 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
278
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
279 s = g_strdup_printf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
280 fc->type,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
281 fc->pause_len_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
282 fc->simple_len_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
283 fc->out_enable,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
284 fc->out_len_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
285 fc->out_volume,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
286 fc->ofs_type,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
287 fc->ofs_type_wanted,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
288 fc->ofs_custom_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
289 fc->in_locked,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
290 fc->in_enable,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
291 fc->in_len_ms,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
292 fc->in_volume,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
293 fc->flush_pause_enable,
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
294 fc->flush_pause_len_ms, fc->flush_in_enable, fc->flush_in_len_ms, fc->flush_in_volume);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
295
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
296 if (!s)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
297 return;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
298
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
299 xmms_cfg_write_string(cfgfile, section, key, s);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
300 g_free(s);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
301 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
302
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
303 void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
304 xfade_load_config()
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
305 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
306 #ifdef PRESET_SUPPORT
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
307 gchar *filename;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
308 #endif
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
309 gchar *section = "Crossfade";
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
310 ConfigFile *cfgfile;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
311
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
312 if ((cfgfile = xmms_cfg_open_default_file()))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
313 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
314 /* *INDENT-OFF* */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
315 /* config items used in v0.1 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
316 xmms_cfg_read_int (cfgfile, section, "output_method", &config->output_method);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
317 xmms_cfg_read_int (cfgfile, section, "audio_device", &config->oss_audio_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
318 xmms_cfg_read_boolean(cfgfile, section, "use_alt_audio_device", &config->oss_use_alt_audio_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
319 xmms_cfg_read_string (cfgfile, section, "alt_audio_device", &config->oss_alt_audio_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
320 xmms_cfg_read_int (cfgfile, section, "mixer_device", &config->oss_mixer_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
321 xmms_cfg_read_string (cfgfile, section, "output_plugin", &config->op_name);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
322 xmms_cfg_read_string (cfgfile, section, "op_config_string", &config->op_config_string);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
323 xmms_cfg_read_int (cfgfile, section, "buffer_size", &config->mix_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
324 xmms_cfg_read_int (cfgfile, section, "sync_size", &config->sync_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
325 xmms_cfg_read_int (cfgfile, section, "preload_size", &config->preload_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
326 xmms_cfg_read_int (cfgfile, section, "songchange_timeout", &config->songchange_timeout);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
327 xmms_cfg_read_boolean(cfgfile, section, "enable_mixer", &config->enable_mixer);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
328 xmms_cfg_read_boolean(cfgfile, section, "mixer_reverse", &config->mixer_reverse);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
329 xmms_cfg_read_boolean(cfgfile, section, "enable_debug", &config->enable_debug);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
330 xmms_cfg_read_boolean(cfgfile, section, "enable_monitor", &config->enable_monitor);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
331
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
332 /* config items introduced by v0.2 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
333 xmms_cfg_read_int (cfgfile, section, "oss_buffer_size", &config->oss_buffer_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
334 xmms_cfg_read_int (cfgfile, section, "oss_preload_size", &config->oss_preload_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
335 xmms_cfg_read_boolean(cfgfile, section, "oss_mixer_use_master", &config->oss_mixer_use_master);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
336 xmms_cfg_read_boolean(cfgfile, section, "gap_lead_enable", &config->gap_lead_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
337 xmms_cfg_read_int (cfgfile, section, "gap_lead_len_ms", &config->gap_lead_len_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
338 xmms_cfg_read_int (cfgfile, section, "gap_lead_level", &config->gap_lead_level);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
339 xmms_cfg_read_boolean(cfgfile, section, "gap_trail_enable", &config->gap_trail_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
340 xmms_cfg_read_int (cfgfile, section, "gap_trail_len_ms", &config->gap_trail_len_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
341 xmms_cfg_read_int (cfgfile, section, "gap_trail_level", &config->gap_trail_level);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
342 xmms_cfg_read_int (cfgfile, section, "gap_trail_locked", &config->gap_trail_locked);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
343
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
344 /* config items introduced by v0.2.1 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
345 xmms_cfg_read_boolean(cfgfile, section, "buffer_size_auto", &config->mix_size_auto);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
346
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
347 /* config items introduced by v0.2.3 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
348 xmms_cfg_read_boolean(cfgfile, section, "album_detection", &config->album_detection);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
349
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
350 /* config items introduced by v0.2.4 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
351 xmms_cfg_read_boolean(cfgfile, section, "http_workaround", &config->enable_http_workaround);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
352 xmms_cfg_read_boolean(cfgfile, section, "enable_op_max_used", &config->enable_op_max_used);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
353 xmms_cfg_read_int (cfgfile, section, "op_max_used_ms", &config->op_max_used_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
354
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
355 /* config items introduced by v0.2.6 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
356 xmms_cfg_read_string (cfgfile, section, "effect_plugin", &config->ep_name);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
357 xmms_cfg_read_boolean(cfgfile, section, "effect_enable", &config->ep_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
358 xmms_cfg_read_int (cfgfile, section, "output_rate", &config->output_rate);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
359
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
360 /* config items introduced by v0.2.7 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
361 xmms_cfg_read_boolean(cfgfile, section, "oss_maxbuf_enable", &config->oss_maxbuf_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
362
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
363 /* config items introduced by v0.3.0 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
364 xmms_cfg_read_boolean(cfgfile, section, "use_alt_mixer_device", &config->oss_use_alt_mixer_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
365 xmms_cfg_read_int (cfgfile, section, "oss_fragments", &config->oss_fragments);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
366 xmms_cfg_read_int (cfgfile, section, "oss_fragment_size", &config->oss_fragment_size);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
367 xmms_cfg_read_boolean(cfgfile, section, "volnorm_enable", &config->volnorm_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
368 xmms_cfg_read_boolean(cfgfile, section, "volnorm_use_qa", &config->volnorm_use_qa);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
369 xmms_cfg_read_int (cfgfile, section, "volnorm_target", &config->volnorm_target);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
370 xmms_cfg_read_boolean(cfgfile, section, "output_keep_opened", &config->output_keep_opened);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
371 xmms_cfg_read_boolean(cfgfile, section, "mixer_software", &config->mixer_software);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
372 xmms_cfg_read_int (cfgfile, section, "mixer_vol_left", &config->mixer_vol_left);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
373 xmms_cfg_read_int (cfgfile, section, "mixer_vol_right", &config->mixer_vol_right);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
374
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
375 /* config items introduced by v0.3.2 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
376 xmms_cfg_read_boolean(cfgfile, section, "no_xfade_if_same_file",&config->no_xfade_if_same_file);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
377
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
378 /* config items introduced by v0.3.3 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
379 xmms_cfg_read_string (cfgfile, section, "alt_mixer_device", &config->oss_alt_mixer_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
380 xmms_cfg_read_boolean(cfgfile, section, "gap_crossing", &config->gap_crossing);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
381
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
382 /* config items introduced by v0.3.6 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
383 xmms_cfg_read_int (cfgfile, section, "output_quality", &config->output_quality);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
384
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
385 /* fade configs */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
386 read_fade_config(cfgfile, section, "fc_xfade", &config->fc[FADE_CONFIG_XFADE]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
387 read_fade_config(cfgfile, section, "fc_manual", &config->fc[FADE_CONFIG_MANUAL]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
388 read_fade_config(cfgfile, section, "fc_album", &config->fc[FADE_CONFIG_ALBUM]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
389 read_fade_config(cfgfile, section, "fc_start", &config->fc[FADE_CONFIG_START]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
390 read_fade_config(cfgfile, section, "fc_stop", &config->fc[FADE_CONFIG_STOP]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
391 read_fade_config(cfgfile, section, "fc_eop", &config->fc[FADE_CONFIG_EOP]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
392 read_fade_config(cfgfile, section, "fc_seek", &config->fc[FADE_CONFIG_SEEK]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
393 read_fade_config(cfgfile, section, "fc_pause", &config->fc[FADE_CONFIG_PAUSE]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
394
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
395 xmms_cfg_free(cfgfile);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
396 DEBUG(("[crossfade] load_config: configuration loaded\n"));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
397 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
398 else
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
399 DEBUG(("[crossfade] load_config: error loading config, using defaults\n"));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
400
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
401 #ifdef PRESET_SUPPORT
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
402 #ifdef COMPILE_FOR_AUDACIOUS
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
403 filename = g_strconcat(g_get_home_dir(), "/.audacious/crossfade-presets", NULL);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
404 #else
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
405 filename = g_strconcat(g_get_home_dir(), "/.xmms/crossfade-presets", NULL);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
406 #endif
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
407 scan_presets(filename);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
408 g_free(filename);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
409 #endif
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
410 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
411
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
412 void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
413 xfade_save_config()
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
414 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
415 gchar *section = "Crossfade";
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
416 ConfigFile *cfgfile;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
417
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
418 if ((cfgfile = xmms_cfg_open_default_file()))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
419 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
420 /* obsolete config items */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
421 xmms_cfg_remove_key(cfgfile, section, "underrun_pct");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
422 xmms_cfg_remove_key(cfgfile, section, "enable_crossfade");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
423 xmms_cfg_remove_key(cfgfile, section, "enable_gapkiller");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
424 xmms_cfg_remove_key(cfgfile, section, "mixer_use_master");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
425 xmms_cfg_remove_key(cfgfile, section, "late_effect");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
426 xmms_cfg_remove_key(cfgfile, section, "gap_lead_length");
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
427
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
428 /* config items used in v0.1 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
429 xmms_cfg_write_int (cfgfile, section, "output_method", config->output_method);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
430 xmms_cfg_write_int (cfgfile, section, "audio_device", config->oss_audio_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
431 xmms_cfg_write_boolean(cfgfile, section, "use_alt_audio_device", config->oss_use_alt_audio_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
432 xmms_cfg_write_string (cfgfile, section, "alt_audio_device", config->oss_alt_audio_device ? config->oss_alt_audio_device : DEFAULT_OSS_ALT_AUDIO_DEVICE);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
433 xmms_cfg_write_int (cfgfile, section, "mixer_device", config->oss_mixer_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
434 xmms_cfg_write_string (cfgfile, section, "output_plugin", config->op_name ? config->op_name : DEFAULT_OP_NAME);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
435 xmms_cfg_write_string (cfgfile, section, "op_config_string", config->op_config_string ? config->op_config_string : DEFAULT_OP_CONFIG_STRING);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
436 xmms_cfg_write_int (cfgfile, section, "buffer_size", config->mix_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
437 xmms_cfg_write_int (cfgfile, section, "sync_size", config->sync_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
438 xmms_cfg_write_int (cfgfile, section, "preload_size", config->preload_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
439 xmms_cfg_write_int (cfgfile, section, "songchange_timeout", config->songchange_timeout);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
440 xmms_cfg_write_boolean(cfgfile, section, "enable_mixer", config->enable_mixer);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
441 xmms_cfg_write_boolean(cfgfile, section, "mixer_reverse", config->mixer_reverse);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
442 xmms_cfg_write_boolean(cfgfile, section, "enable_debug", config->enable_debug);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
443 xmms_cfg_write_boolean(cfgfile, section, "enable_monitor", config->enable_monitor);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
444
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
445 /* config items introduced by v0.2 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
446 xmms_cfg_write_int (cfgfile, section, "oss_buffer_size", config->oss_buffer_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
447 xmms_cfg_write_int (cfgfile, section, "oss_preload_size", config->oss_preload_size_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
448 xmms_cfg_write_boolean(cfgfile, section, "oss_mixer_use_master", config->oss_mixer_use_master);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
449 xmms_cfg_write_boolean(cfgfile, section, "gap_lead_enable", config->gap_lead_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
450 xmms_cfg_write_int (cfgfile, section, "gap_lead_len_ms", config->gap_lead_len_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
451 xmms_cfg_write_int (cfgfile, section, "gap_lead_level", config->gap_lead_level);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
452 xmms_cfg_write_boolean(cfgfile, section, "gap_trail_enable", config->gap_trail_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
453 xmms_cfg_write_int (cfgfile, section, "gap_trail_len_ms", config->gap_trail_len_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
454 xmms_cfg_write_int (cfgfile, section, "gap_trail_level", config->gap_trail_level);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
455 xmms_cfg_write_int (cfgfile, section, "gap_trail_locked", config->gap_trail_locked);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
456
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
457 /* config items introduced by v0.2.1 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
458 xmms_cfg_write_boolean(cfgfile, section, "buffer_size_auto", config->mix_size_auto);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
459
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
460 /* config items introduced by v0.2.3 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
461 xmms_cfg_write_boolean(cfgfile, section, "album_detection", config->album_detection);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
462
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
463 /* config items introduced by v0.2.4 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
464 xmms_cfg_write_boolean(cfgfile, section, "http_workaround", config->enable_http_workaround);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
465 xmms_cfg_write_boolean(cfgfile, section, "enable_op_max_used", config->enable_op_max_used);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
466 xmms_cfg_write_int (cfgfile, section, "op_max_used_ms", config->op_max_used_ms);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
467
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
468 /* config items introduced by v0.2.6 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
469 xmms_cfg_write_int (cfgfile, section, "output_rate", config->output_rate);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
470
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
471 /* config items introduced by v0.2.7 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
472 xmms_cfg_write_boolean(cfgfile, section, "oss_maxbuf_enable", config->oss_maxbuf_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
473
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
474 /* config items introduced by v0.3.0 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
475 xmms_cfg_write_boolean(cfgfile, section, "use_alt_mixer_device", config->oss_use_alt_mixer_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
476 xmms_cfg_write_int (cfgfile, section, "oss_fragments", config->oss_fragments);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
477 xmms_cfg_write_int (cfgfile, section, "oss_fragment_size", config->oss_fragment_size);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
478 #ifdef VOLUME_NORMALIZER
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
479 xmms_cfg_write_boolean(cfgfile, section, "volnorm_enable", config->volnorm_enable);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
480 xmms_cfg_write_boolean(cfgfile, section, "volnorm_use_qa", config->volnorm_use_qa);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
481 xmms_cfg_write_int (cfgfile, section, "volnorm_target", config->volnorm_target);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
482 #endif
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
483 xmms_cfg_write_boolean(cfgfile, section, "output_keep_opened", config->output_keep_opened);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
484 xmms_cfg_write_boolean(cfgfile, section, "mixer_software", config->mixer_software);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
485 xmms_cfg_write_int (cfgfile, section, "mixer_vol_left", config->mixer_vol_left);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
486 xmms_cfg_write_int (cfgfile, section, "mixer_vol_right", config->mixer_vol_right);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
487
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
488 /* config items introduced by v0.3.2 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
489 xmms_cfg_write_boolean(cfgfile, section, "no_xfade_if_same_file",config->no_xfade_if_same_file);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
490
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
491 /* config items introduced by v0.3.2 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
492 xmms_cfg_write_string (cfgfile, section, "alt_mixer_device", config->oss_alt_mixer_device ? config->oss_alt_mixer_device : DEFAULT_OSS_ALT_MIXER_DEVICE);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
493 xmms_cfg_write_boolean(cfgfile, section, "gap_crossing", config->gap_crossing);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
494
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
495 /* config items introduced by v0.3.6 */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
496 xmms_cfg_write_int(cfgfile, section, "output_quality", config->output_quality);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
497
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
498 /* fade configs */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
499 write_fade_config(cfgfile, section, "fc_xfade", &config->fc[FADE_CONFIG_XFADE]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
500 write_fade_config(cfgfile, section, "fc_manual", &config->fc[FADE_CONFIG_MANUAL]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
501 write_fade_config(cfgfile, section, "fc_album", &config->fc[FADE_CONFIG_ALBUM]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
502 write_fade_config(cfgfile, section, "fc_start", &config->fc[FADE_CONFIG_START]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
503 write_fade_config(cfgfile, section, "fc_stop", &config->fc[FADE_CONFIG_STOP]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
504 write_fade_config(cfgfile, section, "fc_eop", &config->fc[FADE_CONFIG_EOP]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
505 write_fade_config(cfgfile, section, "fc_seek", &config->fc[FADE_CONFIG_SEEK]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
506 write_fade_config(cfgfile, section, "fc_pause", &config->fc[FADE_CONFIG_PAUSE]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
507 /* *INDENT-ON* */
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
508
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
509 xmms_cfg_write_default_file(cfgfile);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
510 xmms_cfg_free(cfgfile);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
511 DEBUG(("[crossfade] save_config: configuration saved\n"));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
512 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
513 else
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
514 DEBUG(("[crossfade] save_config: error saving configuration!\n"));
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
515 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
516
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
517 #define SAFE_FREE(x) if(x) { g_free(x); x = NULL; }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
518 void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
519 xfade_free_config()
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
520 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
521 SAFE_FREE(xfg->oss_alt_audio_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
522 SAFE_FREE(xfg->oss_alt_mixer_device);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
523 SAFE_FREE(xfg->op_config_string);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
524 SAFE_FREE(xfg->op_name);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
525
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
526 g_list_foreach(config->presets, g_free_f, NULL);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
527 g_list_free(config->presets);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
528 config->presets = NULL;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
529 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
530
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
531 void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
532 xfade_load_plugin_config(gchar *config_string, gchar *plugin_name, plugin_config_t *plugin_config)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
533 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
534 update_plugin_config(&config_string, plugin_name, plugin_config, FALSE);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
535 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
536
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
537 void
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
538 xfade_save_plugin_config(gchar **config_string, gchar *plugin_name, plugin_config_t *plugin_config)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
539 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
540 update_plugin_config(config_string, plugin_name, plugin_config, TRUE);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
541 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
542
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
543 /*** helpers *****************************************************************/
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
544
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
545 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
546 xfade_cfg_out_skip(fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
547 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
548 if (!fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
549 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
550
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
551 switch (fc->config)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
552 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
553 case FADE_CONFIG_TIMING:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
554 return fc->out_skip_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
555 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
556 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
557 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
558
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
559 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
560 xfade_cfg_fadeout_len(fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
561 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
562 if (!fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
563 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
564
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
565 switch (fc->type)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
566 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
567 case FADE_TYPE_SIMPLE_XF:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
568 return fc->simple_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
569
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
570 case FADE_TYPE_ADVANCED_XF:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
571 return fc->out_enable ? fc->out_len_ms : 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
572
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
573 case FADE_TYPE_FADEOUT:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
574 case FADE_TYPE_PAUSE_ADV:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
575 return fc->out_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
576 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
577 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
578 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
579
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
580 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
581 xfade_cfg_fadeout_volume(fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
582 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
583 gint volume;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
584 if (!fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
585 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
586
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
587 switch (fc->type)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
588 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
589 case FADE_TYPE_ADVANCED_XF:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
590 case FADE_TYPE_FADEOUT:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
591 volume = fc->out_volume;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
592 if (volume < 0) volume = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
593 if (volume > 100) volume = 100;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
594 return volume;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
595 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
596 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
597 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
598
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
599 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
600 xfade_cfg_offset(fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
601 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
602 if (!fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
603 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
604
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
605 switch (fc->type)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
606 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
607 case FADE_TYPE_FLUSH:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
608 return fc->flush_pause_enable ? fc->flush_pause_len_ms : 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
609
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
610 case FADE_TYPE_PAUSE:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
611 return fc->pause_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
612
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
613 case FADE_TYPE_SIMPLE_XF:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
614 return -fc->simple_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
615
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
616 case FADE_TYPE_ADVANCED_XF:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
617 switch (fc->ofs_type)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
618 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
619 case FC_OFFSET_LOCK_OUT: return -fc->out_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
620 case FC_OFFSET_LOCK_IN: return -fc->in_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
621 case FC_OFFSET_CUSTOM: return fc->ofs_custom_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
622 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
623 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
624
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
625 case FADE_TYPE_FADEOUT:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
626 case FADE_TYPE_PAUSE_ADV:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
627 return fc->ofs_custom_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
628 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
629 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
630 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
631
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
632 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
633 xfade_cfg_in_skip(fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
634 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
635 if (!fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
636 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
637
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
638 switch (fc->config)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
639 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
640 case FADE_CONFIG_TIMING:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
641 return fc->in_skip_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
642 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
643 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
644 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
645
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
646 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
647 xfade_cfg_fadein_len(fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
648 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
649 if (!fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
650 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
651
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
652 switch (fc->type)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
653 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
654 case FADE_TYPE_FLUSH:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
655 return fc->flush_in_enable ? fc->flush_in_len_ms : 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
656
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
657 case FADE_TYPE_SIMPLE_XF:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
658 return fc->simple_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
659
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
660 case FADE_TYPE_ADVANCED_XF:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
661 return fc->in_locked
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
662 ? (fc->out_enable ? fc->out_len_ms : 0)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
663 : (fc->in_enable ? fc->in_len_ms : 0);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
664
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
665 case FADE_TYPE_FADEIN:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
666 case FADE_TYPE_PAUSE_ADV:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
667 return fc->in_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
668 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
669 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
670 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
671
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
672 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
673 xfade_cfg_fadein_volume(fade_config_t *fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
674 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
675 gint volume;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
676 if (!fc)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
677 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
678
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
679 switch (fc->type)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
680 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
681 case FADE_TYPE_FLUSH:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
682 volume = fc->flush_in_volume;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
683 break;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
684
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
685 case FADE_TYPE_ADVANCED_XF:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
686 volume = fc->in_locked ? fc->out_volume : fc->in_volume;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
687 break;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
688
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
689 case FADE_TYPE_FADEIN:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
690 volume = fc->in_volume;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
691 break;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
692
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
693 default:
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
694 volume = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
695 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
696
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
697 if (volume < 0) volume = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
698 if (volume > 100) volume = 100;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
699 return volume;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
700 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
701
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
702 gboolean
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
703 xfade_cfg_gap_trail_enable(config_t *cfg)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
704 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
705 return xfg->gap_trail_locked ? xfg->gap_lead_enable : xfg->gap_trail_enable;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
706 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
707
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
708 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
709 xfade_cfg_gap_trail_len(config_t *cfg)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
710 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
711 if (!xfade_cfg_gap_trail_enable(cfg))
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
712 return 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
713
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
714 return xfg->gap_trail_locked ? xfg->gap_lead_len_ms : xfg->gap_trail_len_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
715 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
716
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
717 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
718 xfade_cfg_gap_trail_level(config_t *cfg)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
719 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
720 return xfg->gap_trail_locked ? xfg->gap_lead_level : xfg->gap_trail_level;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
721 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
722
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
723 gint
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
724 xfade_mix_size_ms(config_t *cfg)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
725 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
726 if (xfg->mix_size_auto)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
727 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
728 gint i, min_size = 0;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
729
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
730 for (i = 0; i < MAX_FADE_CONFIGS; i++)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
731 {
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
732 gint size = xfade_cfg_fadeout_len(&xfg->fc[i]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
733 gint offset = xfade_cfg_offset(&xfg->fc[i]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
734
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
735 if (xfg->fc[i].type == FADE_TYPE_PAUSE_ADV)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
736 size += xfade_cfg_fadein_len(&xfg->fc[i]);
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
737
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
738 if (size < -offset)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
739 size = -offset;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
740
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
741 if (size > min_size)
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
742 min_size = size;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
743 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
744 return min_size += xfade_cfg_gap_trail_len(cfg) + xfg->songchange_timeout;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
745 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
746 else
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
747 return xfg->mix_size_ms;
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
748 }
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
749
2e241e90494a Import work in progress xmms-crossfade rewrite.
William Pitcock <nenolod@atheme.org>
parents:
diff changeset
750 /*****************************************************************************/