author | serb |
Thu, 19 Feb 2015 18:47:55 +0300 | |
changeset 29261 | ea6e20f98dfa |
parent 25859 | 3317bb8137f4 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23659
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
//#define USE_TRACE |
|
27 |
||
28 |
||
29 |
#include <jni.h> |
|
23659
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
30 |
#include <jni_util.h> |
2 | 31 |
#include "SoundDefs.h" |
32 |
#include "Ports.h" |
|
33 |
#include "Utilities.h" |
|
34 |
#include "com_sun_media_sound_PortMixerProvider.h" |
|
35 |
||
36 |
||
37 |
//////////////////////////////////////////// PortMixerProvider //////////////////////////////////////////// |
|
38 |
||
39 |
int getPortMixerDescription(int mixerIndex, PortMixerDescription* desc) { |
|
40 |
strcpy(desc->name, "Unknown Name"); |
|
41 |
strcpy(desc->vendor, "Unknown Vendor"); |
|
42 |
strcpy(desc->description, "Port Mixer"); |
|
43 |
strcpy(desc->version, "Unknown Version"); |
|
44 |
#if USE_PORTS == TRUE |
|
45 |
PORT_GetPortMixerDescription(mixerIndex, desc); |
|
46 |
#endif // USE_PORTS |
|
47 |
return TRUE; |
|
48 |
} |
|
49 |
||
50 |
JNIEXPORT jint JNICALL Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices(JNIEnv *env, jclass cls) { |
|
51 |
INT32 numDevices = 0; |
|
52 |
||
53 |
TRACE0("Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices.\n"); |
|
54 |
||
55 |
#if USE_PORTS == TRUE |
|
56 |
numDevices = PORT_GetPortMixerCount(); |
|
57 |
#endif // USE_PORTS |
|
58 |
||
59 |
TRACE1("Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices returning %d.\n", (int) numDevices); |
|
60 |
||
61 |
return (jint)numDevices; |
|
62 |
} |
|
63 |
||
64 |
JNIEXPORT jobject JNICALL Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo(JNIEnv *env, jclass cls, jint mixerIndex) { |
|
65 |
jclass portMixerInfoClass; |
|
66 |
jmethodID portMixerInfoConstructor; |
|
67 |
PortMixerDescription desc; |
|
68 |
jobject info = NULL; |
|
23659
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
69 |
jstring name; |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
70 |
jstring vendor; |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
71 |
jstring description; |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
72 |
jstring version; |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
73 |
|
2 | 74 |
TRACE1("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo(%d).\n", mixerIndex); |
75 |
||
76 |
// retrieve class and constructor of PortMixerProvider.PortMixerInfo |
|
77 |
portMixerInfoClass = (*env)->FindClass(env, IMPLEMENTATION_PACKAGE_NAME"/PortMixerProvider$PortMixerInfo"); |
|
78 |
if (portMixerInfoClass == NULL) { |
|
79 |
ERROR0("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo: portMixerInfoClass is NULL\n"); |
|
80 |
return NULL; |
|
81 |
} |
|
82 |
portMixerInfoConstructor = (*env)->GetMethodID(env, portMixerInfoClass, "<init>", |
|
83 |
"(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); |
|
84 |
if (portMixerInfoConstructor == NULL) { |
|
85 |
ERROR0("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo: portMixerInfoConstructor is NULL\n"); |
|
86 |
return NULL; |
|
87 |
} |
|
88 |
||
89 |
if (getPortMixerDescription(mixerIndex, &desc)) { |
|
90 |
// create a new PortMixerInfo object and return it |
|
23659
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
91 |
name = (*env)->NewStringUTF(env, desc.name); |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
92 |
CHECK_NULL_RETURN(name, info); |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
93 |
vendor = (*env)->NewStringUTF(env, desc.vendor); |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
94 |
CHECK_NULL_RETURN(vendor, info); |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
95 |
description = (*env)->NewStringUTF(env, desc.description); |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
96 |
CHECK_NULL_RETURN(description, info); |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
97 |
version = (*env)->NewStringUTF(env, desc.version); |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
98 |
CHECK_NULL_RETURN(version, info); |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
99 |
info = (*env)->NewObject(env, portMixerInfoClass, |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
100 |
portMixerInfoConstructor, mixerIndex, |
ac5179bc5c63
8029362: [Parfait] warnings from b117 for jdk.src.share.native.com.sun.media.sound: JNI exception pending
serb
parents:
5506
diff
changeset
|
101 |
name, vendor, description, version); |
2 | 102 |
} |
103 |
||
104 |
TRACE0("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo succeeded.\n"); |
|
105 |
return info; |
|
106 |
} |