Audacious $Id:Doxyfile42802007-03-2104:39:00Znenolod$
|
00001 /* Audacious - Cross-platform multimedia player 00002 * Copyright (C) 2005-2010 Audacious development team. 00003 * 00004 * Based on BMP: 00005 * Copyright (C) 2003-2004 BMP development team. 00006 * 00007 * Based on XMMS: 00008 * Copyright (C) 1998-2003 XMMS development team. 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; under version 3 of the License. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program. If not, see <http://www.gnu.org/licenses>. 00021 * 00022 * The Audacious team does not consider modular code linking to 00023 * Audacious or using our public API to be a derived work. 00024 */ 00025 00026 #include <glib.h> 00027 #include <libaudcore/hook.h> 00028 00029 #ifdef HAVE_CONFIG_H 00030 # include "config.h" 00031 #endif 00032 00033 #include "audconfig.h" 00034 #include "configdb.h" 00035 #include "effect.h" 00036 #include "general.h" 00037 #include "output.h" 00038 #include "playback.h" 00039 #include "pluginenum.h" 00040 #include "plugins.h" 00041 #include "util.h" 00042 #include "visualization.h" 00043 00044 AudConfig cfg = { 00045 .shuffle = FALSE, 00046 .repeat = FALSE, 00047 .equalizer_autoload = FALSE, 00048 .equalizer_active = FALSE, 00049 .playlist_visible = FALSE, 00050 .equalizer_visible = FALSE, 00051 .player_visible = TRUE, 00052 .show_numbers_in_pl = TRUE, 00053 .no_playlist_advance = FALSE, 00054 .stopaftersong = FALSE, 00055 .close_dialog_open = TRUE, 00056 .equalizer_preamp = 0.0, 00057 .equalizer_bands = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, 00058 .filesel_path = NULL, 00059 .playlist_path = NULL, 00060 .eqpreset_default_file = NULL, 00061 .eqpreset_extension = NULL, 00062 .url_history = NULL, 00063 .resume_playback_on_startup = FALSE, 00064 .resume_state = 0, 00065 .resume_playback_on_startup_time = 0, 00066 .chardet_detector = NULL, 00067 .chardet_fallback = NULL, 00068 .chardet_fallback_s = NULL, 00069 .output_buffer_size = 500, 00070 .show_filepopup_for_tuple = TRUE, 00071 .cover_name_include = NULL, /* words identifying covers */ 00072 .cover_name_exclude = NULL, /* words that might not show up in cover names */ 00073 .recurse_for_cover = FALSE, 00074 .recurse_for_cover_depth = 0, 00075 .filepopup_pixelsize = 150, /* short side length of the picture in the filepopup */ 00076 .filepopup_delay = 20, /* delay until the filepopup comes up */ 00077 .use_file_cover = FALSE, /* use filename.jpg for coverart */ 00078 .filepopup_showprogressbar = TRUE, 00079 .close_jtf_dialog = TRUE, /* close jtf dialog on jump */ 00080 .software_volume_control = FALSE, 00081 .remember_jtf_entry = TRUE, 00082 .output_bit_depth = 16, 00083 .enable_replay_gain = TRUE, 00084 .enable_clipping_prevention = TRUE, 00085 .replay_gain_track = TRUE, /* track mode */ 00086 .replay_gain_album = FALSE, /* album mode */ 00087 .replay_gain_preamp = 0, 00088 .default_gain = 0, 00089 .sw_volume_left = 100, .sw_volume_right = 100, 00090 .clear_playlist = TRUE, 00091 .output_path = NULL, 00092 .output_number = -1, 00093 .iface_path = NULL, 00094 .iface_number = -1, 00095 00096 /* libaudgui stuff */ 00097 .no_confirm_playlist_delete = FALSE, 00098 .playlist_manager_x = 0, 00099 .playlist_manager_y = 0, 00100 .playlist_manager_width = 0, 00101 .playlist_manager_height = 0, 00102 .playlist_manager_close_on_activate = FALSE, 00103 00104 /* not saved */ 00105 .verbose = FALSE, 00106 }; 00107 00108 typedef struct aud_cfg_boolent_t { 00109 char const *be_vname; 00110 gboolean *be_vloc; 00111 gboolean be_wrt; 00112 } aud_cfg_boolent; 00113 00114 typedef struct aud_cfg_nument_t { 00115 char const *ie_vname; 00116 gint *ie_vloc; 00117 gboolean ie_wrt; 00118 } aud_cfg_nument; 00119 00120 typedef struct aud_cfg_strent_t { 00121 char const *se_vname; 00122 char **se_vloc; 00123 gboolean se_wrt; 00124 } aud_cfg_strent; 00125 00126 static aud_cfg_boolent aud_boolents[] = { 00127 {"show_numbers_in_pl", &cfg.show_numbers_in_pl, TRUE}, 00128 {"no_playlist_advance", &cfg.no_playlist_advance, TRUE}, 00129 {"player_visible", &cfg.player_visible, TRUE}, 00130 {"shuffle", &cfg.shuffle, TRUE}, 00131 {"repeat", &cfg.repeat, TRUE}, 00132 {"stop_after_current_song", &cfg.stopaftersong, TRUE}, 00133 {"playlist_visible", &cfg.playlist_visible, TRUE}, 00134 {"equalizer_visible", &cfg.equalizer_visible, TRUE}, 00135 {"equalizer_active", &cfg.equalizer_active, TRUE}, 00136 {"equalizer_autoload", &cfg.equalizer_autoload, TRUE}, 00137 {"close_dialog_open", &cfg.close_dialog_open, TRUE}, 00138 {"resume_playback_on_startup", &cfg.resume_playback_on_startup, TRUE}, 00139 {"show_filepopup_for_tuple", &cfg.show_filepopup_for_tuple, TRUE}, 00140 {"recurse_for_cover", &cfg.recurse_for_cover, TRUE}, 00141 {"use_file_cover", &cfg.use_file_cover, TRUE}, 00142 {"filepopup_showprogressbar", &cfg.filepopup_showprogressbar, TRUE}, 00143 {"close_jtf_dialog", &cfg.close_jtf_dialog, TRUE}, 00144 {"software_volume_control", &cfg.software_volume_control, TRUE}, 00145 {"remember_jtf_entry", &cfg.remember_jtf_entry, TRUE}, 00146 {"enable_replay_gain", &cfg.enable_replay_gain, TRUE}, 00147 {"enable_clipping_prevention", &cfg.enable_clipping_prevention, TRUE}, 00148 {"replay_gain_track", &cfg.replay_gain_track, TRUE}, 00149 {"replay_gain_album", &cfg.replay_gain_album, TRUE}, 00150 {"clear_playlist", &cfg.clear_playlist, TRUE}, 00151 {"no_confirm_playlist_delete", &cfg.no_confirm_playlist_delete, TRUE}, 00152 {"playlist_manager_close_on_activate", 00153 & cfg.playlist_manager_close_on_activate, TRUE}, 00154 }; 00155 00156 static gint ncfgbent = G_N_ELEMENTS(aud_boolents); 00157 00158 static aud_cfg_nument aud_numents[] = { 00159 {"titlestring_preset", &cfg.titlestring_preset, TRUE}, 00160 {"resume_state", & cfg.resume_state, TRUE}, 00161 {"resume_playback_on_startup_time", &cfg.resume_playback_on_startup_time, TRUE}, 00162 {"output_buffer_size", &cfg.output_buffer_size, TRUE}, 00163 {"recurse_for_cover_depth", &cfg.recurse_for_cover_depth, TRUE}, 00164 {"filepopup_pixelsize", &cfg.filepopup_pixelsize, TRUE}, 00165 {"filepopup_delay", &cfg.filepopup_delay, TRUE}, 00166 {"output_bit_depth", &cfg.output_bit_depth, TRUE}, 00167 {"sw_volume_left", & cfg.sw_volume_left, TRUE}, 00168 {"sw_volume_right", & cfg.sw_volume_right, TRUE}, 00169 {"output_number", & cfg.output_number, TRUE}, 00170 {"iface_number", & cfg.iface_number, TRUE}, 00171 {"playlist_manager_x", & cfg.playlist_manager_x, TRUE}, 00172 {"playlist_manager_y", & cfg.playlist_manager_y, TRUE}, 00173 {"playlist_manager_width", & cfg.playlist_manager_width, TRUE}, 00174 {"playlist_manager_height", & cfg.playlist_manager_height, TRUE}, 00175 }; 00176 00177 static gint ncfgient = G_N_ELEMENTS(aud_numents); 00178 00179 static aud_cfg_strent aud_strents[] = { 00180 {"eqpreset_default_file", &cfg.eqpreset_default_file, TRUE}, 00181 {"eqpreset_extension", &cfg.eqpreset_extension, TRUE}, 00182 {"filesel_path", &cfg.filesel_path, FALSE}, 00183 {"playlist_path", &cfg.playlist_path, FALSE}, 00184 {"generic_title_format", &cfg.gentitle_format, TRUE}, 00185 {"chardet_detector", &cfg.chardet_detector, TRUE}, 00186 {"chardet_fallback", &cfg.chardet_fallback, TRUE}, 00187 {"cover_name_include", &cfg.cover_name_include, TRUE}, 00188 {"cover_name_exclude", &cfg.cover_name_exclude, TRUE}, 00189 {"output_path", & cfg.output_path, TRUE}, 00190 {"iface_path", & cfg.iface_path, TRUE}, 00191 }; 00192 00193 static gint ncfgsent = G_N_ELEMENTS(aud_strents); 00194 00195 void 00196 aud_config_free(void) 00197 { 00198 gint i; 00199 for (i = 0; i < ncfgsent; ++i) { 00200 if ( *(aud_strents[i].se_vloc) != NULL ) 00201 { 00202 g_free( *(aud_strents[i].se_vloc) ); 00203 *(aud_strents[i].se_vloc) = NULL; 00204 } 00205 } 00206 } 00207 00208 void aud_config_chardet_update(void) 00209 { 00210 if (cfg.chardet_fallback_s != NULL) 00211 g_strfreev(cfg.chardet_fallback_s); 00212 cfg.chardet_fallback_s = g_strsplit_set(cfg.chardet_fallback, " ,:;|/", 0); 00213 } 00214 00215 00216 void 00217 aud_config_load(void) 00218 { 00219 mcs_handle_t *db; 00220 gint i, length; 00221 00222 db = cfg_db_open(); 00223 for (i = 0; i < ncfgbent; ++i) { 00224 cfg_db_get_bool(db, NULL, 00225 aud_boolents[i].be_vname, 00226 aud_boolents[i].be_vloc); 00227 } 00228 00229 for (i = 0; i < ncfgient; ++i) { 00230 cfg_db_get_int(db, NULL, 00231 aud_numents[i].ie_vname, 00232 aud_numents[i].ie_vloc); 00233 } 00234 00235 for (i = 0; i < ncfgsent; ++i) { 00236 cfg_db_get_string(db, NULL, 00237 aud_strents[i].se_vname, 00238 aud_strents[i].se_vloc); 00239 } 00240 00241 /* Preset */ 00242 cfg_db_get_float(db, NULL, "equalizer_preamp", &cfg.equalizer_preamp); 00243 for (i = 0; i < AUD_EQUALIZER_NBANDS; i++) { 00244 gchar eqtext[32]; 00245 00246 g_snprintf(eqtext, sizeof(eqtext), "equalizer_band%d", i); 00247 cfg_db_get_float(db, NULL, eqtext, &cfg.equalizer_bands[i]); 00248 } 00249 00250 /* History */ 00251 if (cfg_db_get_int(db, NULL, "url_history_length", &length)) { 00252 for (i = 1; i <= length; i++) { 00253 gchar str[19], *tmp; 00254 00255 g_snprintf(str, sizeof(str), "url_history%d", i); 00256 if (cfg_db_get_string(db, NULL, str, &tmp)) 00257 cfg.url_history = g_list_append(cfg.url_history, tmp); 00258 } 00259 } 00260 00261 /* RG settings */ 00262 cfg_db_get_float(db, NULL, "replay_gain_preamp", &cfg.replay_gain_preamp); 00263 cfg_db_get_float(db, NULL, "default_gain", &cfg.default_gain); 00264 00265 cfg_db_close(db); 00266 00267 if (!cfg.gentitle_format) 00268 cfg.gentitle_format = g_strdup("${?artist:${artist} - }${?album:${album} - }${title}"); 00269 00270 if (!cfg.chardet_detector) 00271 cfg.chardet_detector = g_strdup(""); 00272 00273 if (!cfg.chardet_fallback) 00274 cfg.chardet_fallback = g_strdup(""); 00275 00276 aud_config_chardet_update(); 00277 00278 if (!cfg.cover_name_include) 00279 cfg.cover_name_include = g_strdup("album,folder"); 00280 00281 if (!cfg.cover_name_exclude) 00282 cfg.cover_name_exclude = g_strdup("back"); 00283 } 00284 00285 static void save_output_path (void) 00286 { 00287 const gchar * path = NULL; 00288 gint type, number = -1; 00289 00290 if (current_output_plugin != NULL) 00291 plugin_get_path (plugin_by_header (current_output_plugin), & path, 00292 & type, & number); 00293 00294 g_free (cfg.output_path); 00295 cfg.output_path = (path != NULL) ? g_strdup (path) : NULL; 00296 cfg.output_number = number; 00297 } 00298 00299 void 00300 aud_config_save(void) 00301 { 00302 GList *node; 00303 gchar *str; 00304 gint i; 00305 mcs_handle_t *db; 00306 00307 hook_call ("config save", NULL); 00308 00309 cfg.resume_state = playback_get_playing () ? (playback_get_paused () ? 2 : 00310 1) : 0; 00311 cfg.resume_playback_on_startup_time = playback_get_playing () ? 00312 playback_get_time () : 0; 00313 00314 save_output_path (); 00315 00316 db = cfg_db_open(); 00317 00318 for (i = 0; i < ncfgbent; ++i) 00319 if (aud_boolents[i].be_wrt) 00320 cfg_db_set_bool(db, NULL, 00321 aud_boolents[i].be_vname, 00322 *aud_boolents[i].be_vloc); 00323 00324 for (i = 0; i < ncfgient; ++i) 00325 if (aud_numents[i].ie_wrt) 00326 cfg_db_set_int(db, NULL, 00327 aud_numents[i].ie_vname, 00328 *aud_numents[i].ie_vloc); 00329 00330 for (i = 0; i < ncfgsent; ++i) { 00331 if (aud_strents[i].se_wrt) 00332 cfg_db_set_string(db, NULL, 00333 aud_strents[i].se_vname, 00334 *aud_strents[i].se_vloc); 00335 } 00336 00337 cfg_db_set_float(db, NULL, "equalizer_preamp", cfg.equalizer_preamp); 00338 00339 /* RG settings */ 00340 cfg_db_set_float(db, NULL, "replay_gain_preamp", cfg.replay_gain_preamp); 00341 cfg_db_set_float(db, NULL, "default_gain", cfg.default_gain); 00342 00343 for (i = 0; i < 10; i++) { 00344 str = g_strdup_printf("equalizer_band%d", i); 00345 cfg_db_set_float(db, NULL, str, cfg.equalizer_bands[i]); 00346 g_free(str); 00347 } 00348 00349 if (cfg.filesel_path) 00350 cfg_db_set_string(db, NULL, "filesel_path", cfg.filesel_path); 00351 00352 if (cfg.playlist_path) 00353 cfg_db_set_string(db, NULL, "playlist_path", cfg.playlist_path); 00354 00355 cfg_db_set_int(db, NULL, "url_history_length", 00356 g_list_length(cfg.url_history)); 00357 00358 for (node = cfg.url_history, i = 1; node; node = g_list_next(node), i++) { 00359 str = g_strdup_printf("url_history%d", i); 00360 cfg_db_set_string(db, NULL, str, node->data); 00361 g_free(str); 00362 } 00363 00364 cfg_db_close(db); 00365 }