From 7bc0c45b59a958ce1545eef9df0148efd5ae1f92 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Fri, 29 Mar 2013 09:47:42 -0300 Subject: [PATCH] [xmp] Allow module configuration to override default module quirks Libxmp 4.0.3 includes built-in module quirks for well-known cases. Allow modules.conf to override these default settings. Signed-off-by: Claudio Matsuoka --- Changelog | 3 +++ src/common.h | 4 +++- src/main.c | 18 ++++++++++++++++-- src/read_config.c | 11 ++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Changelog b/Changelog index df48b28..8a74e4f 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,9 @@ Stable versions 4.0.2 (): - Fix data type in coreaudio driver + - Allow modules.conf to override default module quirks when + using libxmp 4.0.3 or newer + - Don't rescan module if using libxmp 4.0.3 or newer Changes by Jan Engelhardt: - give Pulseaudio higher priority than ALSA diff --git a/src/common.h b/src/common.h index 38c9977..fe9e747 100644 --- a/src/common.h +++ b/src/common.h @@ -15,7 +15,9 @@ struct options { int loop; /* loop module */ int random; /* play in random order */ int reverse; /* reverse stereo channels */ - int flags; /* player flags */ + int vblank; /* vblank flag */ + int fx9bug; /* fx9bug flag */ + int fixloop; /* fixloop flag */ int verbose; /* verbosity level */ int silent; /* silent output */ int info; /* display information and exit */ diff --git a/src/main.c b/src/main.c index 98d6555..f2c9eb2 100644 --- a/src/main.c +++ b/src/main.c @@ -169,6 +169,7 @@ int main(int argc, char **argv) #ifndef WIN32 struct timeval tv; struct timezone tz; + int flags; gettimeofday(&tv, &tz); srand(tv.tv_usec); @@ -355,10 +356,23 @@ int main(int argc, char **argv) /* Set player flags */ - xmp_set_player(xc, XMP_PLAYER_FLAGS, opt.flags); - if (opt.flags & XMP_FLAGS_VBLANK) { +#define set_flag(x,y,z) do { \ + if ((y) > 0) (x) |= (z); \ + else if ((y) < 0) (x) &= ~ (z); \ +} while (0) + + flags = xmp_get_player(xc, XMP_PLAYER_FLAGS); + + set_flag(flags, opt.vblank, XMP_FLAGS_VBLANK); + set_flag(flags, opt.fx9bug, XMP_FLAGS_FX9BUG); + set_flag(flags, opt.fixloop, XMP_FLAGS_FIXLOOP); + + xmp_set_player(xc, XMP_PLAYER_FLAGS, flags); +#if XMP_VERCODE < 0x040003 + if (flags & XMP_FLAGS_VBLANK) { xmp_scan_module(xc); } +#endif /* Show module data */ diff --git a/src/read_config.c b/src/read_config.c index 00d78c3..8e31e46 100644 --- a/src/read_config.c +++ b/src/read_config.c @@ -98,6 +98,10 @@ int read_config(struct options *o) if (!strcmp(var,x)) { if (get_yesno (val)) w |= (y); \ else w &= ~(y); continue; } } +#define getval_tristate(x,w) { \ + if (!strcmp(var,x)) { if (get_yesno (val)) w = 1; \ + else w = -1; continue; } } + #define getval_no(x,y) { \ if (!strcmp(var,x)) { y = atoi (val); continue; } } @@ -221,9 +225,10 @@ static void parse_modconf(struct options *o, char *confname, unsigned char *md5) getval_yn("reverse", o->reverse, 1); getval_no("amplify", o->amplify); getval_no("mix", o->mix); - getval_yn("fixloop", o->flags, XMP_FLAGS_FIXLOOP); - getval_yn("fx9bug", o->flags, XMP_FLAGS_FX9BUG); - getval_yn("vblank", o->flags, XMP_FLAGS_VBLANK); + + getval_tristate("fixloop", o->fixloop); + getval_tristate("fx9bug", o->fx9bug); + getval_tristate("vblank", o->vblank); if (!strcmp(var, "interpolation")) { if (!strcmp(val, "nearest")) {