Path: blob/master/src/java.desktop/share/native/libjsound/MidiOutDeviceProvider.c
41149 views
/*1* Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425//#define USE_ERROR26//#define USE_TRACE272829#include <jni.h>30#include "SoundDefs.h"31#include "PlatformMidi.h"32#include "Utilities.h"33// for strcpy34#include <string.h>35#include "com_sun_media_sound_MidiOutDeviceProvider.h"363738#define MAX_STRING_LENGTH 128394041JNIEXPORT jint JNICALL42Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices(JNIEnv* e, jobject thisObj) {4344INT32 numDevices = 0;4546TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices.\n");4748#if USE_PLATFORM_MIDI_OUT == TRUE49numDevices = MIDI_OUT_GetNumDevices();50#endif5152TRACE1("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices returning %d.\n", (int) numDevices);53return (jint) numDevices;54}555657JNIEXPORT jstring JNICALL58Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName(JNIEnv* e, jobject thisObj, jint index) {5960char name[MAX_STRING_LENGTH + 1];61jstring jString = NULL;6263TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName.\n");64name[0] = 0;6566#if USE_PLATFORM_MIDI_OUT == TRUE67MIDI_OUT_GetDeviceName((INT32)index, name, (UINT32)MAX_STRING_LENGTH);68#endif6970if (name[0] == 0) {71strcpy(name, "Unknown name");72}73jString = (*e)->NewStringUTF(e, name);74TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName completed.\n");75return jString;76}777879JNIEXPORT jstring JNICALL80Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor(JNIEnv* e, jobject thisObj, jint index) {8182char name[MAX_STRING_LENGTH + 1];83jstring jString = NULL;8485TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor.\n");86name[0] = 0;8788#if USE_PLATFORM_MIDI_OUT == TRUE89MIDI_OUT_GetDeviceVendor((INT32)index, name, (UINT32)MAX_STRING_LENGTH);90#endif9192if (name[0] == 0) {93strcpy(name, "Unknown vendor");94}95jString = (*e)->NewStringUTF(e, name);96TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor completed.\n");97return jString;98}99100101JNIEXPORT jstring JNICALL102Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription(JNIEnv* e, jobject thisObj, jint index) {103104char name[MAX_STRING_LENGTH + 1];105jstring jString = NULL;106107TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription.\n");108name[0] = 0;109110#if USE_PLATFORM_MIDI_OUT == TRUE111MIDI_OUT_GetDeviceDescription((INT32)index, name, (UINT32)MAX_STRING_LENGTH);112#endif113114if (name[0] == 0) {115strcpy(name, "No details available");116}117jString = (*e)->NewStringUTF(e, name);118TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription completed.\n");119return jString;120}121122123JNIEXPORT jstring JNICALL124Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion(JNIEnv* e, jobject thisObj, jint index) {125126char name[MAX_STRING_LENGTH + 1];127jstring jString = NULL;128129TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion.\n");130name[0] = 0;131132#if USE_PLATFORM_MIDI_OUT == TRUE133MIDI_OUT_GetDeviceVersion((INT32)index, name, (UINT32)MAX_STRING_LENGTH);134#endif135if (name[0] == 0) {136strcpy(name, "Unknown version");137}138jString = (*e)->NewStringUTF(e, name);139140TRACE0("Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion completed.\n");141142return jString;143}144145146