1 /* 2 * Copyright (c) 2002, 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 #ifndef PORTS_INCLUDED 27 #define PORTS_INCLUDED 28 29 30 #include "SoundDefs.h" 31 // for memset 32 #include <string.h> 33 #include "Configure.h" // put flags for debug msgs etc. here 34 #include "Utilities.h" 35 #include <com_sun_media_sound_PortMixer.h> 36 37 38 /* *********************** PORT TYPES (for all platforms) ******************************* */ 39 40 #define PORT_SRC_UNKNOWN (com_sun_media_sound_PortMixer_SRC_UNKNOWN) 41 #define PORT_SRC_MICROPHONE (com_sun_media_sound_PortMixer_SRC_MICROPHONE) 42 #define PORT_SRC_LINE_IN (com_sun_media_sound_PortMixer_SRC_LINE_IN) 43 #define PORT_SRC_COMPACT_DISC (com_sun_media_sound_PortMixer_SRC_COMPACT_DISC) 44 #define PORT_SRC_MASK (com_sun_media_sound_PortMixer_SRC_MASK) 45 #define PORT_DST_UNKNOWN (com_sun_media_sound_PortMixer_DST_UNKNOWN) 46 #define PORT_DST_SPEAKER (com_sun_media_sound_PortMixer_DST_SPEAKER) 47 #define PORT_DST_HEADPHONE (com_sun_media_sound_PortMixer_DST_HEADPHONE) 48 #define PORT_DST_LINE_OUT (com_sun_media_sound_PortMixer_DST_LINE_OUT) 49 #define PORT_DST_MASK (com_sun_media_sound_PortMixer_DST_MASK) 50 51 #define PORT_STRING_LENGTH 200 52 53 typedef struct tag_PortMixerDescription { 54 char name[PORT_STRING_LENGTH]; 55 char vendor[PORT_STRING_LENGTH]; 56 char description[PORT_STRING_LENGTH]; 57 char version[PORT_STRING_LENGTH]; 58 } PortMixerDescription; 59 60 61 // for BooleanControl.Type 62 #define CONTROL_TYPE_MUTE ((char*) 1) 63 #define CONTROL_TYPE_SELECT ((char*) 2) 64 65 // for FloatControl.Type 66 #define CONTROL_TYPE_BALANCE ((char*) 1) 67 #define CONTROL_TYPE_MASTER_GAIN ((char*) 2) 68 #define CONTROL_TYPE_PAN ((char*) 3) 69 #define CONTROL_TYPE_VOLUME ((char*) 4) 70 #define CONTROL_TYPE_MAX 4 71 72 // method definitions 73 74 /* controlID: unique ID for this control 75 * type: string that is used to construct the BooleanControl.Type, or CONTROL_TYPE_MUTE 76 * creator: pointer to the creator struct provided by PORT_GetControls 77 * returns an opaque pointer to the created control 78 */ 79 typedef void* (*PORT_NewBooleanControlPtr)(void* creator, void* controlID, char* type); 80 81 /* type: string that is used to construct the CompoundControl.Type 82 * controls: an array of opaque controls returned by the CreateXXXControlPtr functions 83 * controlCount: number of elements in controls 84 * creator: pointer to the creator struct provided by PORT_GetControls 85 * returns an opaque pointer to the created control 86 */ 87 typedef void* (*PORT_NewCompoundControlPtr)(void* creator, char* type, void** controls, int controlCount); 88 89 /* controlID: unique ID for this control 90 * type: string that is used to construct the FloatControl.Type, or one of 91 * CONTROL_TYPE_BALANCE, CONTROL_TYPE_MASTER_GAIN, CONTROL_TYPE_PAN, CONTROL_TYPE_VOLUME 92 * creator: pointer to the creator struct provided by PORT_GetControls 93 * returns an opaque pointer to the created control 94 */ 95 typedef void* (*PORT_NewFloatControlPtr)(void* creator, void* controlID, char* type, 96 float min, float max, float precision, const char* units); 97 98 /* control: The control to add to current port 99 * creator: pointer to the creator struct provided by PORT_GetControls 100 * returns TRUE or FALSE 101 */ 102 typedef int (*PORT_AddControlPtr)(void* creator, void* control); 103 104 // struct for dynamically instantiating the controls from platform dependent code 105 // without creating a dependency from the platform code to JNI 106 107 typedef struct tag_PortControlCreator { 108 PORT_NewBooleanControlPtr newBooleanControl; 109 PORT_NewCompoundControlPtr newCompoundControl; 110 PORT_NewFloatControlPtr newFloatControl; 111 PORT_AddControlPtr addControl; 112 } PortControlCreator; 113 114 #if (USE_PORTS == TRUE) 115 116 // the following methods need to be implemented by the platform dependent code 117 INT32 PORT_GetPortMixerCount(); 118 INT32 PORT_GetPortMixerDescription(INT32 mixerIndex, PortMixerDescription* description); 119 void* PORT_Open(INT32 mixerIndex); 120 void PORT_Close(void* id); 121 122 INT32 PORT_GetPortCount(void* id); 123 INT32 PORT_GetPortType(void* id, INT32 portIndex); 124 INT32 PORT_GetPortName(void* id, INT32 portIndex, char* name, INT32 len); 125 void PORT_GetControls(void* id, INT32 portIndex, PortControlCreator* creator); 126 float PORT_GetFloatValue(void* controlID); 127 INT32 PORT_GetIntValue(void* controlIDV); 128 void PORT_SetFloatValue(void* controlID, float value); 129 void PORT_SetIntValue(void* controlIDV, INT32 value); 130 131 #endif // USE_PORTS 132 133 #endif // PORTS_INCLUDED