J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2002-2007 Sun Microsystems, Inc. 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. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any 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 | #include <stropts.h> |
| 35 | #include <sys/conf.h> |
| 36 | #include <sys/stat.h> |
| 37 | #include <unistd.h> |
| 38 | |
| 39 | #ifndef PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED |
| 40 | #define PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED |
| 41 | |
| 42 | /* defines for Solaris 2.7 |
| 43 | #ifndef AUDIO_AUX1_OUT |
| 44 | #define AUDIO_AUX1_OUT (0x08) // output to aux1 out |
| 45 | #define AUDIO_AUX2_OUT (0x10) // output to aux2 out |
| 46 | #define AUDIO_SPDIF_OUT (0x20) // output to SPDIF port |
| 47 | #define AUDIO_AUX1_IN (0x08) // input from aux1 in |
| 48 | #define AUDIO_AUX2_IN (0x10) // input from aux2 in |
| 49 | #define AUDIO_SPDIF_IN (0x20) // input from SPDIF port |
| 50 | #endif |
| 51 | */ |
| 52 | |
| 53 | /* input from Codec inter. loopback */ |
| 54 | #ifndef AUDIO_CODEC_LOOPB_IN |
| 55 | #define AUDIO_CODEC_LOOPB_IN (0x40) |
| 56 | #endif |
| 57 | |
| 58 | |
| 59 | #define MAX_NAME_LENGTH 300 |
| 60 | |
| 61 | typedef struct tag_AudioDevicePath { |
| 62 | char path[MAX_NAME_LENGTH]; |
| 63 | ino_t st_ino; // inode number to detect duplicate devices |
| 64 | dev_t st_dev; // device ID to detect duplicate audio devices |
| 65 | } AudioDevicePath; |
| 66 | |
| 67 | typedef struct tag_AudioDeviceDescription { |
| 68 | INT32 maxSimulLines; |
| 69 | char path[MAX_NAME_LENGTH+1]; |
| 70 | char pathctl[MAX_NAME_LENGTH+4]; |
| 71 | char name[MAX_NAME_LENGTH+1]; |
| 72 | char vendor[MAX_NAME_LENGTH+1]; |
| 73 | char version[MAX_NAME_LENGTH+1]; |
| 74 | char description[MAX_NAME_LENGTH+1]; |
| 75 | } AudioDeviceDescription; |
| 76 | |
| 77 | int getAudioDeviceCount(); |
| 78 | |
| 79 | /* |
| 80 | * adPath is an array of AudioDevicePath structures |
| 81 | * count contains initially the number of elements in adPath |
| 82 | * and will be set to the returned number of paths. |
| 83 | */ |
| 84 | void getAudioDevices(AudioDevicePath* adPath, int* count); |
| 85 | |
| 86 | /* |
| 87 | * fills adDesc from the audio device given in path |
| 88 | * returns 0 if an error occured |
| 89 | * if getNames is 0, only path and pathctl are filled |
| 90 | */ |
| 91 | int getAudioDeviceDescription(char* path, AudioDeviceDescription* adDesc, int getNames); |
| 92 | int getAudioDeviceDescriptionByIndex(int index, AudioDeviceDescription* adDesc, int getNames); |
| 93 | |
| 94 | |
| 95 | #endif // PLATFORM_API_SOLARISOS_UTILS_H_INCLUDED |