[142] | 1 | /* $Id: audiohw.cpp 142 2000-04-23 14:55:46Z ktk $ */
|
---|
| 2 |
|
---|
| 3 | /* SCCSID = %W% %E% */
|
---|
| 4 | /****************************************************************************
|
---|
| 5 | * *
|
---|
| 6 | * Copyright (c) IBM Corporation 1994 - 1997. *
|
---|
| 7 | * *
|
---|
| 8 | * The following IBM OS/2 source code is provided to you solely for the *
|
---|
| 9 | * the purpose of assisting you in your development of OS/2 device drivers. *
|
---|
| 10 | * You may use this code in accordance with the IBM License Agreement *
|
---|
| 11 | * provided in the IBM Device Driver Source Kit for OS/2. *
|
---|
| 12 | * *
|
---|
| 13 | ****************************************************************************/
|
---|
| 14 | /**@internal %W%
|
---|
| 15 | * @notes
|
---|
| 16 | * Parent audio hardware class all audio hardware objects will be decendents
|
---|
| 17 | * of this class
|
---|
| 18 | * @version %I%
|
---|
| 19 | * @context Unless otherwise noted, all interfaces are Ring-0, 16-bit,
|
---|
| 20 | * <stack context>.
|
---|
| 21 | * @history
|
---|
| 22 | *
|
---|
| 23 | */
|
---|
| 24 | #define INCL_NOPMAPI
|
---|
| 25 | #include <os2.h>
|
---|
| 26 | #include <os2medef.h>
|
---|
| 27 | #include <audio.h>
|
---|
| 28 | #include <include.h>
|
---|
| 29 | #include "audiohw.hpp"
|
---|
| 30 |
|
---|
| 31 | PQUEUEHEAD pAudioHWList; // Queuehead for all audio HW objects created
|
---|
| 32 | // during driver initialization.
|
---|
| 33 | hardware_index HardwareArray[NUM_HARDWARE_DEVICE_TYPES] = {
|
---|
| 34 | {
|
---|
| 35 | AUDIOHW_WAVE_PLAY,
|
---|
| 36 | 0,
|
---|
| 37 | DATATYPE_WAVEFORM,
|
---|
| 38 | OPERATION_PLAY
|
---|
| 39 | },
|
---|
| 40 | {
|
---|
| 41 | AUDIOHW_WAVE_PLAY,
|
---|
| 42 | 0,
|
---|
| 43 | PCM,
|
---|
| 44 | OPERATION_PLAY
|
---|
| 45 | },
|
---|
| 46 | {
|
---|
| 47 | AUDIOHW_WAVE_PLAY,
|
---|
| 48 | 0,
|
---|
| 49 | DATATYPE_ALAW,
|
---|
| 50 | OPERATION_PLAY
|
---|
| 51 | },
|
---|
| 52 | {
|
---|
| 53 | AUDIOHW_WAVE_PLAY,
|
---|
| 54 | 0,
|
---|
| 55 | DATATYPE_RIFF_ALAW,
|
---|
| 56 | OPERATION_PLAY
|
---|
| 57 | },
|
---|
| 58 | {
|
---|
| 59 | AUDIOHW_WAVE_PLAY,
|
---|
| 60 | 0,
|
---|
| 61 | A_LAW,
|
---|
| 62 | OPERATION_PLAY
|
---|
| 63 | },
|
---|
| 64 | {
|
---|
| 65 | AUDIOHW_WAVE_PLAY,
|
---|
| 66 | 0,
|
---|
| 67 | DATATYPE_MULAW,
|
---|
| 68 | OPERATION_PLAY
|
---|
| 69 | },
|
---|
| 70 | {
|
---|
| 71 | AUDIOHW_WAVE_PLAY,
|
---|
| 72 | 0,
|
---|
| 73 | DATATYPE_RIFF_MULAW,
|
---|
| 74 | OPERATION_PLAY
|
---|
| 75 | },
|
---|
| 76 | {
|
---|
| 77 | AUDIOHW_WAVE_PLAY,
|
---|
| 78 | 0,
|
---|
| 79 | MU_LAW,
|
---|
| 80 | OPERATION_PLAY
|
---|
| 81 | },
|
---|
| 82 | {
|
---|
| 83 | AUDIOHW_WAVE_CAPTURE,
|
---|
| 84 | 0,
|
---|
| 85 | DATATYPE_WAVEFORM,
|
---|
| 86 | OPERATION_RECORD
|
---|
| 87 | },
|
---|
| 88 | {
|
---|
| 89 | AUDIOHW_WAVE_CAPTURE,
|
---|
| 90 | 0,
|
---|
| 91 | PCM,
|
---|
| 92 | OPERATION_RECORD
|
---|
| 93 | },
|
---|
| 94 | {
|
---|
| 95 | AUDIOHW_WAVE_CAPTURE,
|
---|
| 96 | 0,
|
---|
| 97 | DATATYPE_ALAW,
|
---|
| 98 | OPERATION_RECORD
|
---|
| 99 | },
|
---|
| 100 | {
|
---|
| 101 | AUDIOHW_WAVE_CAPTURE,
|
---|
| 102 | 0,
|
---|
| 103 | DATATYPE_RIFF_ALAW,
|
---|
| 104 | OPERATION_RECORD
|
---|
| 105 | },
|
---|
| 106 | {
|
---|
| 107 | AUDIOHW_WAVE_CAPTURE,
|
---|
| 108 | 0,
|
---|
| 109 | A_LAW,
|
---|
| 110 | OPERATION_RECORD
|
---|
| 111 | },
|
---|
| 112 | {
|
---|
| 113 | AUDIOHW_WAVE_CAPTURE,
|
---|
| 114 | 0,
|
---|
| 115 | DATATYPE_MULAW,
|
---|
| 116 | OPERATION_RECORD
|
---|
| 117 | },
|
---|
| 118 | {
|
---|
| 119 | AUDIOHW_WAVE_CAPTURE,
|
---|
| 120 | 0,
|
---|
| 121 | DATATYPE_RIFF_MULAW,
|
---|
| 122 | OPERATION_RECORD
|
---|
| 123 | },
|
---|
| 124 | {
|
---|
| 125 | AUDIOHW_WAVE_CAPTURE,
|
---|
| 126 | 0,
|
---|
| 127 | MU_LAW,
|
---|
| 128 | OPERATION_RECORD
|
---|
| 129 | },
|
---|
| 130 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 131 | AUDIOHW_INVALID_DEVICE,
|
---|
| 132 | -1,
|
---|
| 133 | -1,
|
---|
| 134 | -1
|
---|
| 135 | },
|
---|
| 136 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 137 | AUDIOHW_INVALID_DEVICE,
|
---|
| 138 | -1,
|
---|
| 139 | -1,
|
---|
| 140 | -1
|
---|
| 141 | },
|
---|
| 142 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 143 | AUDIOHW_INVALID_DEVICE,
|
---|
| 144 | -1,
|
---|
| 145 | -1,
|
---|
| 146 | -1
|
---|
| 147 | },
|
---|
| 148 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 149 | AUDIOHW_INVALID_DEVICE,
|
---|
| 150 | -1,
|
---|
| 151 | -1,
|
---|
| 152 | -1
|
---|
| 153 | },
|
---|
| 154 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 155 | AUDIOHW_INVALID_DEVICE,
|
---|
| 156 | -1,
|
---|
| 157 | -1,
|
---|
| 158 | -1
|
---|
| 159 | },
|
---|
| 160 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 161 | AUDIOHW_INVALID_DEVICE,
|
---|
| 162 | -1,
|
---|
| 163 | -1,
|
---|
| 164 | -1
|
---|
| 165 | },
|
---|
| 166 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 167 | AUDIOHW_INVALID_DEVICE,
|
---|
| 168 | -1,
|
---|
| 169 | -1,
|
---|
| 170 | -1
|
---|
| 171 | },
|
---|
| 172 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 173 | AUDIOHW_INVALID_DEVICE,
|
---|
| 174 | -1,
|
---|
| 175 | -1,
|
---|
| 176 | -1
|
---|
| 177 | },
|
---|
| 178 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 179 | AUDIOHW_INVALID_DEVICE,
|
---|
| 180 | -1,
|
---|
| 181 | -1,
|
---|
| 182 | -1
|
---|
| 183 | },
|
---|
| 184 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 185 | AUDIOHW_INVALID_DEVICE,
|
---|
| 186 | -1,
|
---|
| 187 | -1,
|
---|
| 188 | -1
|
---|
| 189 | },
|
---|
| 190 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 191 | AUDIOHW_INVALID_DEVICE,
|
---|
| 192 | -1,
|
---|
| 193 | -1,
|
---|
| 194 | -1
|
---|
| 195 | },
|
---|
| 196 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 197 | AUDIOHW_INVALID_DEVICE,
|
---|
| 198 | -1,
|
---|
| 199 | -1,
|
---|
| 200 | -1
|
---|
| 201 | },
|
---|
| 202 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 203 | AUDIOHW_INVALID_DEVICE,
|
---|
| 204 | -1,
|
---|
| 205 | -1,
|
---|
| 206 | -1
|
---|
| 207 | },
|
---|
| 208 | { // Last device is marked as AUDIOHW_INVALID_DEVICE
|
---|
| 209 | AUDIOHW_INVALID_DEVICE,
|
---|
| 210 | -1,
|
---|
| 211 | -1,
|
---|
| 212 | -1
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | };
|
---|
| 216 |
|
---|
| 217 | /**@internal GetHardwareDevice
|
---|
| 218 | * @param ULONG the device type being queried (see audiohw.hpp)
|
---|
| 219 | * @return PAUDIOHW the address of the correct hardware object
|
---|
| 220 | * @return NULL ERROR hardware object not found
|
---|
| 221 | * @notes
|
---|
| 222 | * Globally scoped function to get the address of a hardware object based on
|
---|
| 223 | * the type.
|
---|
| 224 | */
|
---|
| 225 | PAUDIOHW GetHardwareDevice(ULONG Devicetype)
|
---|
| 226 | {
|
---|
| 227 | PAUDIOHW pEle = (PAUDIOHW)pAudioHWList->Head();
|
---|
| 228 | while (pEle != NULL) {
|
---|
| 229 | if (pEle->ulDeviceType == Devicetype)
|
---|
| 230 | return(pEle);
|
---|
| 231 | pEle = (PAUDIOHW)pEle->pNext;
|
---|
| 232 | } /* endwhile */
|
---|
| 233 | return(NULL);
|
---|
| 234 | }
|
---|
| 235 | /**@internal SetHardwareType
|
---|
| 236 | * @param ULONG
|
---|
| 237 | * @param USHORT
|
---|
| 238 | * @param USHORT
|
---|
| 239 | * @return No return value
|
---|
| 240 | * @notes
|
---|
| 241 | * Globally scoped function
|
---|
| 242 | *
|
---|
| 243 | */
|
---|
| 244 | void SetHardwareType(ULONG HardwareType, USHORT DataType, USHORT Operation, USHORT LDev)
|
---|
| 245 | {
|
---|
| 246 | int i;
|
---|
| 247 |
|
---|
| 248 | for (i = 0;
|
---|
| 249 | ((i < NUM_HARDWARE_DEVICE_TYPES) &&
|
---|
| 250 | (HardwareArray[i].DeviceType != AUDIOHW_INVALID_DEVICE)); ++ i) {
|
---|
| 251 | if ((HardwareArray[i].DeviceDataType == DataType) &&
|
---|
| 252 | (HardwareArray[i].DeviceOperation == Operation) &&
|
---|
| 253 | (HardwareArray[i].LogicalDevice == LDev))
|
---|
| 254 | break;
|
---|
| 255 | } /* endfor */
|
---|
| 256 | // if i is not pointing to the last entry in the table then either we
|
---|
| 257 | // are either pointing to an empty table entry or one that we want
|
---|
| 258 | // to change. like the midi entries......
|
---|
| 259 | //
|
---|
| 260 | if (i < (NUM_HARDWARE_DEVICE_TYPES - 1)) { // not at last entry
|
---|
| 261 | HardwareArray[i].DeviceType = HardwareType;
|
---|
| 262 | HardwareArray[i].LogicalDevice = LDev;
|
---|
| 263 | HardwareArray[i].DeviceDataType = DataType;
|
---|
| 264 | HardwareArray[i].DeviceOperation = Operation;
|
---|
| 265 | HardwareArray[i + 1].DeviceType = AUDIOHW_INVALID_DEVICE;
|
---|
| 266 | }
|
---|
| 267 | }
|
---|
| 268 | /**@internal GetHardwareType
|
---|
| 269 | * @param USHORT
|
---|
| 270 | * @param USHORT
|
---|
| 271 | * @return ULONG
|
---|
| 272 | * @return AUDIOHW_INVALID_DEVICE if not found
|
---|
| 273 | * @notes
|
---|
| 274 | * Globally scoped function
|
---|
| 275 | *
|
---|
| 276 | */
|
---|
| 277 | ULONG GetHardwareType(USHORT DataType, USHORT Operation, USHORT LDev)
|
---|
| 278 | {
|
---|
| 279 | int i;
|
---|
| 280 |
|
---|
| 281 | for (i = 0;
|
---|
| 282 | ((i < NUM_HARDWARE_DEVICE_TYPES) &&
|
---|
| 283 | (HardwareArray[i].DeviceType != AUDIOHW_INVALID_DEVICE)); ++ i) {
|
---|
| 284 | if ((HardwareArray[i].DeviceDataType == DataType) &&
|
---|
| 285 | (HardwareArray[i].DeviceOperation == Operation) &&
|
---|
| 286 | (HardwareArray[i].LogicalDevice == LDev))
|
---|
| 287 | break;
|
---|
| 288 | } /* endfor */
|
---|
| 289 | return (HardwareArray[i].DeviceType);
|
---|
| 290 |
|
---|
| 291 | }
|
---|