Package-Name: xmp
Rebuild-For: xmms XFree86 Xorg
Homepage: http://xmp.sourceforge.net/
Source: sourceforge:///xmp/xmp-(\d+.\d+.\d+).tar.gz $1
Zap-Before-Install: 1
Repack:
	tar xzvfp "$(SOURCE)"
Compile:
	$(MAKE) -f ../Makefile configure
	$(MAKE)
	umask 022 ; mkdir -p "$(PREFIX)"/{bin,etc,man/man1}
	rm -rf "$(PREFIX)"/bin/xmp
	cp -fp src/main/xmp "$(PREFIX)"/bin/
	set -e ; if test -f src/xmms/xmp-plugin.so ; then \
		mkdir -p "$(PREFIX)"/lib/xmms/Input ; \
		mv -f src/xmms/xmp-plugin.so "$(PREFIX)"/lib/xmms/Input/ ; \
	else \
		rm -rf "$(PREFIX)"/lib/xmms ; \
		rmdir "$(PREFIX)"/lib || true ; \
	fi
	if test -f "$(PREFIX)"/etc/xmp.conf ; then mv -f "$(PREFIX)"/etc/xmp.conf "$(PREFIX)"/etc/xmp.conf.old ; fi
	if test -f "$(PREFIX)"/etc/xmp-modules.conf ; then mv -f "$(PREFIX)"/etc/xmp-modules.conf "$(PREFIX)"/etc/xmp-modules.conf.old ; fi
	cp -fp etc/xmp{,-modules}.conf "$(PREFIX)"/etc/
	cp -fp docs/xmp.1 "$(PREFIX)"/man/man1/
Install:
	$(MAKE) instbin BIN=xmp
	$(MAKE) instetc ETC="xmp.conf xmp-modules.conf"
	$(MAKE) instman SECTION=1 MAN=xmp
	if test -f "$(PREFIX)"/lib/xmms/Input/xmp-plugin.so ; then \
		ln -fs "$(PREFIX)"/lib/xmms/Input/xmp-plugin.so /usr/lib/xmms/Input/ ; \
	else \
		rm -f /usr/lib/xmms/Input/xmp-plugin.so ; \
	fi
Patch: <<EOT
######## begin stop-build-on-error.diff
--- ../xmp-2.5.1-orig/src/Makefile	2007-10-21 21:59:15 +0900
+++ src/Makefile	2007-12-15 01:14:07 +0900
@@ -9,8 +9,9 @@
 DCFILES	=
 
 all install::
-	@for i in $(_DIRS); do	\
-		(cd $$i && $(MAKE) $@)	\
+	@set -e;			\
+	for i in $(_DIRS); do		\
+		$(MAKE) -C $$i $@;	\
 	done
 
 include $(TOPDIR)/Makefile.rules
######## end stop-build-on-error.diff
######## begin tone-vslide-fix.diff
--- ../xmp-2.5.1-orig/src/player/player.c	2007-12-05 21:24:42 +0900
+++ src/player/player.c	2007-12-15 01:15:33 +0900
@@ -286,7 +286,8 @@
         } else if (key == XMP_KEY_OFF) {
             SET(RELEASE);
 	    flg &= ~(RESET_VOL | RESET_ENV);
-	} else if (e->fxt == FX_TONEPORTA || e->f2t == FX_TONEPORTA) {
+	} else if (e->fxt == FX_TONEPORTA   || e->f2t == FX_TONEPORTA
+		|| e->fxt == FX_TONE_VSLIDE || e->f2t == FX_TONE_VSLIDE) {
 	    /* This test should fix portamento behaviour in 7spirits.s3m */
 	    if (m->fetch & XMP_CTL_RTGINS && e->ins && xc->ins != ins) {
 		flg |= NEW_INS;
######## end tone-vslide-fix.diff
######## begin envelope-reset-fix.diff
--- ../xmp-2.5.1-orig/src/player/player.c	2007-12-05 21:24:42 +0900
+++ src/player/player.c	2007-12-15 01:17:14 +0900
@@ -415,9 +415,6 @@
 	SET(ECHOBACK);
     }
 
-    if (xc->key == 0xff || XXIM.ins[xc->key] == 0xff)
-        return XMP_OK;
-
     if (TEST(RESET_ENV)) {
         /* xc->fadeout = 0x8000; -- moved to fetch */
         RESET(RELEASE | FADEOUT);
@@ -429,6 +426,9 @@
 	xc->resonance = XXI->ifr & 0x80 ? (XXI->ifr - 0x80) * 2 : 0;
     }
 
+    if (xc->key == 0xff || XXIM.ins[xc->key] == 0xff)
+        return XMP_OK;
+
     if (TEST(RESET_VOL)) {
         xc->volume = XXI[XXIM.ins[xc->key]].vol;
         SET(ECHOBACK | NEW_VOL);
######## end envelope-reset-fix.diff
######## begin missing-difftime-prototype-fix.diff
--- ../xmp-2.5.1-orig/src/misc/control.c	2007-11-21 08:38:19 +0900
+++ src/misc/control.c	2007-12-15 01:24:21 +0900
@@ -15,6 +15,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <ctype.h>
 #include <time.h>
 #include <sys/time.h>
######## end missing-difftime-prototype-fix.diff
######## begin no-tempo-zero.diff
--- ../xmp-2.5.1-orig/src/player/player.c	2007-12-05 21:24:42 +0900
+++ src/player/player.c	2007-12-15 01:28:01 +0900
@@ -879,7 +879,9 @@
 		    if (p->pos == 0)
 			e = p->xmp_scan_num;
 
-		    p->tempo = m->xxo_info[ord = p->pos].tempo;
+		    ord = p->pos;
+		    if (m->xxo_info[ord].tempo)
+			p->tempo = m->xxo_info[ord].tempo;
 		    p->tick_time = m->rrate / (p->xmp_bpm = m->xxo_info[ord].bpm);
 		    m->volume = m->xxo_info[ord].gvl;
 		    p->flow.jump = ord;
######## end no-tempo-zero.diff
######## begin reset-dsp-on-exit.diff
--- ../xmp-2.5.1-orig/src/drivers/oss_mix.c	2007-10-22 19:33:08 +0900
+++ src/drivers/oss_mix.c	2007-12-15 01:28:50 +0900
@@ -235,6 +235,7 @@
 static void shutdown ()
 {
     xmp_smix_off();
+    ioctl(audio_fd, SNDCTL_DSP_RESET);
     close(audio_fd);
 }
 
######## end reset-dsp-on-exit.diff
######## begin local fix to not apply portamento on first tick (fixes Biomechanoid, I think?)
--- ../xmp-2.5.1-orig/src/player/player.c	2007-12-05 21:24:42 +0900
+++ src/player/player.c	2007-12-15 01:29:40 +0900
@@ -722,7 +722,7 @@
     }
 
     /* Do tone portamento */
-    if (TEST(TONEPORTA) || TEST_PER(TONEPORTA)) {
+    if (t && (TEST(TONEPORTA) || TEST_PER(TONEPORTA))) {
 	xc->period += xc->s_sgn * xc->s_val;
 	if ((xc->s_sgn * xc->s_end) < (xc->s_sgn * xc->period)) {
 	    xc->period = xc->s_end;
######## end local fix to not apply portamento on first tick
EOT
NoPatch: <<EOT
######## begin xmms plugin not flushing fix --> xmms module gone?
--- src/xmms/plugin.c.old	2004-08-25 11:16:08 +0900
+++ src/xmms/plugin.c	2004-08-25 11:58:53 +0900
@@ -162,7 +162,8 @@
 		return;
 
 	_D("*** stop!");
-	xmp_stop_module (); 
+	xmp_stop_module ();
+	xmp_going = 0;
 	pthread_join (decode_thread, NULL);
 }
 
--- src/xmms/xmms_mix.c.old	2000-12-30 03:16:36 +0900
+++ src/xmms/xmms_mix.c	2004-08-25 11:58:18 +0900
@@ -34,6 +34,7 @@
 
 static int init (struct xmp_control *);
 static void bufdump (int);
+static void flush ();
 static void shutdown ();
 
 static void dummy () { }
@@ -54,7 +55,7 @@
     dummy,		/* setbend */
     xmp_smix_seteffect,	/* seteffect */
     dummy,		/* starttimer */
-    dummy,		/* stctlimer */
+    flush,		/* stctlimer */
     dummy,		/* resetvoices */
     bufdump,		/* bufdump */
     dummy,		/* bufwipe */
@@ -104,6 +105,15 @@
 }
 
 
+static void flush ()
+{
+    xmp_ip.output->buffer_free();
+    xmp_ip.output->buffer_free();
+    while(xmp_going && xmp_ip.output->buffer_playing())
+        xmms_usleep(10000);
+}
+
+
 static void shutdown ()
 {
     xmp_smix_off ();
######## end xmms plugin not flushing fix
EOT

-/etc/xmp.conf
-/etc/xmp-modules.conf
-/etc/xmprc
/etc/xmp.conf
/etc/xmp-modules.conf
/etc/xmprc
/usr/lib/xmms/Input/xmp-plugin.so
/pkg/xmp/
/usr/bin/xmp
/usr/man/man1/xmp.1.gz
