author | coleenp |
Fri, 09 Mar 2018 12:03:20 -0500 | |
changeset 49366 | f95ef5511e1f |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
12047
diff
changeset
|
2 |
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
12047 | 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 |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
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 |
* |
|
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. |
|
24 |
*/ |
|
25 |
||
26 |
#if (USE_PLATFORM_MIDI_IN == TRUE) || (USE_PLATFORM_MIDI_OUT == TRUE) |
|
27 |
||
28 |
#include "PlatformMidi.h" // JavaSound header for platform midi support. |
|
29 |
#include <CoreMIDI/CoreMIDI.h> // Umbrella header for the CoreMIDI framework. |
|
30 |
#include <CoreAudio/CoreAudio.h> // This provides access to the host's time base and translations to nanoseconds. |
|
31 |
#include <CoreFoundation/CoreFoundation.h> // CFDataRef. |
|
32 |
||
33 |
/* for memcpy */ |
|
34 |
#include <string.h> |
|
35 |
/* for malloc */ |
|
36 |
#include <stdlib.h> |
|
37 |
/* for usleep */ |
|
38 |
#include <unistd.h> |
|
39 |
||
40 |
#ifdef USE_ERROR |
|
41 |
#include <stdio.h> |
|
42 |
#endif |
|
43 |
||
44 |
#define MIDI_ERROR_NONE MIDI_SUCCESS |
|
45 |
||
46 |
#ifdef USE_ERROR |
|
47 |
#define MIDI_CHECK_ERROR { if (err != MIDI_ERROR_NONE) MIDI_Utils_PrintError(err); } |
|
48 |
#else |
|
49 |
#define MIDI_CHECK_ERROR |
|
50 |
#endif |
|
51 |
||
52 |
typedef struct { |
|
53 |
MidiDeviceHandle h; /* the real handle (must be the first field!) */ |
|
54 |
int direction; /* direction of the endpoint */ |
|
55 |
int deviceID; /* logical index (0 .. numEndpoints-1) */ |
|
56 |
int isStarted; /* whether device is "started" */ |
|
57 |
MIDIPortRef port; /* input or output port associated with the endpoint */ |
|
58 |
CFMutableDataRef readingSysExData; /* Non-Null: in the middle of reading SysEx data; Null: otherwise */ |
|
59 |
} MacMidiDeviceHandle; |
|
60 |
||
61 |
extern const char* MIDI_Utils_GetErrorMsg(int err); |
|
62 |
extern void MIDI_Utils_PrintError(int err); |
|
63 |
||
64 |
// A MIDI endpoint represents a source or a destination for a standard 16-channel MIDI data stream. |
|
65 |
enum { |
|
66 |
MIDI_IN = 0, // source |
|
67 |
MIDI_OUT = 1 // destination |
|
68 |
}; |
|
69 |
||
70 |
// The parameter "direction" is either MIDI_IN or MIDI_OUT. |
|
71 |
// Declarations of functions required by the JavaSound MIDI Porting layer. |
|
72 |
||
73 |
extern INT32 MIDI_Utils_GetNumDevices(int direction); |
|
74 |
extern INT32 MIDI_Utils_GetDeviceName(int direction, INT32 deviceID, char *name, UINT32 nameLength); |
|
75 |
extern INT32 MIDI_Utils_GetDeviceVendor(int direction, INT32 deviceID, char *name, UINT32 nameLength); |
|
76 |
extern INT32 MIDI_Utils_GetDeviceDescription(int direction, INT32 deviceID, char *name, UINT32 nameLength); |
|
77 |
extern INT32 MIDI_Utils_GetDeviceVersion(int direction, INT32 deviceID, char *name, UINT32 nameLength); |
|
78 |
extern INT32 MIDI_Utils_OpenDevice(int direction, INT32 deviceID, MacMidiDeviceHandle** handle, |
|
79 |
int num_msgs, int num_long_msgs, |
|
80 |
size_t lm_size); |
|
81 |
extern INT32 MIDI_Utils_CloseDevice(MacMidiDeviceHandle* handle); |
|
82 |
extern INT32 MIDI_Utils_StartDevice(MacMidiDeviceHandle* handle); |
|
83 |
extern INT32 MIDI_Utils_StopDevice(MacMidiDeviceHandle* handle); |
|
84 |
extern INT64 MIDI_Utils_GetTimeStamp(MacMidiDeviceHandle* handle); |
|
85 |
||
86 |
// Mac OS X port for locking and synchronization. |
|
87 |
||
88 |
extern void* MIDI_CreateConditionVariable(); |
|
89 |
extern void MIDI_DestroyConditionVariable(void* cond); |
|
90 |
extern void MIDI_WaitOnConditionVariable(void* cond, void* lock); |
|
91 |
extern void MIDI_SignalConditionVariable(void* cond); |
|
92 |
||
93 |
#endif // USE_PLATFORM_MIDI_IN || USE_PLATFORM_MIDI_OUT |