jdk/src/java.desktop/share/native/libjsound/PortMixerProvider.c
author serb
Thu, 19 Feb 2015 18:47:55 +0300
changeset 29261 ea6e20f98dfa
parent 25859 3317bb8137f4
permissions -rw-r--r--
8072665: SoundLibraries.gmk and SoundDefs.h: remove isSigned8() dead code Reviewed-by: erikj, ihse, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
//#define USE_TRACE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "SoundDefs.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "Ports.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "Utilities.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "com_sun_media_sound_PortMixerProvider.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
//////////////////////////////////////////// PortMixerProvider ////////////////////////////////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
int getPortMixerDescription(int mixerIndex, PortMixerDescription* desc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    strcpy(desc->name, "Unknown Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    strcpy(desc->vendor, "Unknown Vendor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    strcpy(desc->description, "Port Mixer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    strcpy(desc->version, "Unknown Version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#if USE_PORTS == TRUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    PORT_GetPortMixerDescription(mixerIndex, desc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#endif // USE_PORTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
JNIEXPORT jint JNICALL Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices(JNIEnv *env, jclass cls) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    INT32 numDevices = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    TRACE0("Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices.\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#if USE_PORTS == TRUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    numDevices = PORT_GetPortMixerCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#endif // USE_PORTS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    TRACE1("Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices returning %d.\n", (int) numDevices);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    return (jint)numDevices;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
JNIEXPORT jobject JNICALL Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo(JNIEnv *env, jclass cls, jint mixerIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    jclass portMixerInfoClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    jmethodID portMixerInfoConstructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    PortMixerDescription desc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    TRACE1("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo(%d).\n", mixerIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    // retrieve class and constructor of PortMixerProvider.PortMixerInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    portMixerInfoClass = (*env)->FindClass(env, IMPLEMENTATION_PACKAGE_NAME"/PortMixerProvider$PortMixerInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    if (portMixerInfoClass == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        ERROR0("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo: portMixerInfoClass is NULL\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    portMixerInfoConstructor = (*env)->GetMethodID(env, portMixerInfoClass, "<init>",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                  "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    if (portMixerInfoConstructor == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        ERROR0("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo: portMixerInfoConstructor is NULL\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    if (getPortMixerDescription(mixerIndex, &desc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    TRACE0("Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo succeeded.\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    return info;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
}