diff -uprN old-portmidi/pm_linux/Makefile new-portmidi/pm_linux/Makefile --- old-portmidi/pm_linux/Makefile 2006-10-20 16:13:52.000000000 -0400 +++ new-portmidi/pm_linux/Makefile 2006-11-04 04:07:40.000000000 -0500 @@ -18,7 +18,7 @@ # For debugging, define PM_CHECK_ERRORS # Define NEWBUFFER to use new FIFO code that is multiprocessor safe # (Besides, it looks like old code (non-NEWBUFFER) is broken now. -RBD) -PMFLAGS = -DPM_CHECK_ERRORS -DNEWBUFFER +PMFLAGS = -DNEWBUFFER # Otherwise do not define PM_CHECK_ERRORS # PMFLAGS = -DNEWBUFFER @@ -33,13 +33,17 @@ VFLAGS = -DPMALSA # 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/pmlinuxalsa.o + pm_common/portmidi.o ptobjects = porttime/porttime.o porttime/ptlinux.o @@ -48,11 +52,14 @@ current: all all: $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread \ pm_test/latency pm_test/midithru pm_test/qtest -$(pmlib): pm_linux/Makefile $(pmobjects) +$(pmlib): pm_linux/Makefile $(pmobjects) $(ptlib) ar -cr $(pmlib) $(pmobjects) + $(CC) -shared $(ptslib) $(ALSALIB) $(pmobjects) -Wl,-soname -Wl,libportmidi.so.0 -o $(pmslib) $(ptlib): pm_linux/Makefile $(ptobjects) ar -cr $(ptlib) $(ptobjects) + $(CC) -shared -lpthread $(ptobjects) -Wl,-soname -Wl,libporttime.so.0 -o $(ptslib) + 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 @@ -81,8 +88,16 @@ porttime/ptlinux.o: pm_linux/Makefile po pm_test/qtest: pm_linux/Makefile pm_test/qtest.o $(pmlib) $(ptlib) $(CC) pm_test/qtest.o -o pm_test/qtest $(pmlib) $(ptlib) $(ALSALIB) +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 */*~ */core* pm_test/*/pm_dll.dll + 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 rm -f pm_test/*.opt pm_test/*.ncb @@ -91,6 +106,10 @@ cleaner: clean 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 + rm -f pm_linux/libportmidi.a pm_linux/libportmidi.so.0.0.0 pm_test/test pm_test/sysex \ + pm_test/midithread pm_test/latency pm_test/midithru porttime/libporttime.a \ + porttime/libporttime.so.0.0.0 + backup: cleanest cd ..; zip -r portmidi.zip portmidi diff -uprN old-portmidi/pm_linux/pmlinuxalsa.c new-portmidi/pm_linux/pmlinuxalsa.c --- old-portmidi/pm_linux/pmlinuxalsa.c 2006-10-23 11:27:20.000000000 -0400 +++ new-portmidi/pm_linux/pmlinuxalsa.c 2006-11-04 04:05:55.000000000 -0500 @@ -211,8 +211,8 @@ static PmError alsa_write_byte(PmInterna if (when == 0) when = now; when = (when - now) + midi->latency; if (when < 0) when = 0; - VERBOSE printf("timestamp %d now %d latency %d, ", - timestamp, now, midi->latency); + VERBOSE printf("timestamp %d now %d latency %li,", + (int)timestamp, (int)now, midi->latency); VERBOSE printf("scheduling event after %d\n", when); /* message is sent in relative ticks, where 1 tick = 1 ms */ snd_seq_ev_schedule_tick(&ev, queue, 1, when); @@ -242,12 +242,11 @@ static PmError alsa_write_byte(PmInterna static PmError alsa_out_close(PmInternal *midi) { - int err; 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); @@ -334,11 +333,10 @@ static PmError alsa_in_open(PmInternal * static PmError alsa_in_close(PmInternal *midi) { - int err; 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); @@ -356,7 +354,7 @@ static PmError alsa_in_close(PmInternal static PmError alsa_abort(PmInternal *midi) { - alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor; + //alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor; /* This is supposed to flush any pending output. */ printf("WARNING: alsa_abort not implemented\n"); return pmNoError; @@ -416,7 +414,7 @@ static PmError alsa_write(PmInternal *mi static PmError alsa_write_flush(PmInternal *midi) { alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor; - VERBOSE printf("snd_seq_drain_output: 0x%x\n", seq); + 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; @@ -589,8 +587,6 @@ static void handle_event(snd_seq_event_t case SND_SEQ_EVENT_SYSEX: { const BYTE *ptr = (const BYTE *) ev->data.ext.ptr; int i; - long msg = 0; - int shift = 0; if (!(midi->filters & PM_FILT_SYSEX)) { for (i = 0; i < ev->data.ext.len; i++) { pm_read_byte(midi, *ptr++, timestamp); @@ -715,7 +711,7 @@ PmError pm_linuxalsa_init( void ) * call seq_event_input_pending() to avoid blocking. */ err = snd_seq_open(&seq, "default", SND_SEQ_OPEN_DUPLEX, 0); - if (err < 0) return; + if (err < 0) return err; snd_seq_client_info_alloca(&cinfo); snd_seq_port_info_alloca(&pinfo); @@ -752,6 +748,7 @@ PmError pm_linuxalsa_init( void ) } } } + return 0; } @@ -759,5 +756,9 @@ void pm_linuxalsa_term(void) { if (seq) { snd_seq_close(seq); + free(descriptors); + descriptors=NULL; + pm_descriptor_index=0; + pm_descriptor_max=0; } } diff -uprN old-portmidi/pm_linux/pmlinux.c new-portmidi/pm_linux/pmlinux.c --- old-portmidi/pm_linux/pmlinux.c 2006-10-21 15:48:46.000000000 -0400 +++ new-portmidi/pm_linux/pmlinux.c 2006-11-04 04:05:55.000000000 -0500 @@ -23,10 +23,10 @@ PmError pm_init() { #ifdef PMALSA - pm_linuxalsa_init(); + return pm_linuxalsa_init(); #endif #ifdef PMNULL - pm_linuxnull_init(); + return pm_linuxnull_init(); #endif } diff -uprN old-portmidi/pm_test/Makefile new-portmidi/pm_test/Makefile --- old-portmidi/pm_test/Makefile 1969-12-31 19:00:00.000000000 -0500 +++ new-portmidi/pm_test/Makefile 2006-11-04 04:05:55.000000000 -0500 @@ -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 diff -uprN old-portmidi/porttime/ptlinux.c new-portmidi/porttime/ptlinux.c --- old-portmidi/porttime/ptlinux.c 2006-10-02 22:34:54.000000000 -0400 +++ new-portmidi/porttime/ptlinux.c 2006-11-04 04:05:55.000000000 -0500 @@ -22,6 +22,10 @@ CHANGE LOG */ +#include +#include +#include +#include #include "porttime.h" #include "sys/time.h" #include "sys/resource.h"