--- portmidi-200.orig/debian/libportmidi0.links
+++ portmidi-200/debian/libportmidi0.links
@@ -0,0 +1,2 @@
+usr/lib/libportmidi.so.0.0.0 usr/lib/libportmidi.so.0
+usr/lib/libporttime.so.0.0.0 usr/lib/libporttime.so.0
--- portmidi-200.orig/debian/control
+++ portmidi-200/debian/control
@@ -0,0 +1,24 @@
+Source: portmidi
+Priority: optional
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Paul Brossier <piem@debian.org>
+Build-Depends: debhelper (>= 5.0.0), libasound2-dev, quilt
+Standards-Version: 3.8.3
+Homepage: http://portmedia.sourceforge.net/
+Section: libs
+
+Package: libportmidi-dev
+Section: libdevel
+Architecture: any
+Depends: libportmidi0 (= ${binary:Version})
+Description: library for real-time MIDI input/output
+ PortMidi is a platform independent library for MIDI input/output.
+ This package provides the header files for PortMidi and PortTime.
+
+Package: libportmidi0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: library for real-time MIDI input/output
+ PortMidi is a platform independent library for MIDI input/output.
+ This package provide the PortMidi and PortTime libraries.
--- portmidi-200.orig/debian/README.source
+++ portmidi-200/debian/README.source
@@ -0,0 +1,5 @@
+This package uses quilt to manage all modifications to the upstream
+source.  Changes are stored in the source package as diffs in
+debian/patches and applied during the build.
+
+See /usr/share/doc/quilt/README.source for more information about quilt.
--- portmidi-200.orig/debian/libportmidi-dev.install
+++ portmidi-200/debian/libportmidi-dev.install
@@ -0,0 +1,3 @@
+usr/include/*
+usr/lib/lib*.a
+usr/lib/lib*.so
--- portmidi-200.orig/debian/copyright
+++ portmidi-200/debian/copyright
@@ -0,0 +1,49 @@
+This package was debianized by Paul Brossier <piem@debian.org> on
+Fri,  5 Aug 2005 18:37:26 +0100.
+
+It was downloaded from http://portmedia.sourceforge.net/
+
+Copyright Holders:
+
+ Copyright (c) 1999-2000 Ross Bencina and Phil Burk
+ Copyright (c) 2001-2009 Roger B. Dannenberg
+
+The following files contain additional copyright notices:
+
+pm_cl/cffi-portmidi.lisp:
+ Copyright (C) 2005 Heinrich Taube, <taube (at) uiuc (dot) edu>
+
+pm_mac/readbinaryplist.c
+ Copyright (C) 2007 Jens Ayton
+
+License:
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+                                                                        
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+                                                                        
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ 
+Additional note from the file license.txt:
+
+ The text above constitutes the entire PortMidi license; however, 
+ the PortMusic community also makes the following non-binding requests:
+                                                                        
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version. It is also
+ requested that these non-binding requests be included along with the 
+ license above.
--- portmidi-200.orig/debian/libportmidi-dev.links
+++ portmidi-200/debian/libportmidi-dev.links
@@ -0,0 +1,2 @@
+usr/lib/libportmidi.so.0.0.0 usr/lib/libportmidi.so
+usr/lib/libporttime.so.0.0.0 usr/lib/libporttime.so
--- portmidi-200.orig/debian/changelog
+++ portmidi-200/debian/changelog
@@ -0,0 +1,66 @@
+portmidi (1:200-0ubuntu1.12.04.1) precise-proposed; urgency=low
+
+  * debian/patches/11-pmlinuxalsa.patch:
+    - Avoid SIGSEGV when it receives data for devices which
+      might have already been closed. (LP: #1073484)
+    - Fix some other pointer issues:
+      + alsa_in_close() didn't clear midi-descriptor.
+      + Some other uses of midi->descriptor didn't do NULL-check of
+        the pointer.
+
+ -- Alessio Treglia <quadrispro@ubuntu.com>  Sun, 23 Dec 2012 22:14:44 +0000
+
+portmidi (1:200-0ubuntu1) lucid; urgency=low
+
+  * New upstream release
+  * debian/patches/: Refresh/rediff
+
+ -- Daniel T Chen <crimsun@ubuntu.com>  Sun, 14 Feb 2010 17:30:52 -0500
+
+portmidi (1:184-2) unstable; urgency=low
+
+  * Add -lpthread to ALSALIB (closes: #556070) 
+
+ -- Paul Brossier <piem@debian.org>  Fri, 13 Nov 2009 15:26:46 +0100
+
+portmidi (1:184-1) unstable; urgency=low
+
+  * New upstream release. 
+  * Update patches where merged with upstream, disable pmdefautls for now
+
+ -- Paul Brossier <piem@debian.org>  Fri, 30 Oct 2009 13:41:33 +0100
+
+portmidi (1:131-1) unstable; urgency=low
+
+  * New upstream version, uses epoch (closes: #501132)
+  * debian/watch: update to match new download location and version
+    numbering (closes: #450055), but still fails due to zip format
+  * Add depends on quilt, move patches to debian/patches
+  * Add Homepage to debian/control
+  * debian/control: use ${binary:Version}, bump to S-V 3.8.3
+  * debian/compat: bump to 5
+  * debian/copyright: update to match license.txt and add missing copyrights
+  * debian/patches/02_pmlinuxalsa.diff: remove merged hunks
+  * debian/patches/04_ptlinux.diff: remove merged hunks
+  * debian/patches/05_makefile.diff: merge and link portmidi to porttime,
+    thanks to Willem van Engen (closes: #515712)
+  * debian/rules: use pm_linux/Makefile, ship CHANGELOG.txt and make sure
+    source and header files are not executable
+  * debian/README.source: refer to quilt documentation
+  * debian/libportmidi-dev.install: do not try to install unexisting files
+  * debian/patches/{06_pm_test_mm,07_pm_test_sysex,08_pm_test_qtest}.diff:
+    get rid of missing include and parenthesis, fix long int formatting
+  * debian/rules: do not compress header files
+
+ -- Paul Brossier <piem@debian.org>  Wed, 16 Sep 2009 06:50:57 +0200
+
+portmidi (20041117-1) unstable; urgency=low
+
+  * Initial release (closes: #280656)
+  * Add shared libraries and installation target to Makefile, add
+    pm_test/Makefile for examples/.
+  * Patch pm_linuxalsa_term as suggested by Predrag Viceic, freecycle author.
+  * Minor fixes to prevent compilation warnings.
+
+ -- Paul Brossier <piem@debian.org>  Tue, 27 Sep 2005 02:04:20 +0100
+
--- portmidi-200.orig/debian/rules
+++ portmidi-200/debian/rules
@@ -0,0 +1,72 @@
+#!/usr/bin/make -f
+
+include /usr/share/quilt/quilt.make
+
+CFLAGS = -Wall -g -fPIC
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -O0
+else
+	CFLAGS += -O2
+endif
+
+version=`ls pm_linux/lib*.so.* | \
+ awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
+major=`ls pm_linux/lib*.so.* | \
+ awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
+
+configure: configure-stamp
+configure-stamp:
+	dh_testdir
+	# nothing to do by default
+	touch configure-stamp
+
+build: build-stamp
+build-stamp: patch configure-stamp 
+	dh_testdir
+	CFLAGS='$(CFLAGS)' $(MAKE) -f pm_linux/Makefile
+	touch build-stamp
+
+clean: clean1st unpatch
+clean1st:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp configure-stamp
+	[ ! -f pm_linux/Makefile ] || $(MAKE) -f pm_linux/Makefile cleanest
+	dh_clean 
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k 
+	dh_installdirs
+	# do not ship executables c files
+	chmod a-x $(CURDIR)/pm_test/*.c $(CURDIR)/pm_common/*.h
+	$(MAKE) -f pm_linux/Makefile install DESTDIR=$(CURDIR)/debian/tmp
+	dh_install --sourcedir=$(CURDIR)/debian/tmp
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs CHANGELOG.txt
+	dh_installdocs
+	dh_installexamples
+	dh_installman
+	dh_link
+	dh_strip
+	dh_compress -X.c -X.h
+	dh_fixperms
+	dh_makeshlibs
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- portmidi-200.orig/debian/libportmidi-dev.docs
+++ portmidi-200/debian/libportmidi-dev.docs
@@ -0,0 +1,2 @@
+README.txt
+pm_linux/README_LINUX.txt
--- portmidi-200.orig/debian/libportmidi-dev.dirs
+++ portmidi-200/debian/libportmidi-dev.dirs
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
--- portmidi-200.orig/debian/libportmidi0.install
+++ portmidi-200/debian/libportmidi0.install
@@ -0,0 +1 @@
+usr/lib/lib*.so.*
--- portmidi-200.orig/debian/libportmidi-dev.examples
+++ portmidi-200/debian/libportmidi-dev.examples
@@ -0,0 +1,4 @@
+pm_test/*.c
+pm_test/Makefile
+pm_common/pminternal.h
+pm_common/pmutil.h
--- portmidi-200.orig/debian/libportmidi0.dirs
+++ portmidi-200/debian/libportmidi0.dirs
@@ -0,0 +1 @@
+usr/lib
--- portmidi-200.orig/debian/watch
+++ portmidi-200/debian/watch
@@ -0,0 +1,2 @@
+version=3
+http://sf.net/portmedia/ portmidi-src-(.*)\.zip
--- portmidi-200.orig/debian/compat
+++ portmidi-200/debian/compat
@@ -0,0 +1 @@
+5
--- portmidi-200.orig/debian/patches/series
+++ portmidi-200/debian/patches/series
@@ -0,0 +1,6 @@
+01_pmlinux.diff
+02_pmlinuxalsa.diff
+03_pm_test_Makefile.diff
+05_makefile.diff
+09_makefile_linking.diff
+11-pmlinuxalsa.patch
--- portmidi-200.orig/debian/patches/03_pm_test_Makefile.diff
+++ portmidi-200/debian/patches/03_pm_test_Makefile.diff
@@ -0,0 +1,35 @@
+--- portmidi-20041117.orig/pm_test/Makefile
++++ portmidi-20041117/pm_test/Makefile
+@@ -0,0 +1,32 @@
++# For debugging, define PM_CHECK_ERRORS
++PMFLAGS = -DPM_CHECK_ERRORS
++# Use this for linux alsa (0.9x) version
++ALSALIB = -lasound
++pmlib = -lportmidi
++ptlib = -lporttime
++VFLAGS = -DPMALSA
++
++CC = gcc $(CFLAGS) $(VFLAGS) $(PMFLAGS) -g
++
++all: test sysex midithread latency midithru
++
++test: test.o
++	$(CC) test.c -o test $(pmlib) $(ptlib) $(ALSALIB)
++
++sysex: sysex.o
++	$(CC) sysex.c -o sysex $(pmlib) $(ptlib) $(ALSALIB)
++
++midithread: midithread.o
++	$(CC) midithread.c -o midithread \
++		$(pmlib) $(ptlib) $(ALSALIB)
++
++latency: latency.o
++	$(CC) latency.c -o latency $(pmlib) $(ptlib) \
++		$(ALSALIB) -lpthread -lm
++
++midithru: midithru.o
++	$(CC) midithru.c -o midithru $(pmlib) $(ptlib) \
++		$(ALSALIB) -lpthread -lm
++
++clean:
++	rm -f midithru latency midithread sysex test
--- portmidi-200.orig/debian/patches/05_makefile.diff
+++ portmidi-200/debian/patches/05_makefile.diff
@@ -0,0 +1,73 @@
+--- a/pm_linux/Makefile	2009-10-30 13:16:31.000000000 +0100
++++ b/pm_linux/Makefile	2009-10-30 13:17:08.000000000 +0100
+@@ -31,10 +31,14 @@
+ # VFLAGS = -DPMNULL
+ 
+ pmlib = pm_linux/libportmidi.a
++pmslib = pm_linux/libportmidi.so.0.0.0
+ 
+ ptlib = porttime/libporttime.a
++ptslib = porttime/libporttime.so.0.0.0
+ 
+-CC = gcc $(VFLAGS) $(PMFLAGS) -g -Ipm_common -Iporttime
++CC = gcc $(CFLAGS) $(VFLAGS) $(PMFLAGS) -g -Ipm_common -Iporttime
++
++INSTALL = install
+ 
+ pmobjects = pm_common/pmutil.o $(versions) pm_linux/pmlinux.o  \
+ 	pm_common/portmidi.o pm_linux/finddefault.o
+@@ -43,16 +47,29 @@
+ 
+ current: all
+ 
+-all: $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread \
+-	pm_test/latency pm_test/midithru pm_test/qtest pm_test/mm \
++all: $(pmlib) $(pmslib) $(ptlib) $(ptslib) \
++	pm_test/test pm_test/sysex pm_test/midithread \
++	pm_test/latency pm_test/midithru pm_test/qtest pm_test/mm
++
++pmdefaults:	\
+ 	pm_java/pmjni/libpmjni.so pm_java/pmdefaults/pmdefaults.jar 
+ 
+ $(pmlib): pm_linux/Makefile $(pmobjects)
+ 	ar -cr $(pmlib) $(pmobjects)
+ 
++$(pmslib): pm_linux/Makefile $(pmsobjects) $(ptslib)
++	$(CC) -shared $(ALSALIB) $(pmobjects) -Wl,-soname -Wl,libportmidi.so.0 -Lporttime -lporttime -o $(pmslib)
++	ln -sf $(notdir $(pmslib)) pm_linux/libportmidi.so.0
++	ln -sf $(notdir $(pmslib)) pm_linux/libportmidi.so
++
+ $(ptlib): pm_linux/Makefile $(ptobjects)
+ 	ar -cr $(ptlib) $(ptobjects)
+ 
++$(ptslib): pm_linux/Makefile $(ptobjects)
++	$(CC) -shared $(ptobjects) -Wl,-soname -Wl,libporttime.so.0 -lpthread -o $(ptslib)
++	ln -sf $(notdir $(ptslib)) porttime/libporttime.so.0
++	ln -sf $(notdir $(ptslib)) porttime/libporttime.so
++
+ pm_linux/pmlinuxalsa.o: pm_linux/Makefile pm_linux/pmlinuxalsa.c pm_linux/pmlinuxalsa.h
+ 	$(CC) -c pm_linux/pmlinuxalsa.c -o pm_linux/pmlinuxalsa.o
+ 
+@@ -152,6 +169,14 @@
+ 	# do not chmod +x here since we are probably root
+ 	cp pm_java/pmdefaults/pmdefaults /usr/local/bin
+ 
++install: 
++	$(INSTALL) -d $(DESTDIR)/usr/include/
++	$(INSTALL) -m 644 pm_common/portmidi.h $(DESTDIR)/usr/include/
++	$(INSTALL) -m 644 porttime/porttime.h $(DESTDIR)/usr/include/
++	$(INSTALL) -d $(DESTDIR)/usr/lib/
++	$(INSTALL) -m 644 pm_linux/libportmidi* $(DESTDIR)/usr/lib/
++	$(INSTALL) -m 644 porttime/libporttime* $(DESTDIR)/usr/lib/
++
+ clean:
+ 	rm -f *.o *~ core* */*.o */*.so */*~ */core* pm_test/*/pm_dll.dll 
+ 	rm -f *.opt *.ncb *.plg pm_win/Debug/pm_dll.lib pm_win/Release/pm_dll.lib
+@@ -162,6 +187,7 @@
+ cleanest: cleaner
+ 	rm -f $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread
+ 	rm -f pm_test/latency pm_test/midithru pm_test/qtest pm_test/mm
++	rm -f $(ptslib) $(pmslib)
+ 
+ backup: cleanest
+ 	cd ..; zip -r portmidi.zip portmidi
--- portmidi-200.orig/debian/patches/01_pmlinux.diff
+++ portmidi-200/debian/patches/01_pmlinux.diff
@@ -0,0 +1,17 @@
+Index: portmidi-200/pm_linux/pmlinux.c
+===================================================================
+--- portmidi-200.orig/pm_linux/pmlinux.c	2010-02-14 17:35:40.000000000 -0500
++++ portmidi-200/pm_linux/pmlinux.c	2010-02-14 17:36:17.000000000 -0500
+@@ -34,10 +34,10 @@
+      * devices.
+      */
+     #ifdef PMALSA
+-	pm_linuxalsa_init();
++	return pm_linuxalsa_init();
+     #endif
+     #ifdef PMNULL
+-        pm_linuxnull_init();
++        return pm_linuxnull_init();
+     #endif
+     // this is set when we return to Pm_Initialize, but we need it
+     // now in order to (successfully) call Pm_CountDevices()
--- portmidi-200.orig/debian/patches/09_makefile_linking.diff
+++ portmidi-200/debian/patches/09_makefile_linking.diff
@@ -0,0 +1,11 @@
+--- a/pm_linux/Makefile	2009-01-20 05:01:54.000000000 +0100
++++ b/pm_linux/Makefile	2009-11-13 15:19:56.000000000 +0100
+@@ -22,7 +22,7 @@
+ 
+ # Use this for linux alsa (0.9x) version
+ versions = pm_linux/pmlinuxalsa.o
+-ALSALIB = -lasound
++ALSALIB = -lasound -lpthread
+ VFLAGS = -DPMALSA
+ 
+ # Use this for null (a dummy implementation for no Midi I/O:
--- portmidi-200.orig/debian/patches/11-pmlinuxalsa.patch
+++ portmidi-200/debian/patches/11-pmlinuxalsa.patch
@@ -0,0 +1,70 @@
+Subject: Prevent SIGSEGV on handling events for already closed devices.
+Bug: http://sourceforge.net/apps/trac/portmedia/ticket/3
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=695842
+Bug-Ubuntu: https://launchpad.net/bugs/1073484
+Applied-Upstream: yes
+---
+ pm_linux/pmlinuxalsa.c |   10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- portmidi-200.orig/pm_linux/pmlinuxalsa.c
++++ portmidi-200/pm_linux/pmlinuxalsa.c
+@@ -193,6 +193,7 @@ static PmError alsa_write_byte(PmInterna
+     snd_seq_event_t ev;
+     int err;
+ 
++    if (!desc) return pmBadPtr;
+     snd_seq_ev_clear(&ev);
+     if (snd_midi_event_encode_byte(desc->parser, byte, &ev) == 1) {
+         snd_seq_ev_set_dest(&ev, desc->client, desc->port);
+@@ -339,6 +340,7 @@ static PmError alsa_in_close(PmInternal
+         pm_hosterror = snd_seq_delete_port(seq, desc->this_port);
+     }
+     alsa_unuse_queue();
++    midi->descriptor = NULL;
+     pm_free(desc);
+     if (pm_hosterror) {
+         get_alsa_error_text(pm_hosterror_text, PM_HOST_ERROR_MSG_LEN, 
+@@ -433,6 +435,7 @@ static PmError alsa_write(PmInternal *mi
+ static PmError alsa_write_flush(PmInternal *midi, PmTimestamp timestamp)
+ {
+     alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;
++    if (!desc) return pmBadPtr;
+     VERBOSE printf("snd_seq_drain_output: 0x%x\n", (unsigned int) seq);
+     desc->error = snd_seq_drain_output(seq);
+     if (desc->error < 0) return pmHostError;
+@@ -448,6 +451,7 @@ static PmError alsa_write_short(PmIntern
+     PmMessage msg = event->message;
+     int i;
+     alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;
++    if (!desc) return pmBadPtr;
+     for (i = 0; i < bytes; i++) {
+         unsigned char byte = msg;
+         VERBOSE printf("sending 0x%x\n", byte);
+@@ -481,6 +485,10 @@ static void handle_event(snd_seq_event_t
+ {
+     int device_id = ev->dest.port;
+     PmInternal *midi = descriptors[device_id].internalDescriptor;
++    /* The device we received events for might have been closed before we
++       processed them. */
++    if (!midi)
++        return;
+     PmEvent pm_ev;
+     PmTimeProcPtr time_proc = midi->time_proc;
+     PmTimestamp timestamp;
+@@ -650,6 +658,7 @@ static PmError alsa_poll(PmInternal *mid
+ static unsigned int alsa_has_host_error(PmInternal *midi)
+ {
+     alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;
++    if (!desc) return 0;
+     return desc->error;
+ }
+ 
+@@ -657,6 +666,7 @@ static unsigned int alsa_has_host_error(
+ static void alsa_get_host_error(PmInternal *midi, char *msg, unsigned int len)
+ {
+     alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;
++    if (!desc) return;
+     int err = (pm_hosterror || desc->error);
+     get_alsa_error_text(msg, len, err);
+ }
--- portmidi-200.orig/debian/patches/02_pmlinuxalsa.diff
+++ portmidi-200/debian/patches/02_pmlinuxalsa.diff
@@ -0,0 +1,35 @@
+Index: portmidi-200/pm_linux/pmlinuxalsa.c
+===================================================================
+--- portmidi-200.orig/pm_linux/pmlinuxalsa.c	2009-11-20 00:41:09.000000000 -0500
++++ portmidi-200/pm_linux/pmlinuxalsa.c	2010-02-14 17:39:06.000000000 -0500
+@@ -242,8 +242,8 @@
+     alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;
+     if (!desc) return pmBadPtr;
+ 
+-    if (pm_hosterror = snd_seq_disconnect_to(seq, desc->this_port, 
+-                                             desc->client, desc->port)) {
++    if ((pm_hosterror = snd_seq_disconnect_to(seq, desc->this_port, 
++                                             desc->client, desc->port))) {
+         // if there's an error, try to delete the port anyway, but don't
+         // change the pm_hosterror value so we retain the first error
+         snd_seq_delete_port(seq, desc->this_port);
+@@ -332,8 +332,8 @@
+ {
+     alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;
+     if (!desc) return pmBadPtr;
+-    if (pm_hosterror = snd_seq_disconnect_from(seq, desc->this_port, 
+-                                               desc->client, desc->port)) {
++    if ((pm_hosterror = snd_seq_disconnect_from(seq, desc->this_port, 
++                                               desc->client, desc->port))) {
+         snd_seq_delete_port(seq, desc->this_port); /* try to close port */
+     } else {
+         pm_hosterror = snd_seq_delete_port(seq, desc->this_port);
+@@ -606,7 +606,7 @@
+     case SND_SEQ_EVENT_SYSEX: {
+         const BYTE *ptr = (const BYTE *) ev->data.ext.ptr;
+         /* assume there is one sysex byte to process */
+-        pm_read_bytes(midi, ptr, ev->data.ext.len, timestamp);
++        pm_read_bytes(midi, (unsigned char*)ptr, ev->data.ext.len, timestamp);
+         break;
+     }
+     }
