author | rwestberg |
Fri, 01 Jun 2018 10:15:48 +0200 | |
changeset 50336 | 1b6ea6bcd21a |
parent 47216 | 71c04702a3d5 |
child 52161 | f1b6c4079be0 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
13678
diff
changeset
|
2 |
* Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
#define USE_ERROR |
|
27 |
#define USE_TRACE |
|
28 |
||
29 |
#include "PLATFORM_API_WinOS_Util.h" |
|
30 |
||
47191
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
31 |
/* include to prevent charset problem */ |
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
32 |
#include "PLATFORM_API_WinOS_Charset_Util.h" |
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
33 |
|
2 | 34 |
#if USE_PLATFORM_MIDI_OUT == TRUE |
35 |
||
36 |
||
37 |
#ifdef USE_ERROR |
|
38 |
#include <stdio.h> |
|
13678
5c8001201f98
7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents:
5506
diff
changeset
|
39 |
|
5c8001201f98
7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents:
5506
diff
changeset
|
40 |
/* Use THIS_FILE when it is available. */ |
5c8001201f98
7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents:
5506
diff
changeset
|
41 |
#ifndef THIS_FILE |
5c8001201f98
7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents:
5506
diff
changeset
|
42 |
#define THIS_FILE __FILE__ |
5c8001201f98
7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents:
5506
diff
changeset
|
43 |
#endif |
5c8001201f98
7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents:
5506
diff
changeset
|
44 |
|
2 | 45 |
#define MIDIOUT_CHECK_ERROR { \ |
46 |
if (err != MMSYSERR_NOERROR) \ |
|
13678
5c8001201f98
7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__
ohair
parents:
5506
diff
changeset
|
47 |
ERROR3("MIDI OUT Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \ |
2 | 48 |
} |
49 |
#else |
|
50 |
#define MIDIOUT_CHECK_ERROR |
|
51 |
#endif |
|
52 |
||
53 |
/* *************************** MidiOutDeviceProvider implementation *********************************** */ |
|
54 |
||
55 |
/* not thread safe */ |
|
56 |
static char winMidiOutErrMsg[WIN_MAX_ERROR_LEN]; |
|
57 |
||
58 |
char* MIDI_OUT_GetErrorStr(INT32 err) { |
|
59 |
winMidiOutErrMsg[0] = 0; |
|
60 |
midiOutGetErrorText((MMRESULT) err, winMidiOutErrMsg, WIN_MAX_ERROR_LEN); |
|
61 |
return winMidiOutErrMsg; |
|
62 |
} |
|
63 |
||
64 |
INT32 MIDI_OUT_GetNumDevices() { |
|
65 |
// add one for the MIDI_MAPPER |
|
66 |
// we want to return it first so it'll be the default, so we |
|
67 |
// decrement each deviceID for these methods.... |
|
68 |
return (INT32) (midiOutGetNumDevs() + 1); |
|
69 |
} |
|
70 |
||
71 |
||
47191
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
72 |
INT32 getMidiOutCaps(INT32 deviceID, MIDIOUTCAPSW* caps, INT32* err) { |
2 | 73 |
if (deviceID == 0) { |
74 |
deviceID = MIDI_MAPPER; |
|
75 |
} else { |
|
76 |
deviceID--; |
|
77 |
} |
|
47191
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
78 |
(*err) = (INT32) midiOutGetDevCapsW(deviceID, caps, sizeof(MIDIOUTCAPS)); |
2 | 79 |
return ((*err) == MMSYSERR_NOERROR); |
80 |
} |
|
81 |
||
82 |
||
83 |
INT32 MIDI_OUT_GetDeviceName(INT32 deviceID, char *name, UINT32 nameLength) { |
|
47191
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
84 |
MIDIOUTCAPSW midiOutCaps; |
2 | 85 |
INT32 err; |
86 |
||
87 |
if (getMidiOutCaps(deviceID, &midiOutCaps, &err)) { |
|
47191
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
88 |
UnicodeToUTF8AndCopy(name, midiOutCaps.szPname, nameLength); |
2 | 89 |
return MIDI_SUCCESS; |
90 |
} |
|
91 |
MIDIOUT_CHECK_ERROR; |
|
92 |
return err; |
|
93 |
} |
|
94 |
||
95 |
||
96 |
INT32 MIDI_OUT_GetDeviceVendor(INT32 deviceID, char *name, UINT32 nameLength) { |
|
97 |
return MIDI_NOT_SUPPORTED; |
|
98 |
} |
|
99 |
||
100 |
||
101 |
INT32 MIDI_OUT_GetDeviceDescription(INT32 deviceID, char *name, UINT32 nameLength) { |
|
47191
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
102 |
MIDIOUTCAPSW midiOutCaps; |
2 | 103 |
char *desc; |
104 |
INT32 err; |
|
105 |
||
106 |
if (getMidiOutCaps(deviceID, &midiOutCaps, &err)) { |
|
107 |
int tech = (int)midiOutCaps.wTechnology; |
|
108 |
switch(tech) { |
|
109 |
case MOD_MIDIPORT: |
|
110 |
desc = "External MIDI Port"; |
|
111 |
break; |
|
112 |
case MOD_SQSYNTH: |
|
113 |
desc = "Internal square wave synthesizer"; |
|
114 |
break; |
|
115 |
case MOD_FMSYNTH: |
|
116 |
desc = "Internal FM synthesizer"; |
|
117 |
break; |
|
118 |
case MOD_SYNTH: |
|
119 |
desc = "Internal synthesizer (generic)"; |
|
120 |
break; |
|
121 |
case MOD_MAPPER: |
|
122 |
desc = "Windows MIDI_MAPPER"; |
|
123 |
break; |
|
124 |
case 7 /* MOD_SWSYNTH*/: |
|
125 |
desc = "Internal software synthesizer"; |
|
126 |
break; |
|
127 |
default: |
|
128 |
return MIDI_NOT_SUPPORTED; |
|
129 |
} |
|
130 |
strncpy(name, desc, nameLength-1); |
|
131 |
name[nameLength-1] = 0; |
|
132 |
return MIDI_SUCCESS; |
|
133 |
} |
|
134 |
return err; |
|
135 |
} |
|
136 |
||
137 |
||
138 |
INT32 MIDI_OUT_GetDeviceVersion(INT32 deviceID, char *name, UINT32 nameLength) { |
|
47191
8c95ea7056b7
8177951: Charset problem when the name of the sound device contains Chinese character
serb
parents:
25859
diff
changeset
|
139 |
MIDIOUTCAPSW midiOutCaps; |
2 | 140 |
INT32 err; |
141 |
||
142 |
if (getMidiOutCaps(deviceID, &midiOutCaps, &err) && nameLength>7) { |
|
143 |
sprintf(name, "%d.%d", (midiOutCaps.vDriverVersion & 0xFF00) >> 8, midiOutCaps.vDriverVersion & 0xFF); |
|
144 |
return MIDI_SUCCESS; |
|
145 |
} |
|
146 |
MIDIOUT_CHECK_ERROR; |
|
147 |
return err; |
|
148 |
} |
|
149 |
||
150 |
||
151 |
/* *************************** MidiOutDevice implementation ***************************************** */ |
|
152 |
||
153 |
||
154 |
INT32 unprepareLongBuffers(MidiDeviceHandle* handle) { |
|
155 |
SysExQueue* sysex; |
|
156 |
MMRESULT err = MMSYSERR_NOERROR; |
|
157 |
int i; |
|
158 |
||
159 |
if (!handle || !handle->deviceHandle || !handle->longBuffers) { |
|
160 |
ERROR0("MIDI_OUT_unprepareLongBuffers: handle, deviceHandle, or longBuffers == NULL\n"); |
|
161 |
return MIDI_INVALID_HANDLE; |
|
162 |
} |
|
163 |
sysex = (SysExQueue*) handle->longBuffers; |
|
164 |
for (i = 0; i<sysex->count; i++) { |
|
165 |
MIDIHDR* hdr = &(sysex->header[i]); |
|
166 |
if (hdr->dwFlags) { |
|
167 |
err = midiOutUnprepareHeader((HMIDIOUT) handle->deviceHandle, hdr, sizeof(MIDIHDR)); |
|
168 |
} |
|
169 |
} |
|
170 |
MIDIOUT_CHECK_ERROR; |
|
171 |
return (INT32) err; |
|
172 |
} |
|
173 |
||
174 |
INT32 freeLongBuffer(MIDIHDR* hdr, HMIDIOUT deviceHandle, INT32 minToLeaveData) { |
|
175 |
MMRESULT err = MMSYSERR_NOERROR; |
|
176 |
||
177 |
if (!hdr) { |
|
178 |
ERROR0("MIDI_OUT_freeLongBuffer: hdr == NULL\n"); |
|
179 |
return MIDI_INVALID_HANDLE; |
|
180 |
} |
|
181 |
if (hdr->dwFlags && deviceHandle) { |
|
182 |
err = midiOutUnprepareHeader(deviceHandle, hdr, sizeof(MIDIHDR)); |
|
183 |
} |
|
184 |
if (hdr->lpData && (((INT32) hdr->dwBufferLength) < minToLeaveData || minToLeaveData < 0)) { |
|
185 |
free(hdr->lpData); |
|
186 |
hdr->lpData=NULL; |
|
187 |
hdr->dwBufferLength=0; |
|
188 |
} |
|
189 |
hdr->dwBytesRecorded=0; |
|
190 |
hdr->dwFlags=0; |
|
191 |
return (INT32) err; |
|
192 |
} |
|
193 |
||
194 |
INT32 freeLongBuffers(MidiDeviceHandle* handle) { |
|
195 |
SysExQueue* sysex; |
|
196 |
MMRESULT err = MMSYSERR_NOERROR; |
|
197 |
int i; |
|
198 |
||
199 |
if (!handle || !handle->longBuffers) { |
|
200 |
ERROR0("MIDI_OUT_freeLongBuffers: handle or longBuffers == NULL\n"); |
|
201 |
return MIDI_INVALID_HANDLE; |
|
202 |
} |
|
203 |
sysex = (SysExQueue*) handle->longBuffers; |
|
204 |
for (i = 0; i<sysex->count; i++) { |
|
205 |
err = freeLongBuffer(&(sysex->header[i]), (HMIDIOUT) handle->deviceHandle, -1); |
|
206 |
} |
|
207 |
MIDIOUT_CHECK_ERROR; |
|
208 |
return (INT32) err; |
|
209 |
} |
|
210 |
||
211 |
INT32 MIDI_OUT_OpenDevice(INT32 deviceID, MidiDeviceHandle** handle) { |
|
212 |
MMRESULT err; |
|
213 |
||
214 |
TRACE1(">> MIDI_OUT_OpenDevice: deviceID: %d\n", deviceID); |
|
215 |
||
216 |
if (deviceID == 0) { |
|
217 |
deviceID = MIDI_MAPPER; |
|
218 |
} else { |
|
219 |
deviceID--; |
|
220 |
} |
|
221 |
#ifdef USE_ERROR |
|
222 |
setvbuf(stdout, NULL, (int)_IONBF, 0); |
|
223 |
setvbuf(stderr, NULL, (int)_IONBF, 0); |
|
224 |
#endif |
|
225 |
||
226 |
(*handle) = (MidiDeviceHandle*) malloc(sizeof(MidiDeviceHandle)); |
|
227 |
if (!(*handle)) { |
|
228 |
ERROR0("ERROR: MIDI_OUT_OpenDevice: out of memory\n"); |
|
229 |
return MIDI_OUT_OF_MEMORY; |
|
230 |
} |
|
231 |
memset(*handle, 0, sizeof(MidiDeviceHandle)); |
|
232 |
||
233 |
// create long buffer queue |
|
234 |
if (!MIDI_WinCreateEmptyLongBufferQueue(*handle, MIDI_OUT_LONG_QUEUE_SIZE)) { |
|
235 |
ERROR0("ERROR: MIDI_OUT_OpenDevice: could not create long Buffers\n"); |
|
236 |
free(*handle); |
|
237 |
(*handle) = NULL; |
|
238 |
return MIDI_OUT_OF_MEMORY; |
|
239 |
} |
|
240 |
||
241 |
// create notification event |
|
242 |
(*handle)->platformData = (void*) CreateEvent(NULL, FALSE /*manual reset*/, FALSE /*signaled*/, NULL); |
|
243 |
if (!(*handle)->platformData) { |
|
244 |
ERROR0("ERROR: MIDI_OUT_StartDevice: could not create event\n"); |
|
245 |
MIDI_WinDestroyLongBufferQueue(*handle); |
|
246 |
free(*handle); |
|
247 |
(*handle) = NULL; |
|
248 |
return MIDI_OUT_OF_MEMORY; |
|
249 |
} |
|
250 |
||
251 |
// finally open the device |
|
252 |
err = midiOutOpen((HMIDIOUT*) &((*handle)->deviceHandle), deviceID, |
|
253 |
(UINT_PTR) (*handle)->platformData, (UINT_PTR) (*handle), CALLBACK_EVENT); |
|
254 |
||
255 |
if ((err != MMSYSERR_NOERROR) || (!(*handle)->deviceHandle)) { |
|
256 |
/* some devices return non zero, but no error! */ |
|
257 |
if (midiOutShortMsg((HMIDIOUT) ((*handle)->deviceHandle),0) == MMSYSERR_INVALHANDLE) { |
|
258 |
MIDIOUT_CHECK_ERROR; |
|
259 |
CloseHandle((HANDLE) (*handle)->platformData); |
|
260 |
MIDI_WinDestroyLongBufferQueue(*handle); |
|
261 |
free(*handle); |
|
262 |
(*handle) = NULL; |
|
263 |
return (INT32) err; |
|
264 |
} |
|
265 |
} |
|
266 |
//$$fb enable high resolution time |
|
267 |
timeBeginPeriod(1); |
|
268 |
MIDI_SetStartTime(*handle); |
|
269 |
TRACE0("<< MIDI_OUT_OpenDevice: succeeded\n"); |
|
270 |
return MIDI_SUCCESS; |
|
271 |
} |
|
272 |
||
273 |
INT32 MIDI_OUT_CloseDevice(MidiDeviceHandle* handle) { |
|
274 |
MMRESULT err = MMSYSERR_NOERROR; |
|
275 |
HANDLE event; |
|
276 |
||
277 |
TRACE0("> MIDI_OUT_CloseDevice\n"); |
|
278 |
if (!handle) { |
|
279 |
ERROR0("ERROR: MIDI_OUT_StopDevice: handle is NULL\n"); |
|
280 |
return MIDI_INVALID_HANDLE; // failure |
|
281 |
} |
|
282 |
// encourage MIDI_OUT_SendLongMessage to return soon |
|
283 |
event = handle->platformData; |
|
284 |
handle->platformData = NULL; |
|
285 |
if (event) { |
|
286 |
SetEvent(event); |
|
287 |
} else { |
|
288 |
ERROR0("ERROR: MIDI_OUT_StopDevice: event is NULL\n"); |
|
289 |
} |
|
290 |
||
291 |
if (handle->deviceHandle) { |
|
292 |
//$$fb disable high resolution time |
|
293 |
timeEndPeriod(1); |
|
294 |
err = midiOutReset((HMIDIOUT) handle->deviceHandle); |
|
295 |
} else { |
|
296 |
ERROR0("ERROR: MIDI_OUT_CloseDevice: deviceHandle is NULL\n"); |
|
297 |
} |
|
298 |
||
299 |
// issue a "SUSTAIN OFF" message to each MIDI channel, 0 to 15. |
|
300 |
// "CONTROL CHANGE" is 176, "SUSTAIN CONTROLLER" is 64, and the value is 0. |
|
301 |
// $$fb 2002-04-04: It is responsability of the application developer to |
|
302 |
// leave the device in a consistent state. So I put this in comments |
|
303 |
/* |
|
304 |
for (channel = 0; channel < 16; channel++) |
|
305 |
MIDI_OUT_SendShortMessage(deviceHandle, (unsigned char)(176 + channel), (unsigned char)64, (unsigned char)0, (UINT32)-1); |
|
306 |
*/ |
|
307 |
||
308 |
if (event) { |
|
309 |
// wait until MIDI_OUT_SendLongMessage has finished |
|
310 |
while (handle->isWaiting) Sleep(0); |
|
311 |
} |
|
312 |
||
313 |
unprepareLongBuffers(handle); |
|
314 |
||
315 |
if (handle->deviceHandle) { |
|
316 |
err = midiOutClose((HMIDIOUT) handle->deviceHandle); |
|
317 |
MIDIOUT_CHECK_ERROR; |
|
318 |
handle->deviceHandle = NULL; |
|
319 |
} |
|
320 |
freeLongBuffers(handle); |
|
321 |
||
322 |
if (event) { |
|
323 |
CloseHandle(event); |
|
324 |
} |
|
325 |
MIDI_WinDestroyLongBufferQueue(handle); |
|
326 |
free(handle); |
|
327 |
||
328 |
TRACE0("< MIDI_OUT_CloseDevice\n"); |
|
329 |
return (INT32) err; |
|
330 |
} |
|
331 |
||
332 |
||
333 |
/* return time stamp in microseconds */ |
|
334 |
INT64 MIDI_OUT_GetTimeStamp(MidiDeviceHandle* handle) { |
|
335 |
return MIDI_GetTimeStamp(handle); |
|
336 |
} |
|
337 |
||
338 |
||
339 |
INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT32 timestamp) { |
|
340 |
MMRESULT err = MMSYSERR_NOERROR; |
|
341 |
||
342 |
TRACE2("> MIDI_OUT_SendShortMessage %x, time: %d\n", packedMsg, timestamp); |
|
343 |
if (!handle) { |
|
344 |
ERROR0("ERROR: MIDI_OUT_SendShortMessage: handle is NULL\n"); |
|
345 |
return MIDI_INVALID_HANDLE; // failure |
|
346 |
} |
|
347 |
err = midiOutShortMsg((HMIDIOUT) handle->deviceHandle, packedMsg); |
|
348 |
MIDIOUT_CHECK_ERROR; |
|
349 |
TRACE0("< MIDI_OUT_SendShortMessage\n"); |
|
350 |
return (INT32) err; |
|
351 |
} |
|
352 |
||
353 |
INT32 MIDI_OUT_SendLongMessage(MidiDeviceHandle* handle, UBYTE* data, UINT32 size, UINT32 timestamp) { |
|
354 |
MMRESULT err; |
|
355 |
SysExQueue* sysex; |
|
356 |
MIDIHDR* hdr = NULL; |
|
357 |
INT32 remainingSize; |
|
358 |
int i; |
|
359 |
||
360 |
TRACE2("> MIDI_OUT_SendLongMessage size %d, time: %d\n", size, timestamp); |
|
361 |
if (!handle || !data || !handle->longBuffers) { |
|
362 |
ERROR0("< ERROR: MIDI_OUT_SendLongMessage: handle, data, or longBuffers is NULL\n"); |
|
363 |
return MIDI_INVALID_HANDLE; // failure |
|
364 |
} |
|
365 |
if (size == 0) { |
|
366 |
return MIDI_SUCCESS; |
|
367 |
} |
|
368 |
||
369 |
sysex = (SysExQueue*) handle->longBuffers; |
|
370 |
remainingSize = size; |
|
371 |
||
372 |
// send in chunks of 512 bytes |
|
373 |
size = 512; |
|
374 |
while (remainingSize > 0) { |
|
375 |
if (remainingSize < (INT32) size) { |
|
376 |
size = (UINT32) remainingSize; |
|
377 |
} |
|
378 |
||
379 |
while (!hdr && handle->platformData) { |
|
380 |
/* find a non-queued header */ |
|
381 |
for (i = 0; i < sysex->count; i++) { |
|
382 |
hdr = &(sysex->header[i]); |
|
383 |
if ((hdr->dwFlags & MHDR_DONE) || (hdr->dwFlags == 0)) { |
|
384 |
break; |
|
385 |
} |
|
386 |
hdr = NULL; |
|
387 |
} |
|
388 |
/* wait for a buffer to free up */ |
|
389 |
if (!hdr && handle->platformData) { |
|
390 |
DWORD res; |
|
391 |
TRACE0(" Need to wait for free buffer\n"); |
|
392 |
handle->isWaiting = TRUE; |
|
393 |
res = WaitForSingleObject((HANDLE) handle->platformData, 700); |
|
394 |
handle->isWaiting = FALSE; |
|
395 |
if (res == WAIT_TIMEOUT) { |
|
396 |
// break out back to Java if no buffer freed up after 700 milliseconds |
|
397 |
TRACE0("-> TIMEOUT. Need to go back to Java\n"); |
|
398 |
break; |
|
399 |
} |
|
400 |
} |
|
401 |
} |
|
402 |
if (!hdr) { |
|
403 |
// no free buffer |
|
404 |
return MIDI_NOT_SUPPORTED; |
|
405 |
} |
|
406 |
||
407 |
TRACE2("-> sending %d bytes with buffer index=%d\n", (int) size, (int) hdr->dwUser); |
|
408 |
freeLongBuffer(hdr, handle->deviceHandle, (INT32) size); |
|
409 |
if (hdr->lpData == NULL) { |
|
410 |
hdr->lpData = malloc(size); |
|
411 |
hdr->dwBufferLength = size; |
|
412 |
} |
|
413 |
hdr->dwBytesRecorded = size; |
|
414 |
memcpy(hdr->lpData, data, size); |
|
415 |
err = midiOutPrepareHeader((HMIDIOUT) handle->deviceHandle, hdr, sizeof(MIDIHDR)); |
|
416 |
if (err != MMSYSERR_NOERROR) { |
|
417 |
freeLongBuffer(hdr, handle->deviceHandle, -1); |
|
418 |
MIDIOUT_CHECK_ERROR; |
|
419 |
return (INT32) err; |
|
420 |
} |
|
421 |
err = midiOutLongMsg((HMIDIOUT) handle->deviceHandle, hdr, sizeof(MIDIHDR)); |
|
422 |
if (err != MMSYSERR_NOERROR) { |
|
423 |
freeLongBuffer(hdr, handle->deviceHandle, -1); |
|
424 |
ERROR0("ERROR: MIDI_OUT_SendLongMessage: midiOutLongMsg returned error:\n"); |
|
425 |
MIDIOUT_CHECK_ERROR; |
|
426 |
return (INT32) err; |
|
427 |
} |
|
428 |
remainingSize -= size; |
|
429 |
data += size; |
|
430 |
} |
|
431 |
TRACE0("< MIDI_OUT_SendLongMessage success\n"); |
|
432 |
return MIDI_SUCCESS; |
|
433 |
} |
|
434 |
||
435 |
#endif // USE_PLATFORM_MIDI_OUT |