Mercurial > hg > xmms-sid
comparison src/xs_config.c @ 960:5711abf1ff39
Improve automatic re-configuration, trying to provide at least usable
settings when migrating from another backend library etc.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 20 Nov 2012 22:39:27 +0200 |
parents | f8e1de328ac1 |
children | 85ceec25b059 |
comparison
equal
deleted
inserted
replaced
959:32435407eb9c | 960:5711abf1ff39 |
---|---|
211 static const gint xs_nwidtable = sizeof(xs_cfgitems) / sizeof(xs_cfgitems[0]); | 211 static const gint xs_nwidtable = sizeof(xs_cfgitems) / sizeof(xs_cfgitems[0]); |
212 | 212 |
213 | 213 |
214 /* Check configuration | 214 /* Check configuration |
215 */ | 215 */ |
216 gboolean xs_check_configuration(void) | 216 gboolean xs_check_configuration(gboolean checkOnly) |
217 { | 217 { |
218 gboolean changed = FALSE; | |
219 | |
220 // Automatic adjustments | |
221 switch (xs_cfg.playerEngine) | |
222 { | |
223 #if !defined(HAVE_SIDPLAYFP) | |
224 case XS_ENG_SIDPLAYFP: | |
225 changed = TRUE; | |
226 #if defined(HAVE_SIDPLAY2) | |
227 xs_cfg.playerEngine = XS_ENG_SIDPLAY2; break; | |
228 #elif defined(HAVE_SIDPLAY1) | |
229 xs_cfg.playerEngine = XS_ENG_SIDPLAY1; break; | |
230 #endif | |
231 #endif | |
232 | |
233 #if !defined(HAVE_SIDPLAY2) | |
234 case XS_ENG_SIDPLAY2: | |
235 changed = TRUE; | |
236 #if defined(HAVE_SIDPLAYFP) | |
237 xs_cfg.playerEngine = XS_ENG_SIDPLAYFP; break; | |
238 #elif defined(HAVE_SIDPLAY1) | |
239 xs_cfg.playerEngine = XS_ENG_SIDPLAY1; break; | |
240 #endif | |
241 #endif | |
242 | |
243 #if !defined(HAVE_SIDPLAY1) | |
244 case XS_ENG_SIDPLAY1: | |
245 changed = TRUE; | |
246 #if defined(HAVE_SIDPLAYFP) | |
247 xs_cfg.playerEngine = XS_ENG_SIDPLAYFP; break; | |
248 #elif defined(HAVE_SIDPLAY2) | |
249 xs_cfg.playerEngine = XS_ENG_SIDPLAY2; break; | |
250 #endif | |
251 #endif | |
252 } | |
253 | |
254 switch (xs_cfg.sid2Builder) | |
255 { | |
256 #if !defined(HAVE_RESID_BUILDER) && defined(HAVE_RESID_FP_BUILDER) | |
257 case XS_BLD_RESID: | |
258 changed = TRUE; | |
259 xs_cfg.sid2Builder = XS_BLD_RESID_FP; break; | |
260 #endif | |
261 #if defined(HAVE_RESID_BUILDER) && !defined(HAVE_RESID_FP_BUILDER) | |
262 case XS_BLD_RESID_FP: | |
263 changed = TRUE; | |
264 xs_cfg.sid2Builder = XS_BLD_RESID; break; | |
265 #endif | |
266 | |
267 #if !defined(HAVE_HARDSID_BUILDER) | |
268 case XS_BLD_HARDSID: | |
269 changed = TRUE; | |
270 #if defined(HAVE_RESID_FP_BUILDER) | |
271 xs_cfg.sid2Builder = XS_BLD_RESID_FP; break; | |
272 #elif defined(HAVE_RESID_BUILDER) | |
273 xs_cfg.sid2Builder = XS_BLD_RESID; break; | |
274 #endif | |
275 #endif | |
276 } | |
277 | |
218 // Check for plain errors | 278 // Check for plain errors |
219 switch (xs_cfg.playerEngine) | 279 switch (xs_cfg.playerEngine) |
220 { | 280 { |
221 case XS_ENG_SIDPLAYFP: | 281 case XS_ENG_SIDPLAYFP: |
222 { | 282 { |
223 if (xs_cfg.romPath == NULL || xs_cfg.romPath[0] == 0) | 283 if (xs_cfg.romPath == NULL || xs_cfg.romPath[0] == 0) |
224 { | 284 { |
285 if (checkOnly) return FALSE; | |
225 xs_messagebox(_("Error"), | 286 xs_messagebox(_("Error"), |
226 _("You have selected libSIDPlayFP backend, but not set the C64 ROM images directory.\n")); | 287 _("You have selected libSIDPlayFP backend, but not set the C64 ROM images directory.\n")); |
227 return FALSE; | 288 return FALSE; |
228 } | 289 } |
229 | 290 |
230 if (!xs_is_dir_path(xs_cfg.romPath)) | 291 if (!xs_is_dir_path(xs_cfg.romPath)) |
231 { | 292 { |
293 if (checkOnly) return FALSE; | |
232 xs_messagebox(_("Error"), | 294 xs_messagebox(_("Error"), |
233 _("The C64 ROM images directory path '%s' is not a directory.\n"), | 295 _("The C64 ROM images directory path '%s' is not a directory.\n"), |
234 xs_cfg.romPath); | 296 xs_cfg.romPath); |
235 return FALSE; | 297 return FALSE; |
236 } | 298 } |
253 g_free(buf); | 315 g_free(buf); |
254 } | 316 } |
255 | 317 |
256 if (result != NULL) | 318 if (result != NULL) |
257 { | 319 { |
320 if (checkOnly) return FALSE; | |
258 xs_messagebox(_("Error"), | 321 xs_messagebox(_("Error"), |
259 _("Could not load the required C64 ROM image files from '%s'.\n" | 322 _("Could not load the required C64 ROM image files from '%s'.\n" |
260 "\n" | 323 "\n" |
261 "Following files could not be found: %s."), | 324 "Following files could not be found: %s."), |
262 xs_cfg.romPath, result); | 325 xs_cfg.romPath, result); |
265 } | 328 } |
266 } | 329 } |
267 break; | 330 break; |
268 } | 331 } |
269 | 332 |
270 // Automatic adjustments | 333 return !changed; |
271 switch (xs_cfg.sid2Builder) | |
272 { | |
273 #if !defined(HAVE_RESID_BUILDER) && defined(HAVE_RESID_FP_BUILDER) | |
274 case XS_BLD_RESID: xs_cfg.sid2Builder = XS_BLD_RESID_FP; break; | |
275 #endif | |
276 #if defined(HAVE_RESID_BUILDER) && !defined(HAVE_RESID_FP_BUILDER) | |
277 case XS_BLD_RESID_FP: xs_cfg.sid2Builder = XS_BLD_RESID; break; | |
278 #endif | |
279 #if !defined(HAVE_HARDSID_BUILDER) | |
280 case XS_BLD_HARDSID: | |
281 #if defined(HAVE_RESID_FP_BUILDER) | |
282 xs_cfg.sid2Builder = XS_BLD_RESID_FP; break; | |
283 #elif defined(HAVE_RESID_BUILDER) | |
284 xs_cfg.sid2Builder = XS_BLD_RESID; break; | |
285 #endif | |
286 #endif | |
287 } | |
288 | |
289 return TRUE; | |
290 } | 334 } |
291 | 335 |
292 | 336 |
293 /* Reset/initialize the configuration | 337 /* Reset/initialize the configuration |
294 */ | 338 */ |
312 xs_cfg.emulateFilters = TRUE; | 356 xs_cfg.emulateFilters = TRUE; |
313 xs_cfg.sid1Filter.fs = XS_SIDPLAY1_FS; | 357 xs_cfg.sid1Filter.fs = XS_SIDPLAY1_FS; |
314 xs_cfg.sid1Filter.fm = XS_SIDPLAY1_FM; | 358 xs_cfg.sid1Filter.fm = XS_SIDPLAY1_FM; |
315 xs_cfg.sid1Filter.ft = XS_SIDPLAY1_FT; | 359 xs_cfg.sid1Filter.ft = XS_SIDPLAY1_FT; |
316 | 360 |
317 #if defined(HAVE_SIDPLAY2) | 361 #if defined(HAVE_SIDPLAYFP) |
362 xs_cfg.playerEngine = XS_ENG_SIDPLAYFP; | |
363 xs_cfg.memoryMode = XS_MPU_REAL; | |
364 #elif defined(HAVE_SIDPLAY2) | |
318 xs_cfg.playerEngine = XS_ENG_SIDPLAY2; | 365 xs_cfg.playerEngine = XS_ENG_SIDPLAY2; |
319 xs_cfg.memoryMode = XS_MPU_REAL; | 366 xs_cfg.memoryMode = XS_MPU_REAL; |
320 #elif defined(HAVE_SIDPLAY1) | 367 #elif defined(HAVE_SIDPLAY1) |
321 xs_cfg.playerEngine = XS_ENG_SIDPLAY1; | 368 xs_cfg.playerEngine = XS_ENG_SIDPLAY1; |
322 xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; | 369 xs_cfg.memoryMode = XS_MPU_BANK_SWITCHING; |
323 #elif !defined(HAVE_SIDPLAYFP) | 370 #else |
324 #error This should not happen! No emulator engines configured in! | 371 # error This should not happen! No emulator engines configured in! |
325 #endif | 372 #endif |
326 | 373 |
327 xs_cfg.clockSpeed = XS_CLOCK_PAL; | 374 xs_cfg.clockSpeed = XS_CLOCK_PAL; |
328 xs_cfg.forceSpeed = FALSE; | 375 xs_cfg.forceSpeed = FALSE; |
329 | 376 |
330 xs_cfg.sid2OptLevel = 0; | 377 xs_cfg.sid2OptLevel = 0; |
331 xs_cfg.sid2NFilterPresets = 0; | 378 xs_cfg.sid2NFilterPresets = 0; |
332 | 379 |
333 #if defined(HAVE_RESID_BUILDER) || defined(HAVE_RESID_FP_BUILDER) | 380 #if defined(HAVE_RESID_FP_BUILDER) |
381 xs_cfg.sid2Builder = XS_BLD_RESID_FP; | |
382 #elif defined(HAVE_RESID_BUILDER) | |
334 xs_cfg.sid2Builder = XS_BLD_RESID; | 383 xs_cfg.sid2Builder = XS_BLD_RESID; |
335 #elif defined(HAVE_HARDSID_BUILDER) | 384 #elif defined(HAVE_HARDSID_BUILDER) |
336 xs_cfg.sid2Builder = XS_BLD_HARDSID; | 385 xs_cfg.sid2Builder = XS_BLD_HARDSID; |
337 #elif defined(HAVE_SIDPLAY2) | 386 #elif defined(HAVE_SIDPLAY2) |
338 # error This should not happen! No supported SIDPlay2 builders configured in! | 387 # error This should not happen! No supported SIDPlay2 builders configured in! |
872 for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) | 921 for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) |
873 xs_cfg.sid2FilterPresets[i] = xs_filter_load(cfg, i); | 922 xs_cfg.sid2FilterPresets[i] = xs_filter_load(cfg, i); |
874 } | 923 } |
875 } | 924 } |
876 | 925 |
926 // Do a final check | |
927 if (!xs_check_configuration(TRUE)) | |
928 configOK = FALSE; | |
929 | |
877 error: | 930 error: |
878 if (cfg != NULL) | 931 if (cfg != NULL) |
879 { | 932 { |
880 XS_CONFIG_FREE(cfg); | 933 XS_CONFIG_FREE(cfg); |
881 } | 934 } |
1023 gtk_entry_get_text(GTK_ENTRY(LUW(xs_cfgitems[i].widName)))); | 1076 gtk_entry_get_text(GTK_ENTRY(LUW(xs_cfgitems[i].widName)))); |
1024 break; | 1077 break; |
1025 } | 1078 } |
1026 | 1079 |
1027 // Check the settings | 1080 // Check the settings |
1028 if (!xs_check_configuration()) | 1081 if (!xs_check_configuration(FALSE)) |
1029 goto error; | 1082 goto error; |
1030 | 1083 |
1031 /* Get filter settings */ | 1084 /* Get filter settings */ |
1032 /* | 1085 /* |
1033 if (!xs_curve_get_points(XS_CURVE(LUW("")), &xs_cfg.sid2Filter.points, &xs_cfg.sid2Filter.npoints)) { | 1086 if (!xs_curve_get_points(XS_CURVE(LUW("")), &xs_cfg.sid2Filter.points, &xs_cfg.sid2Filter.npoints)) { |