| 1 | /* $Id: audiohw.cpp,v 1.1 2000/04/23 14:55:15 ktk Exp $ */
|
|---|
| 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 | /*00*/ { AUDIOHW_WAVE_PLAY, 0, DATATYPE_WAVEFORM, OPERATION_PLAY },
|
|---|
| 35 | /*01*/ { AUDIOHW_WAVE_PLAY, 0, PCM, OPERATION_PLAY },
|
|---|
| 36 | /*02*/ { AUDIOHW_WAVE_PLAY, 0, DATATYPE_ALAW, OPERATION_PLAY },
|
|---|
| 37 | /*03*/ { AUDIOHW_WAVE_PLAY, 0, DATATYPE_RIFF_ALAW, OPERATION_PLAY },
|
|---|
| 38 | /*04*/ { AUDIOHW_WAVE_PLAY, 0, A_LAW, OPERATION_PLAY },
|
|---|
| 39 | /*05*/ { AUDIOHW_WAVE_PLAY, 0, DATATYPE_MULAW, OPERATION_PLAY },
|
|---|
| 40 | /*06*/ { AUDIOHW_WAVE_PLAY, 0, DATATYPE_RIFF_MULAW, OPERATION_PLAY },
|
|---|
| 41 | /*07*/ { AUDIOHW_WAVE_PLAY, 0, MU_LAW, OPERATION_PLAY },
|
|---|
| 42 | /*08*/ { AUDIOHW_WAVE_CAPTURE, 0, DATATYPE_WAVEFORM, OPERATION_RECORD },
|
|---|
| 43 | /*09*/ { AUDIOHW_WAVE_CAPTURE, 0, PCM, OPERATION_RECORD },
|
|---|
| 44 | /*10*/ { AUDIOHW_WAVE_CAPTURE, 0, DATATYPE_ALAW, OPERATION_RECORD },
|
|---|
| 45 | /*11*/ { AUDIOHW_WAVE_CAPTURE, 0, DATATYPE_RIFF_ALAW, OPERATION_RECORD },
|
|---|
| 46 | /*12*/ { AUDIOHW_WAVE_CAPTURE, 0, A_LAW, OPERATION_RECORD },
|
|---|
| 47 | /*13*/ { AUDIOHW_WAVE_CAPTURE, 0, DATATYPE_MULAW, OPERATION_RECORD },
|
|---|
| 48 | /*14*/ { AUDIOHW_WAVE_CAPTURE, 0, DATATYPE_RIFF_MULAW, OPERATION_RECORD },
|
|---|
| 49 | /*15*/ { AUDIOHW_WAVE_CAPTURE, 0, MU_LAW, OPERATION_RECORD },
|
|---|
| 50 | /*16*/ { AUDIOHW_WAVE_PLAY, 0, DATATYPE_AC3, OPERATION_PLAY },
|
|---|
| 51 | /*17*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 52 | /*18*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 53 | /*19*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 54 | /*20*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 55 | /*21*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 56 | /*22*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 57 | /*23*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 58 | /*24*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 59 | /*25*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 60 | /*26*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 61 | /*27*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 62 | /*28*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 63 | /*29*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 64 | /*30*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 },
|
|---|
| 65 | /*31*/ { AUDIOHW_INVALID_DEVICE, -1, -1, -1 }
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | /**@internal GetHardwareDevice
|
|---|
| 69 | * @param USHORT the device type being queried (see audiohw.hpp)
|
|---|
| 70 | * @return PAUDIOHW the address of the correct hardware object
|
|---|
| 71 | * @return NULL ERROR hardware object not found
|
|---|
| 72 | * @notes
|
|---|
| 73 | * Globally scoped function to get the address of a hardware object based on
|
|---|
| 74 | * the type.
|
|---|
| 75 | */
|
|---|
| 76 | PAUDIOHW GetHardwareDevice(USHORT Devicetype)
|
|---|
| 77 | {
|
|---|
| 78 | PAUDIOHW pEle = (PAUDIOHW)pAudioHWList->Head();
|
|---|
| 79 | while (pEle != NULL) {
|
|---|
| 80 | if (pEle->usDeviceType == Devicetype)
|
|---|
| 81 | return(pEle);
|
|---|
| 82 | pEle = (PAUDIOHW)pEle->pNext;
|
|---|
| 83 | } /* endwhile */
|
|---|
| 84 | return(NULL);
|
|---|
| 85 | }
|
|---|
| 86 | /**@internal SetHardwareType
|
|---|
| 87 | * @param USHORT
|
|---|
| 88 | * @param USHORT
|
|---|
| 89 | * @param USHORT
|
|---|
| 90 | * @return No return value
|
|---|
| 91 | * @notes
|
|---|
| 92 | * Globally scoped function
|
|---|
| 93 | *
|
|---|
| 94 | */
|
|---|
| 95 | void SetHardwareType(USHORT HardwareType, USHORT DataType, USHORT Operation, USHORT LDev)
|
|---|
| 96 | {
|
|---|
| 97 | int i;
|
|---|
| 98 |
|
|---|
| 99 | for (i = 0;
|
|---|
| 100 | ((i < NUM_HARDWARE_DEVICE_TYPES) &&
|
|---|
| 101 | (HardwareArray[i].DeviceType != AUDIOHW_INVALID_DEVICE)); ++ i) {
|
|---|
| 102 | if ((HardwareArray[i].DeviceDataType == DataType) &&
|
|---|
| 103 | (HardwareArray[i].DeviceOperation == Operation) &&
|
|---|
| 104 | (HardwareArray[i].LogicalDevice == LDev))
|
|---|
| 105 | break;
|
|---|
| 106 | } /* endfor */
|
|---|
| 107 | // if i is not pointing to the last entry in the table then either we
|
|---|
| 108 | // are either pointing to an empty table entry or one that we want
|
|---|
| 109 | // to change. like the midi entries......
|
|---|
| 110 | //
|
|---|
| 111 | if (i < (NUM_HARDWARE_DEVICE_TYPES - 1)) { // not at last entry
|
|---|
| 112 | HardwareArray[i].DeviceType = HardwareType;
|
|---|
| 113 | HardwareArray[i].LogicalDevice = LDev;
|
|---|
| 114 | HardwareArray[i].DeviceDataType = DataType;
|
|---|
| 115 | HardwareArray[i].DeviceOperation = Operation;
|
|---|
| 116 | // HardwareArray[i + 1].DeviceType = AUDIOHW_INVALID_DEVICE;
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 | /**@internal GetHardwareType
|
|---|
| 120 | * @param USHORT
|
|---|
| 121 | * @param USHORT
|
|---|
| 122 | * @return USHORT
|
|---|
| 123 | * @return AUDIOHW_INVALID_DEVICE if not found
|
|---|
| 124 | * @notes
|
|---|
| 125 | * Globally scoped function
|
|---|
| 126 | *
|
|---|
| 127 | */
|
|---|
| 128 | USHORT GetHardwareType(USHORT DataType, USHORT Operation, USHORT LDev)
|
|---|
| 129 | {
|
|---|
| 130 | int i;
|
|---|
| 131 |
|
|---|
| 132 | for (i = 0;
|
|---|
| 133 | ((i < NUM_HARDWARE_DEVICE_TYPES) &&
|
|---|
| 134 | (HardwareArray[i].DeviceType != AUDIOHW_INVALID_DEVICE)); ++ i) {
|
|---|
| 135 | if ((HardwareArray[i].DeviceDataType == DataType) &&
|
|---|
| 136 | (HardwareArray[i].DeviceOperation == Operation) &&
|
|---|
| 137 | (HardwareArray[i].LogicalDevice == LDev))
|
|---|
| 138 | break;
|
|---|
| 139 | } /* endfor */
|
|---|
| 140 | return (HardwareArray[i].DeviceType);
|
|---|
| 141 |
|
|---|
| 142 | }
|
|---|