Re: audio/mikmod: fix bug causing ri-li crash

2013-01-09 Thread Stuart Henderson
On 2012/12/31 01:50, Stefan Sperling wrote:
 Perhaps mikmod should be updated but I'd rather just fix this for now.

updated to 3.2.0 here, some of the patches were rolled in, and I've
added a comment in patches for the remaining ones where it's not obvious.


Index: Makefile
===
RCS file: /cvs/ports/audio/libmikmod/Makefile,v
retrieving revision 1.23
diff -u -p -r1.23 Makefile
--- Makefile2 Jan 2013 15:13:02 -   1.23
+++ Makefile10 Jan 2013 00:36:33 -
@@ -2,13 +2,11 @@
 
 COMMENT=   mikmod sound library
 
-VERSION=   3.1.10
-DISTNAME=  libmikmod-${VERSION}
-REVISION=  10
-SHARED_LIBS += mikmod   2.4  # .2.4
-CATEGORIES=audio devel
+DISTNAME=  libmikmod-3.2.0
+SHARED_LIBS += mikmod   3.0  # .3.0
+CATEGORIES=audio devel
 
-HOMEPAGE=  http://mikmod.raphnet.net/
+HOMEPAGE=  http://mikmod.shlomifish.org/
 
 MAINTAINER=Peter Valchev pvalc...@openbsd.org
 
@@ -17,15 +15,14 @@ PERMIT_PACKAGE_FTP= Yes
 PERMIT_DISTFILES_CDROM=Yes
 PERMIT_DISTFILES_FTP=  Yes
 
-MASTER_SITES=  ${HOMEPAGE}/files/libmikmod/ \
-   ${MASTER_SITE_SUNSITE:=apps/sound/libs/}
+MASTER_SITES=  ${HOMEPAGE}files/
 
-WANTLIB=   sndio
+WANTLIB=   m sndio
 
 SEPARATE_BUILD=Yes
 CONFIGURE_STYLE= gnu
 USE_LIBTOOL=   Yes
-CFLAGS +=  -DDRV_SNDIO
+CFLAGS +=  -DDRV_SNDIO
 CONFIGURE_ENV= LIBRARY_LIB=-lsndio
 CONFIGURE_ARGS+= ${CONFIGURE_SHARED}
 CONFIGURE_ARGS+= --disable-dl \
Index: distinfo
===
RCS file: /cvs/ports/audio/libmikmod/distinfo,v
retrieving revision 1.3
diff -u -p -r1.3 distinfo
--- distinfo5 Apr 2007 15:37:43 -   1.3
+++ distinfo10 Jan 2013 00:36:33 -
@@ -1,5 +1,2 @@
-MD5 (libmikmod-3.1.10.tar.gz) = FL8/GM8Bh/XatG5Co93ahA==
-RMD160 (libmikmod-3.1.10.tar.gz) = lAqGyTHuyjhFYeruuIykSKgN7dA=
-SHA1 (libmikmod-3.1.10.tar.gz) = jU2uxmsX5Vbol3ywd8QYYRGAjg0=
-SHA256 (libmikmod-3.1.10.tar.gz) = bsVgmdzZcE53BANo+E50tpac5vKvxbSkvpAYrBwBdDg=
-SIZE (libmikmod-3.1.10.tar.gz) = 528929
+SHA256 (libmikmod-3.2.0.tar.gz) = c0yEkLv5sMWHkguSQU3Po8ImeDigzfaY1fH7a7qPZh4=
+SIZE (libmikmod-3.2.0.tar.gz) = 873258
Index: patches/patch-configure
===
RCS file: /cvs/ports/audio/libmikmod/patches/patch-configure,v
retrieving revision 1.1
diff -u -p -r1.1 patch-configure
--- patches/patch-configure 11 Jan 2010 04:25:26 -  1.1
+++ patches/patch-configure 10 Jan 2013 00:36:33 -
@@ -1,12 +1,15 @@
-$OpenBSD: patch-configure,v 1.1 2010/01/11 04:25:26 jakemsr Exp $
 configure.orig Sat Dec 19 01:48:17 2009
-+++ configure  Sat Dec 19 01:48:17 2009
-@@ -3682,7 +3682,7 @@ done
+$OpenBSD$
+
+sndio
+
+--- configure.orig Thu Jan 10 00:24:22 2013
 configure  Thu Jan 10 00:24:28 2013
+@@ -13343,7 +13343,7 @@ done
libmikmod_driver_hp=yes
fi
;;
 -  NetBSD|OpenBSD)
 +  NetBSD)
-   for ac_hdr in sys/audioio.h
- do
- ac_safe=`echo $ac_hdr | sed 'y%./+-%__p_%'`
+   for ac_header in sys/audioio.h
+ do :
+   ac_fn_c_check_header_mongrel $LINENO sys/audioio.h 
ac_cv_header_sys_audioio_h $ac_includes_default
Index: patches/patch-drivers_drv_wav_c
===
RCS file: patches/patch-drivers_drv_wav_c
diff -N patches/patch-drivers_drv_wav_c
--- patches/patch-drivers_drv_wav_c 16 Jun 2003 04:30:57 -  1.1
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,21 +0,0 @@
-$OpenBSD: patch-drivers_drv_wav_c,v 1.1 2003/06/16 04:30:57 pvalchev Exp $
 drivers/drv_wav.c.orig Sat Jan 12 18:00:14 2002
-+++ drivers/drv_wav.c  Sun Jun 15 22:26:13 2003
-@@ -148,6 +148,17 @@ static void WAV_Update(void)
-   ULONG done;
- 
-   done=VC_WriteBytes(audiobuffer,BUFFERSIZE);
-+#if BYTE_ORDER == BIG_ENDIAN
-+  if (md_mode  DMODE_16BITS) {
-+  ULONG i;
-+  SWORD *w = audiobuffer;
-+
-+  for (i = 0; i  done; i += 2) {
-+  *w = ((*w  0xff)  8) | ((*w  0xff00)  8);
-+  w++;
-+  }
-+  }
-+#endif
-   _mm_write_UBYTES(audiobuffer,done,wavout);
-   dumpsize+=done;
- }
Index: patches/patch-include_mikmod_h_in
===
RCS file: /cvs/ports/audio/libmikmod/patches/patch-include_mikmod_h_in,v
retrieving revision 1.2
diff -u -p -r1.2 patch-include_mikmod_h_in
--- patches/patch-include_mikmod_h_in   11 Jan 2010 04:25:26 -  1.2
+++ patches/patch-include_mikmod_h_in   10 Jan 2013 00:36:33 -
@@ -1,16 +1,16 @@
-$OpenBSD: patch-include_mikmod_h_in,v 1.2 2010/01/11 04:25:26 jakemsr Exp $
 include/mikmod.h.in.orig   Thu Jan 17 14:39:38 2002
-+++ include/mikmod.h.inFri Dec 18 23:53:46 2009
+$OpenBSD$
+--- 

Re: audio/mikmod: fix bug causing ri-li crash

2013-01-09 Thread Stefan Sperling
On Thu, Jan 10, 2013 at 12:37:54AM +, Stuart Henderson wrote:
 On 2012/12/31 01:50, Stefan Sperling wrote:
  Perhaps mikmod should be updated but I'd rather just fix this for now.
 
 updated to 3.2.0 here, some of the patches were rolled in, and I've
 added a comment in patches for the remaining ones where it's not obvious.

Diff is fine with me. Unfortunately this update breaks sdl-mixer :(

Rebuilding sdl-mixer with this update leads to the following output
from sdl-mixer's configure script:

checking for libmikmod - version = 3.1.10... configure: WARNING: *** Unable to 
find MikMod library (http://mikmod.raphnet.net/)
configure: WARNING: MOD support disabled

config.log shows:

configure:12696: cc -o conftest -O2 -pipe  -D_GNU_SOURCE=1 -DLIBMIKMOD_MUSIC -I/
usr/local/include -pthread -D_REENTRANT -I/usr/local/include  -D_GNU_SOURCE=1 -L
/usr/local/lib  conftest.c  -L/usr/local/lib -lmikmod -lm -lsndio 5
/usr/local/lib/libmikmod.so.3.0: warning: strcpy() is almost always misused, ple
ase use strlcpy()
/usr/local/lib/libmikmod.so.3.0: warning: strcat() is almost always misused, ple
ase use strlcat()
/usr/local/lib/libmikmod.so.3.0: warning: sprintf() is often misused, please use
 snprintf()
/usr/local/lib/libmikmod.so.3.0: undefined reference to `_mm_free'
/usr/local/lib/libmikmod.so.3.0: undefined reference to `_mm_malloc'

And the resulting package does indeed lack MOD support.
And that means no music in ri-li!



Re: audio/mikmod: fix bug causing ri-li crash

2013-01-09 Thread Tobias Ulmer
On Thu, Jan 10, 2013 at 02:00:08AM +0100, Stefan Sperling wrote:
 On Thu, Jan 10, 2013 at 12:37:54AM +, Stuart Henderson wrote:
  On 2012/12/31 01:50, Stefan Sperling wrote:
   Perhaps mikmod should be updated but I'd rather just fix this for now.
  
  updated to 3.2.0 here, some of the patches were rolled in, and I've
  added a comment in patches for the remaining ones where it's not obvious.
 
 Diff is fine with me. Unfortunately this update breaks sdl-mixer :(

You need this. The new version does segfault with mikmod, currently
debugging...

Index: files/drv_sndio.c
===
RCS file: /home/vcs/cvs/openbsd/ports/audio/libmikmod/files/drv_sndio.c,v
retrieving revision 1.1
diff -u -p -r1.1 drv_sndio.c
--- files/drv_sndio.c   11 Jan 2010 04:25:26 -  1.1
+++ files/drv_sndio.c   10 Jan 2013 01:46:05 -
@@ -65,7 +65,7 @@ static BOOL Sndio_Init(void)
return 1;
}
 
-   if (!(audiobuffer = (SBYTE *)_mm_malloc(fragsize)))
+   if (!(audiobuffer = (SBYTE *)MikMod_malloc(fragsize)))
return 1;
 
sio_initpar(par);
@@ -106,7 +106,7 @@ static BOOL Sndio_Init(void)
 static void Sndio_Exit(void)
 {
VC_Exit();
-   _mm_free(audiobuffer);
+   MikMod_free(audiobuffer);
if (hdl) {
sio_close(hdl);
hdl = NULL;



Re: audio/mikmod: fix bug causing ri-li crash

2013-01-09 Thread Tobias Ulmer
Take two:
Fix MDRIVER initialisation, add help text. Sndio_PlayStop must call
sio_stop(), otherwise mikmod playback stops after one tune.

Tested with mikmod using sndio/wav drivers on amd64/sparc64. I did not
check port depends.

With the fix below, ok tobiasu@

Index: files/drv_sndio.c
===
RCS file: /home/vcs/cvs/openbsd/ports/audio/libmikmod/files/drv_sndio.c,v
retrieving revision 1.1
diff -u -p -r1.1 drv_sndio.c
--- files/drv_sndio.c   11 Jan 2010 04:25:26 -  1.1
+++ files/drv_sndio.c   10 Jan 2013 04:51:03 -
@@ -65,7 +65,7 @@ static BOOL Sndio_Init(void)
return 1;
}
 
-   if (!(audiobuffer = (SBYTE *)_mm_malloc(fragsize)))
+   if (!(audiobuffer = (SBYTE *)MikMod_malloc(fragsize)))
return 1;
 
sio_initpar(par);
@@ -106,7 +106,7 @@ static BOOL Sndio_Init(void)
 static void Sndio_Exit(void)
 {
VC_Exit();
-   _mm_free(audiobuffer);
+   MikMod_free(audiobuffer);
if (hdl) {
sio_close(hdl);
hdl = NULL;
@@ -139,9 +139,8 @@ static BOOL Sndio_PlayStart(void)
 
 static void Sndio_PlayStop(void)
 {
-   //sio_stop(hdl);
-
VC_PlayStop();
+   sio_stop(hdl);
 }
 
 MIKMODAPI MDRIVER drv_sndio = {
@@ -150,7 +149,7 @@ MIKMODAPI MDRIVER drv_sndio = {
sndio audio driver v1.0,
0, 255,
audio,
-
+buffer:r:7,17,12:Audio buffer log2 size\n,
Sndio_CommandLine,
Sndio_IsThere,
VC_SampleLoad,