src/java.desktop/linux/native/libjsound/PLATFORM_API_LinuxOS_ALSA_CommonUtils.h
changeset 49289 148e29df1644
parent 47216 71c04702a3d5
equal deleted inserted replaced
49288:6e2d71029781 49289:148e29df1644
       
     1 /*
       
     2  * Copyright (c) 2003, 2007, 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 #include <alsa/asoundlib.h>
       
    27 #include "Utilities.h"
       
    28 
       
    29 #ifndef PLATFORM_API_LINUXOS_ALSA_COMMONUTILS_H_INCLUDED
       
    30 #define PLATFORM_API_LINUXOS_ALSA_COMMONUTILS_H_INCLUDED
       
    31 
       
    32 #define ALSA_VERSION_PROC_FILE "/proc/asound/version"
       
    33 #define ALSA_HARDWARE "hw"
       
    34 #define ALSA_HARDWARE_CARD ALSA_HARDWARE":%d"
       
    35 #define ALSA_HARDWARE_DEVICE ALSA_HARDWARE_CARD",%d"
       
    36 #define ALSA_HARDWARE_SUBDEVICE ALSA_HARDWARE_DEVICE",%d"
       
    37 
       
    38 #define ALSA_PLUGHARDWARE "plughw"
       
    39 #define ALSA_DEFAULT_DEVICE_NAME "default"
       
    40 
       
    41 #define ALSA_DEFAULT_DEVICE_ID (0)
       
    42 
       
    43 #define ALSA_PCM     (0)
       
    44 #define ALSA_RAWMIDI (1)
       
    45 
       
    46 // for use in info objects
       
    47 #define ALSA_VENDOR "ALSA (http://www.alsa-project.org)"
       
    48 
       
    49 // Environment variable for inclusion of subdevices in device listing.
       
    50 // If this variable is unset or "no", then subdevices are ignored, and
       
    51 // it's ALSA's choice which one to use (enables hardware mixing)
       
    52 #define ENV_ENUMERATE_PCM_SUBDEVICES "ALSA_ENUMERATE_PCM_SUBDEVICES"
       
    53 
       
    54 // if defined, subdevices are listed.
       
    55 //#undef ALSA_MIDI_ENUMERATE_SUBDEVICES
       
    56 #define ALSA_MIDI_ENUMERATE_SUBDEVICES
       
    57 
       
    58 // must be called before any ALSA calls
       
    59 void initAlsaSupport();
       
    60 
       
    61 /* if true (non-zero), ALSA sub devices should be listed as separate devices
       
    62  */
       
    63 int needEnumerateSubdevices(int isMidi);
       
    64 
       
    65 
       
    66 /*
       
    67  * deviceID contains packed card, device and subdevice numbers
       
    68  * each number takes 10 bits
       
    69  * "default" device has id == ALSA_DEFAULT_DEVICE_ID
       
    70  */
       
    71 UINT32 encodeDeviceID(int card, int device, int subdevice);
       
    72 
       
    73 void decodeDeviceID(UINT32 deviceID, int* card, int* device, int* subdevice,
       
    74                     int isMidi);
       
    75 
       
    76 void getDeviceStringFromDeviceID(char* buffer, UINT32 deviceID,
       
    77                                  int usePlugHw, int isMidi);
       
    78 
       
    79 void getALSAVersion(char* buffer, int len);
       
    80 
       
    81 
       
    82 #endif // PLATFORM_API_LINUXOS_ALSA_COMMONUTILS_H_INCLUDED