1/*
2 * Copyright (c) 2002, 2015, 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
27#include "Utilities.h"
28// Platform.java includes
29#include "com_sun_media_sound_Platform.h"
30
31/*
32 * Declare library specific JNI_Onload entry if static build
33 */
34DEF_STATIC_JNI_OnLoad
35
36/*
37 * Class:     com_sun_media_sound_Platform
38 * Method:    nIsBigEndian
39 * Signature: ()Z
40 */
41JNIEXPORT jboolean JNICALL Java_com_sun_media_sound_Platform_nIsBigEndian(JNIEnv *env, jclass clss) {
42    return UTIL_IsBigEndianPlatform();
43}
44
45/*
46 * Class:     com_sun_media_sound_Platform
47 * Method:    nGetExtraLibraries
48 * Signature: ()Ljava/lang/String;
49 */
50JNIEXPORT jstring JNICALL Java_com_sun_media_sound_Platform_nGetExtraLibraries(JNIEnv *env, jclass clss) {
51    return (*env)->NewStringUTF(env, EXTRA_SOUND_JNI_LIBS);
52}
53
54/*
55 * Class:     com_sun_media_sound_Platform
56 * Method:    nGetLibraryForFeature
57 * Signature: (I)I
58 */
59JNIEXPORT jint JNICALL Java_com_sun_media_sound_Platform_nGetLibraryForFeature
60  (JNIEnv *env, jclass clazz, jint feature) {
61
62// for every OS
63#if X_PLATFORM == X_WINDOWS
64    switch (feature) {
65    case com_sun_media_sound_Platform_FEATURE_MIDIIO:
66        return com_sun_media_sound_Platform_LIB_MAIN;
67    case com_sun_media_sound_Platform_FEATURE_PORTS:
68        return com_sun_media_sound_Platform_LIB_MAIN;
69    case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
70        return com_sun_media_sound_Platform_LIB_DSOUND;
71    }
72#endif
73#if (X_PLATFORM == X_SOLARIS)
74    switch (feature) {
75    case com_sun_media_sound_Platform_FEATURE_MIDIIO:
76        return com_sun_media_sound_Platform_LIB_MAIN;
77    case com_sun_media_sound_Platform_FEATURE_PORTS:
78        return com_sun_media_sound_Platform_LIB_MAIN;
79    case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
80        return com_sun_media_sound_Platform_LIB_MAIN;
81    }
82#endif
83#if (X_PLATFORM == X_LINUX)
84    switch (feature) {
85    case com_sun_media_sound_Platform_FEATURE_MIDIIO:
86        return com_sun_media_sound_Platform_LIB_ALSA;
87    case com_sun_media_sound_Platform_FEATURE_PORTS:
88        return com_sun_media_sound_Platform_LIB_ALSA;
89    case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
90        return com_sun_media_sound_Platform_LIB_ALSA;
91    }
92#endif
93#if (X_PLATFORM == X_MACOSX)
94    switch (feature) {
95    case com_sun_media_sound_Platform_FEATURE_MIDIIO:
96        return com_sun_media_sound_Platform_LIB_MAIN;
97    case com_sun_media_sound_Platform_FEATURE_PORTS:
98        return com_sun_media_sound_Platform_LIB_MAIN;
99    case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
100        return com_sun_media_sound_Platform_LIB_MAIN;
101    }
102#endif
103#if (X_PLATFORM == X_BSD)
104    switch (feature) {
105    case com_sun_media_sound_Platform_FEATURE_MIDIIO:
106       return com_sun_media_sound_Platform_LIB_MAIN;
107#ifdef __FreeBSD__
108    case com_sun_media_sound_Platform_FEATURE_PORTS:
109       return com_sun_media_sound_Platform_LIB_ALSA;
110    case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
111       return com_sun_media_sound_Platform_LIB_ALSA;
112#else
113    case com_sun_media_sound_Platform_FEATURE_PORTS:
114       return com_sun_media_sound_Platform_LIB_MAIN;
115    case com_sun_media_sound_Platform_FEATURE_DIRECT_AUDIO:
116       // XXXBSD: When native Direct Audio support is ported change
117       // this back to returning com_sun_media_sound_Platform_LIB_MAIN
118       return 0;
119#endif
120    }
121#endif
122    return 0;
123}
124