1 /*
   2  * Copyright (c) 2002, 2013, 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 <Utilities.h>
  27 #include <string.h>
  28 #include <stdlib.h>
  29 #include <fcntl.h>
  30 /* does not work on Solaris 2.7 */
  31 #include <sys/audio.h>
  32 #include <sys/mixer.h>
  33 #include <sys/types.h>
  34 #ifndef __linux__
  35 #include <stropts.h>
  36 #endif
  37 #include <sys/conf.h>
  38 #include <sys/stat.h>
  39 #include <unistd.h>
  40 
  41 #ifndef PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED
  42 #define PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED
  43 
  44 /* defines for Solaris 2.7
  45    #ifndef AUDIO_AUX1_OUT
  46    #define AUDIO_AUX1_OUT   (0x08)  // output to aux1 out
  47    #define AUDIO_AUX2_OUT   (0x10)  // output to aux2 out
  48    #define AUDIO_SPDIF_OUT  (0x20)  // output to SPDIF port
  49    #define AUDIO_AUX1_IN    (0x08)    // input from aux1 in
  50    #define AUDIO_AUX2_IN    (0x10)    // input from aux2 in
  51    #define AUDIO_SPDIF_IN   (0x20)    // input from SPDIF port
  52    #endif
  53 */
  54 
  55 /* input from Codec inter. loopback */
  56 #ifndef AUDIO_CODEC_LOOPB_IN
  57 #define AUDIO_CODEC_LOOPB_IN       (0x40)
  58 #endif
  59 
  60 
  61 #define MAX_NAME_LENGTH 300
  62 
  63 typedef struct tag_AudioDevicePath {
  64     char path[MAX_NAME_LENGTH];
  65     ino_t st_ino; // inode number to detect duplicate devices
  66     dev_t st_dev; // device ID to detect duplicate audio devices
  67 } AudioDevicePath;
  68 
  69 typedef struct tag_AudioDeviceDescription {
  70     INT32 maxSimulLines;
  71     char path[MAX_NAME_LENGTH+1];
  72     char pathctl[MAX_NAME_LENGTH+4];
  73     char name[MAX_NAME_LENGTH+1];
  74     char vendor[MAX_NAME_LENGTH+1];
  75     char version[MAX_NAME_LENGTH+1];
  76     char description[MAX_NAME_LENGTH+1];
  77 } AudioDeviceDescription;
  78 
  79 int getAudioDeviceCount();
  80 
  81 /*
  82  * adPath is an array of AudioDevicePath structures
  83  * count contains initially the number of elements in adPath
  84  *       and will be set to the returned number of paths.
  85  */
  86 void getAudioDevices(AudioDevicePath* adPath, int* count);
  87 
  88 /*
  89  * fills adDesc from the audio device given in path
  90  * returns 0 if an error occurred
  91  * if getNames is 0, only path and pathctl are filled
  92  */
  93 int getAudioDeviceDescription(char* path, AudioDeviceDescription* adDesc, int getNames);
  94 int getAudioDeviceDescriptionByIndex(int index, AudioDeviceDescription* adDesc, int getNames);
  95 
  96 
  97 #endif // PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED