Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.desktop/share/native/libjsound/MidiInDeviceProvider.c
41152 views
1
/*
2
* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
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
//#define USE_ERROR
27
//#define USE_TRACE
28
29
30
#include <jni.h>
31
#include "SoundDefs.h"
32
#include "PlatformMidi.h"
33
#include "Utilities.h"
34
// for strcpy
35
#include <string.h>
36
#include "com_sun_media_sound_MidiInDeviceProvider.h"
37
38
39
#define MAX_STRING_LENGTH 128
40
41
42
JNIEXPORT jint JNICALL
43
Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices(JNIEnv* e, jobject thisObj) {
44
45
INT32 numDevices = 0;
46
47
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices.\n");
48
49
#if USE_PLATFORM_MIDI_IN == TRUE
50
numDevices = MIDI_IN_GetNumDevices();
51
#endif
52
53
TRACE1("Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices returning %d.\n", numDevices);
54
return (jint) numDevices;
55
}
56
57
58
JNIEXPORT jstring JNICALL
59
Java_com_sun_media_sound_MidiInDeviceProvider_nGetName(JNIEnv* e, jobject thisObj, jint index) {
60
61
char name[MAX_STRING_LENGTH + 1];
62
jstring jString = NULL;
63
64
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetName.\n");
65
name[0] = 0;
66
67
#if USE_PLATFORM_MIDI_IN == TRUE
68
MIDI_IN_GetDeviceName((INT32)index, name, (UINT32)MAX_STRING_LENGTH);
69
#endif
70
71
if (name[0] == 0) {
72
strcpy(name, "Unknown name");
73
}
74
jString = (*e)->NewStringUTF(e, name);
75
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetName completed.\n");
76
return jString;
77
}
78
79
80
JNIEXPORT jstring JNICALL
81
Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor(JNIEnv* e, jobject thisObj, jint index) {
82
83
char name[MAX_STRING_LENGTH + 1];
84
jstring jString = NULL;
85
86
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor.\n");
87
name[0] = 0;
88
89
#if USE_PLATFORM_MIDI_IN == TRUE
90
MIDI_IN_GetDeviceVendor((INT32)index, name, (UINT32)MAX_STRING_LENGTH);
91
#endif
92
93
if (name[0] == 0) {
94
strcpy(name, "Unknown vendor");
95
}
96
jString = (*e)->NewStringUTF(e, name);
97
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor completed.\n");
98
return jString;
99
}
100
101
102
JNIEXPORT jstring JNICALL
103
Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription(JNIEnv* e, jobject thisObj, jint index) {
104
105
char name[MAX_STRING_LENGTH + 1];
106
jstring jString = NULL;
107
108
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription.\n");
109
name[0] = 0;
110
111
#if USE_PLATFORM_MIDI_IN == TRUE
112
MIDI_IN_GetDeviceDescription((INT32)index, name, (UINT32)MAX_STRING_LENGTH);
113
#endif
114
115
if (name[0] == 0) {
116
strcpy(name, "No details available");
117
}
118
jString = (*e)->NewStringUTF(e, name);
119
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription completed.\n");
120
return jString;
121
}
122
123
124
JNIEXPORT jstring JNICALL
125
Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion(JNIEnv* e, jobject thisObj, jint index) {
126
127
char name[MAX_STRING_LENGTH + 1];
128
jstring jString = NULL;
129
130
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion.\n");
131
name[0] = 0;
132
133
#if USE_PLATFORM_MIDI_IN == TRUE
134
MIDI_IN_GetDeviceVersion((INT32)index, name, (UINT32)MAX_STRING_LENGTH);
135
#endif
136
137
if (name[0] == 0) {
138
strcpy(name, "Unknown version");
139
}
140
jString = (*e)->NewStringUTF(e, name);
141
TRACE0("Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion completed.\n");
142
return jString;
143
}
144
145