1 |
774 |
jeremybenn |
/* gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c - DSSI Provider
|
2 |
|
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
3 |
|
|
|
4 |
|
|
This file is part of GNU Classpath.
|
5 |
|
|
|
6 |
|
|
GNU Classpath is free software; you can redistribute it and/or modify
|
7 |
|
|
it under the terms of the GNU General Public License as published by
|
8 |
|
|
the Free Software Foundation; either version 2, or (at your option)
|
9 |
|
|
any later version.
|
10 |
|
|
|
11 |
|
|
GNU Classpath is distributed in the hope that it will be useful, but
|
12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
General Public License for more details.
|
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License
|
17 |
|
|
along with GNU Classpath; see the file COPYING. If not, write to the
|
18 |
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 |
|
|
02110-1301 USA.
|
20 |
|
|
|
21 |
|
|
Linking this library statically or dynamically with other modules is
|
22 |
|
|
making a combined work based on this library. Thus, the terms and
|
23 |
|
|
conditions of the GNU General Public License cover the whole
|
24 |
|
|
combination.
|
25 |
|
|
|
26 |
|
|
As a special exception, the copyright holders of this library give you
|
27 |
|
|
permission to link this library with independent modules to produce an
|
28 |
|
|
executable, regardless of the license terms of these independent
|
29 |
|
|
modules, and to copy and distribute the resulting executable under
|
30 |
|
|
terms of your choice, provided that you also meet, for each linked
|
31 |
|
|
independent module, the terms and conditions of the license of that
|
32 |
|
|
module. An independent module is a module which is not derived from
|
33 |
|
|
or based on this library. If you modify this library, you may extend
|
34 |
|
|
this exception to your version of the library, but you are not
|
35 |
|
|
obligated to do so. If you do not wish to do so, delete this
|
36 |
|
|
exception statement from your version. */
|
37 |
|
|
|
38 |
|
|
#include <config.h>
|
39 |
|
|
#include <gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h>
|
40 |
|
|
|
41 |
|
|
#include "dssi_data.h"
|
42 |
|
|
|
43 |
|
|
void
|
44 |
|
|
Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_dlclose_1
|
45 |
|
|
(JNIEnv *env, jclass clazz __attribute__((unused)), jlong sohandle)
|
46 |
|
|
{
|
47 |
|
|
dssi_data *data = (dssi_data *) (long) sohandle;
|
48 |
|
|
dlclose (data->dlhandle);
|
49 |
|
|
JCL_free (env, data);
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
jlong
|
53 |
|
|
Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_dlopen_1
|
54 |
|
|
(JNIEnv *env, jclass clazz __attribute__((unused)), jstring name)
|
55 |
|
|
{
|
56 |
|
|
const char *filename;
|
57 |
|
|
void *handle;
|
58 |
|
|
DSSI_Descriptor_Function fn;
|
59 |
|
|
dssi_data *data = 0;
|
60 |
|
|
|
61 |
|
|
filename = JCL_jstring_to_cstring (env, name);
|
62 |
|
|
if (filename == NULL)
|
63 |
|
|
return (0);
|
64 |
|
|
|
65 |
|
|
handle = dlopen(filename, RTLD_NOW);
|
66 |
|
|
|
67 |
|
|
if (handle == 0)
|
68 |
|
|
goto done;
|
69 |
|
|
|
70 |
|
|
fn = (DSSI_Descriptor_Function) dlsym(handle, "dssi_descriptor");
|
71 |
|
|
|
72 |
|
|
if (fn == 0)
|
73 |
|
|
{
|
74 |
|
|
dlclose(handle);
|
75 |
|
|
goto done;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
data = (dssi_data *) JCL_malloc(env, sizeof(dssi_data));
|
79 |
|
|
data->dlhandle = handle;
|
80 |
|
|
data->fn = fn;
|
81 |
|
|
data->midiEventReadIndex = 0;
|
82 |
|
|
data->midiEventWriteIndex = 0;
|
83 |
|
|
|
84 |
|
|
done:
|
85 |
|
|
JCL_free_cstring (env, name, filename);
|
86 |
|
|
return PTR_TO_JLONG(data);
|
87 |
|
|
}
|
88 |
|
|
|
89 |
|
|
jlong
|
90 |
|
|
Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIHandle_1
|
91 |
|
|
(JNIEnv *env __attribute__((unused)),
|
92 |
|
|
jclass clazz __attribute__((unused)), jlong handle, jlong index)
|
93 |
|
|
{
|
94 |
|
|
dssi_data *data = JLONG_TO_PTR(dssi_data,handle);
|
95 |
|
|
data->desc = (data->fn)(index);
|
96 |
|
|
return PTR_TO_JLONG(data->desc);
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
jstring
|
100 |
|
|
Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIName_1
|
101 |
|
|
(JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
|
102 |
|
|
{
|
103 |
|
|
DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
|
104 |
|
|
const char *str = desc->LADSPA_Plugin->Name;
|
105 |
|
|
|
106 |
|
|
return (*env)->NewStringUTF (env, str);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
jstring
|
110 |
|
|
Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSICopyright_1
|
111 |
|
|
(JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
|
112 |
|
|
{
|
113 |
|
|
DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
|
114 |
|
|
const char *str = desc->LADSPA_Plugin->Copyright;
|
115 |
|
|
|
116 |
|
|
return (*env)->NewStringUTF (env, str);
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
jstring
|
120 |
|
|
Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIVendor_1
|
121 |
|
|
(JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
|
122 |
|
|
{
|
123 |
|
|
DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
|
124 |
|
|
const char *str = desc->LADSPA_Plugin->Maker;
|
125 |
|
|
|
126 |
|
|
return (*env)->NewStringUTF (env, str);
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
jstring
|
130 |
|
|
Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSILabel_1
|
131 |
|
|
(JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
|
132 |
|
|
{
|
133 |
|
|
DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
|
134 |
|
|
const char *str = desc->LADSPA_Plugin->Label;
|
135 |
|
|
|
136 |
|
|
return (*env)->NewStringUTF (env, str);
|
137 |
|
|
}
|
138 |
|
|
|
139 |
|
|
|