Imported GNU Classpath 0.19 + gcj-import-20051115.
[official-gcc.git] / libjava / classpath / native / jni / midi-dssi / gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c
blob3cad45931bb1d7ef8c46731d45591d32d3b7ce12
1 /* gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.c - DSSI Provider
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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.
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.
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.
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.
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. */
38 #include <config.h>
39 #include <gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider.h>
41 #include "dssi_data.h"
43 void
44 Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_dlclose_1
45 (JNIEnv *env, jclass clazz __attribute__((unused)), jlong sohandle)
47 dssi_data *data = (dssi_data *) (long) sohandle;
48 dlclose (data->dlhandle);
49 JCL_free (env, data);
52 jlong
53 Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_dlopen_1
54 (JNIEnv *env, jclass clazz __attribute__((unused)), jstring name)
56 const char *filename;
57 void *handle;
58 DSSI_Descriptor_Function fn;
59 dssi_data *data = 0;
61 filename = JCL_jstring_to_cstring (env, name);
62 if (filename == NULL)
63 return (0);
65 handle = dlopen(filename, RTLD_NOW);
67 if (handle == 0)
68 goto done;
70 fn = (DSSI_Descriptor_Function) dlsym(handle, "dssi_descriptor");
72 if (fn == 0)
74 dlclose(handle);
75 goto done;
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;
84 done:
85 JCL_free_cstring (env, name, filename);
86 return PTR_TO_JLONG(data);
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)
94 dssi_data *data = JLONG_TO_PTR(dssi_data,handle);
95 data->desc = (data->fn)(index);
96 return PTR_TO_JLONG(data->desc);
99 jstring
100 Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIName_1
101 (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
103 DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
104 const char *str = desc->LADSPA_Plugin->Name;
106 return (*env)->NewStringUTF (env, str);
109 jstring
110 Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSICopyright_1
111 (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
113 DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
114 const char *str = desc->LADSPA_Plugin->Copyright;
116 return (*env)->NewStringUTF (env, str);
119 jstring
120 Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSIVendor_1
121 (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
123 DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
124 const char *str = desc->LADSPA_Plugin->Maker;
126 return (*env)->NewStringUTF (env, str);
129 jstring
130 Java_gnu_javax_sound_midi_dssi_DSSIMidiDeviceProvider_getDSSILabel_1
131 (JNIEnv *env, jclass clazz __attribute__((unused)), jlong handle)
133 DSSI_Descriptor *desc = JLONG_TO_PTR(DSSI_Descriptor,handle);
134 const char *str = desc->LADSPA_Plugin->Label;
136 return (*env)->NewStringUTF (env, str);