Add media-libs/portmidi-82.
[overlay.git] / media-libs / portmidi / files / portmidi-82.diff
1 diff -Nur portmidi/pm_linux/Makefile portmidi-new/pm_linux/Makefile
2 --- portmidi/pm_linux/Makefile  2008-06-14 02:23:43.000000000 +0200
3 +++ portmidi-new/pm_linux/Makefile      2008-11-24 12:01:48.000000000 +0100
4 @@ -16,7 +16,7 @@
5  # simple to create.)\r
6  \r
7  # For debugging, define PM_CHECK_ERRORS\r
8 -PMFLAGS = -DPM_CHECK_ERRORS\r
9 +PMFLAGS = -DNEWBUFFER\r
10  # Otherwise do not define PM_CHECK_ERRORS\r
11  # PMFLAGS = \r
12  \r
13 @@ -31,10 +31,14 @@
14  # VFLAGS = -DPMNULL\r
15  \r
16  pmlib = pm_linux/libportmidi.a\r
17 +pmslib = pm_linux/libportmidi.so.0.0.0\r
18  \r
19  ptlib = porttime/libporttime.a\r
20 +ptslib = porttime/libporttime.so.0.0.0\r
21  \r
22 -CC = gcc $(VFLAGS) $(PMFLAGS) -g -Ipm_common -Iporttime\r
23 +CC = gcc -fPIC $(CFLAGS) $(VFLAGS) $(PMFLAGS) -g -Ipm_common -Iporttime\r
24 +\r
25 +INSTALL = install\r
26  \r
27  pmobjects = pm_common/pmutil.o $(versions) pm_linux/pmlinux.o  \\r
28         pm_common/portmidi.o\r
29 @@ -46,11 +50,13 @@
30  all: $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread \\r
31         pm_test/latency pm_test/midithru pm_test/qtest pm_test/mm\r
32  \r
33 -$(pmlib): pm_linux/Makefile $(pmobjects)\r
34 +$(pmlib): pm_linux/Makefile $(pmobjects) $(ptlib)\r
35         ar -cr $(pmlib) $(pmobjects)\r
36 +       $(CC) -shared $(ptslib) $(ALSALIB) $(pmobjects) -Wl,-soname -Wl,libportmidi.so.0 -o $(pmslib)\r
37  \r
38  $(ptlib): pm_linux/Makefile $(ptobjects)\r
39         ar -cr $(ptlib) $(ptobjects)\r
40 +       $(CC) -shared $(ptobjects) -lpthread -Wl,-soname -Wl,libporttime.so.0 -o $(ptslib)\r
41  \r
42  pm_linux/pmlinuxalsa.o: pm_linux/Makefile pm_linux/pmlinuxalsa.c pm_linux/pmlinuxalsa.h\r
43         $(CC) -c pm_linux/pmlinuxalsa.c -o pm_linux/pmlinuxalsa.o\r
44 @@ -83,6 +89,14 @@
45  pm_test/qtest: pm_linux/Makefile pm_test/qtest.o $(pmlib) $(ptlib)\r
46         $(CC) pm_test/qtest.o -o pm_test/qtest $(pmlib) $(ptlib) $(ALSALIB)\r
47  \r
48 +install:\r
49 +       $(INSTALL) -d $(DESTDIR)/usr/include\r
50 +       $(INSTALL) -m 644 pm_common/portmidi.h $(DESTDIR)/usr/include/\r
51 +       $(INSTALL) -m 644 porttime/porttime.h $(DESTDIR)/usr/include/\r
52 +       $(INSTALL) -d $(DESTDIR)/usr/lib\r
53 +       $(INSTALL) -m 644 pm_linux/libportmidi* $(DESTDIR)/usr/lib/\r
54 +       $(INSTALL) -m 644 porttime/libporttime* $(DESTDIR)/usr/lib/\r
55 +\r
56  clean:\r
57         rm -f *.o *~ core* */*.o */*.so */*~ */core* pm_test/*/pm_dll.dll \r
58         rm -f *.opt *.ncb *.plg pm_win/Debug/pm_dll.lib pm_win/Release/pm_dll.lib\r
59 @@ -93,6 +107,9 @@
60  cleanest: cleaner\r
61         rm -f $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread\r
62         rm -f pm_test/latency pm_test/midithru pm_test/qtest pm_test/mm\r
63 +       rm -f pm_linux/libportmidi.a pm_linux/libportmidi.so.0.0.0 pm_test/test pm_test/sysex \\r
64 +               pm_test/midithread pm_test/latency pm_test/midithru porttime/libporttime.a \\r
65 +               porttime/libporttime.so.0.0.0\r
66  \r
67  backup: cleanest\r
68         cd ..; zip -r portmidi.zip portmidi\r
69 diff -Nur portmidi/pm_linux/pmlinux.c portmidi-new/pm_linux/pmlinux.c
70 --- portmidi/pm_linux/pmlinux.c 2006-11-30 00:37:09.000000000 +0100
71 +++ portmidi-new/pm_linux/pmlinux.c     2008-11-24 11:59:21.000000000 +0100
72 @@ -28,10 +28,10 @@
73       * devices.\r
74       */\r
75      #ifdef PMALSA\r
76 -       pm_linuxalsa_init();\r
77 +       return pm_linuxalsa_init();\r
78      #endif\r
79      #ifdef PMNULL\r
80 -        pm_linuxnull_init();\r
81 +        return pm_linuxnull_init();\r
82      #endif\r
83      return pmNoError;\r
84  }\r
85 diff -Nur portmidi/pm_linux/pmlinuxalsa.c portmidi-new/pm_linux/pmlinuxalsa.c
86 --- portmidi/pm_linux/pmlinuxalsa.c     2008-06-14 02:23:43.000000000 +0200
87 +++ portmidi-new/pm_linux/pmlinuxalsa.c 2008-11-24 11:58:30.000000000 +0100
88 @@ -209,7 +209,7 @@
89              if (when == 0) when = now;\r
90              when = (when - now) + midi->latency;\r
91              if (when < 0) when = 0;\r
92 -            VERBOSE printf("timestamp %d now %d latency %d, ", \r
93 +            VERBOSE printf("timestamp %d now %d latency %li, ", \r
94                             (int) timestamp, (int) now, midi->latency);\r
95              VERBOSE printf("scheduling event after %d\n", when);\r
96              /* message is sent in relative ticks, where 1 tick = 1 ms */\r
97 @@ -243,8 +243,8 @@
98      alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;\r
99      if (!desc) return pmBadPtr;\r
100  \r
101 -    if (pm_hosterror = snd_seq_disconnect_to(seq, desc->this_port, \r
102 -                                             desc->client, desc->port)) {\r
103 +    if ((pm_hosterror = snd_seq_disconnect_to(seq, desc->this_port, \r
104 +                                             desc->client, desc->port))) {\r
105          // if there's an error, try to delete the port anyway, but don't\r
106          // change the pm_hosterror value so we retain the first error\r
107          snd_seq_delete_port(seq, desc->this_port);\r
108 @@ -333,8 +333,8 @@
109  {\r
110      alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;\r
111      if (!desc) return pmBadPtr;\r
112 -    if (pm_hosterror = snd_seq_disconnect_from(seq, desc->this_port, \r
113 -                                               desc->client, desc->port)) {\r
114 +    if ((pm_hosterror = snd_seq_disconnect_from(seq, desc->this_port, \r
115 +                                               desc->client, desc->port))) {\r
116          snd_seq_delete_port(seq, desc->this_port); /* try to close port */\r
117      } else {\r
118          pm_hosterror = snd_seq_delete_port(seq, desc->this_port);\r
119 diff -Nur portmidi/pm_test/Makefile portmidi-new/pm_test/Makefile
120 --- portmidi/pm_test/Makefile   1970-01-01 01:00:00.000000000 +0100
121 +++ portmidi-new/pm_test/Makefile       2008-11-24 12:00:31.000000000 +0100
122 @@ -0,0 +1,32 @@
123 +# For debugging, define PM_CHECK_ERRORS
124 +PMFLAGS = -DPM_CHECK_ERRORS
125 +# Use this for linux alsa (0.9x) version
126 +ALSALIB = -lasound
127 +pmlib = -lportmidi
128 +ptlib = -lporttime
129 +VFLAGS = -DPMALSA
130 +
131 +CC = gcc $(CFLAGS) $(VFLAGS) $(PMFLAGS) -g
132 +
133 +all: test sysex midithread latency midithru
134 +
135 +test: test.o
136 +       $(CC) test.c -o test $(pmlib) $(ptlib) $(ALSALIB)
137 +
138 +sysex: sysex.o
139 +       $(CC) sysex.c -o sysex $(pmlib) $(ptlib) $(ALSALIB)
140 +
141 +midithread: midithread.o
142 +       $(CC) midithread.c -o midithread \
143 +               $(pmlib) $(ptlib) $(ALSALIB)
144 +
145 +latency: latency.o
146 +       $(CC) latency.c -o latency $(pmlib) $(ptlib) \
147 +               $(ALSALIB) -lpthread -lm
148 +
149 +midithru: midithru.o
150 +       $(CC) midithru.c -o midithru $(pmlib) $(ptlib) \
151 +               $(ALSALIB) -lpthread -lm
152 +
153 +clean:
154 +       rm -f midithru latency midithread sysex test