home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / runnable / mmos2 / mmtoolkt / samples / audiodd / audiodat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-06  |  7.5 KB  |  141 lines

  1.  
  2. /**************************START OF SPECIFICATIONS **************************/
  3. /*                                                                          */
  4. /* SOURCE FILE NAME:  AUDIODAT.C        (TEMPLATE SAMPLE)                   */
  5. /*                                                                          */
  6. /* DISCRIPTIVE NAME: Audio device driver GLOBAL data                        */
  7. /*                                                                          */
  8. /************************** END OF SPECIFICATIONS ***************************/
  9.  
  10. #define         INCL_NOPMAPI
  11. #define         INCL_DOS
  12. #define         INCL_DOSDEVICES
  13. #define         INCL_ERRORS
  14. #include        <os2.h>
  15.  
  16. #include        <devhdr.h>              // attribute defines
  17. #include        <devcmd.h>              // device driver strategy cmds
  18. #include        <os2medef.h>
  19. #include        <ssm.h>
  20. #include        <audio.h>
  21. #include        "audiodd.h"
  22.  
  23. /****************************************************************************/
  24. /*                       E X T E R N S                                      */
  25. /****************************************************************************/
  26.  
  27. //************************
  28. // Both are in STARTUP.ASM
  29. //************************
  30. extern  Strategy();                     // IOCTL entry point
  31. extern  DDCMDEntryPoint();
  32. //extern RC FAR DDCMDEntryPoint(PVOID pCommon);
  33.                                         // Device driver command entry point
  34.  
  35. /****************************************************************************/
  36. /*                      D A T A                                             */
  37. /****************************************************************************/
  38.  
  39. //*******************************************************
  40. // Device driver header.                                *
  41. //*******************************************************
  42. DEVHDR  DevHdr = {(FPVOID) 0xFFFFFFFF,          // link (filled in by OS)
  43.                   AUDIO_ATTRIB,                 // attribute
  44.                   (NPVOID)Strategy,             // Offset of Strategy routine
  45.                   (NPVOID)DDCMDEntryPoint,      // Offset of IDC routine
  46.                   "AUDIOn$ ",                   // name where n=1-9
  47.                   "\0\0\0\0\0\0\0\0"};          // 8 bytes reserved
  48. FPVOID  DevHlp;
  49.  
  50.  
  51. GLOBAL  GlobalTable = {
  52.              NULL,                  // paStream dynamically allocated
  53.              DEFAULTSTREAMS};       // number of streams
  54.  
  55.  
  56. PROTOCOLTABLE ProtocolTable[NPROTOCOLS] =
  57.   {
  58.     { DATATYPE_MIDI,      SUBTYPE_NONE,        512L,  3, 0,     0, 0},
  59.     { DATATYPE_ADPCM_AVC, ADPCM_AVC_VOICE,  8*1024L,  3, 0,     0, 0},
  60.     { DATATYPE_ADPCM_AVC, ADPCM_AVC_MUSIC,  16*1024L, 3, 0,     0, 0},
  61.     { DATATYPE_ADPCM_AVC, ADPCM_AVC_STEREO, 16*1024L, 3, 0,     0, 0},
  62.     { DATATYPE_ADPCM_AVC, ADPCM_AVC_HQ,     32*1024L, 3, 0,     0, 0},
  63.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_1M08, 4*1024L,  3, 11025, 1, 8},
  64.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_1S08, 8*1024L,  3, 11025, 2, 8},
  65.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_1M16, 8*1024L,  4, 11025, 1, 16},
  66.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_1S16, 16*1024L, 4, 11025, 2, 16},
  67.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_2M08, 8*1024L,  3, 22050, 1, 8},
  68.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_2S08, 16*1024L, 4, 22050, 2, 8},
  69.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_2M16, 16*1024L, 4, 22050, 1, 16},
  70.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_2S16, 32*1024L, 4, 22050, 2, 16},
  71.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_4M08, 16*1024L, 4, 44100, 1, 8},
  72.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_4S08, 32*1024L, 4, 44100, 2, 8},
  73.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_4M16, 32*1024L, 4, 44100, 1, 16},
  74.     { DATATYPE_WAVEFORM,  WAVE_FORMAT_4S16, 60*1024L, 6, 44100, 2, 16},
  75.     { DATATYPE_MULAW,     MULAW_8B8KS,      60*1024L, 6, 8000,  2, 8},  /* 8k 8b Mu-Law   */
  76.     { DATATYPE_MULAW,     MULAW_8B11KS,     60*1024L, 6, 11025, 2, 8},  /* 11K            */
  77.     { DATATYPE_MULAW,     MULAW_8B22KS,     60*1024L, 6, 22050, 2, 8},  /* 22k 8b Mu-Law  */
  78.     { DATATYPE_MULAW,     MULAW_8B44KS,     60*1024L, 6, 44100, 2, 8},  /* 44k 8b Mu-Law  */
  79.     { DATATYPE_ALAW,      ALAW_8B8KS,       60*1024L, 6, 8000,  2, 8},  /* 8k 8b Mu-Law   */
  80.     { DATATYPE_ALAW,      ALAW_8B11KS,      60*1024L, 6, 11025, 2, 8},  /* 11k 8b Mu-Law  */
  81.     { DATATYPE_ALAW,      ALAW_8B22KS,      60*1024L, 6, 22050, 2, 8},  /* 22k 8b Mu-Law  */
  82.     { DATATYPE_ALAW,      ALAW_8B44KS,      60*1024L, 6, 44100, 2, 8},  /* 44k 8b Mu-Law  */
  83.     { DATATYPE_NULL,      SUBTYPE_NONE,     60*1024L, 6, 0,     2, 16}, /* Get hdwr       */
  84.     { DATATYPE_SPV2,      SPV2_BPCM,        60*1024L, 6, 14700, 2, 16}, /* SPV/2 BCPCM    */
  85.     { DATATYPE_SPV2,      SPV2_PCM,         60*1024L, 6, 14700, 2, 16}, /* SPV/2 16b PCM  */
  86.     { DATATYPE_SPV2,      SPV2_NONE,        60*1024L, 6, 0,     2, 16}, /* SPV/2 NONE BRR30*/
  87.     { DATATYPE_CDXA_AUDIO, CDXA_LEVELC,     39984L, 3, 18900, 2, 16},   /* CD ROM XA Lvl C BRR214*/
  88.     { DATATYPE_CDXA_AUDIO, CDXA_LEVELB,     39984L, 3, 37800, 2,  16},  /* CD ROM XA Lvl B BRR214*/
  89.     { DATATYPE_CDXA_AUDIO, CDXA_LEVELC_MONO,39984L, 3, 18900, 1, 16},   /* CD ROM XA Lvl C BRR214*/
  90.     { DATATYPE_CDXA_AUDIO, CDXA_LEVELB_MONO,39984L, 3, 37800, 1,  16}   /* CD ROM XA Lvl B BRR214*/
  91.   };
  92.  
  93.  
  94. //*******************************************************
  95. // IOCTL jump table                                     *
  96. // Request packet function jump table                   *
  97. //*******************************************************
  98. ULONG   (*IOCTLFuncs[])(PREQPACKET rp) = {
  99.                 IOCTL_Init,                    // 0
  100.                 IOCTL_Invalid,                 // 1
  101.                 IOCTL_Invalid,                 // 2
  102.                 IOCTL_Input,                   // 3
  103.                 IOCTL_Read,                    // 4
  104.                 IOCTL_NondestructiveRead,      // 5
  105.                 IOCTL_ReadStatus,              // 6
  106.                 IOCTL_FlushInput,              // 7
  107.                 IOCTL_Write,                   // 8
  108.                 IOCTL_Invalid,                 // 9
  109.                 IOCTL_WriteStatus,             // 10
  110.                 IOCTL_FlushOutput,             // 11
  111.                 IOCTL_Output,                  // 12
  112.                 IOCTL_Open,                    // 13
  113.                 IOCTL_Close,                   // 14
  114.                 IOCTL_Invalid,                 // 15
  115.                 IOCTL_GenIoctl                 // 16
  116.                 };
  117. USHORT  MaxIOCTLFuncs = sizeof(IOCTLFuncs)/sizeof(USHORT);
  118.  
  119. //*******************************************************
  120. // AUDIO GENERIC IOCTL jump table                       *
  121. //*******************************************************
  122. ULONG   (*AudioIOCTLFuncs[])(PVOID pParm) = {  // Generic IOCTL function table
  123.                 Audio_IOCTL_Init,                     // 0
  124.                 Audio_IOCTL_Status,                   // 1
  125.                 Audio_IOCTL_Control,                  // 2
  126.                 Audio_IOCTL_Buffer,                   // 3
  127.                 Audio_IOCTL_Load,                     // 4
  128.                 Audio_IOCTL_Wait,                     // 5
  129.                 Audio_IOCTL_Hpi                       // 6
  130.                 };
  131. USHORT  MaxAudioIOCTLFuncs = sizeof(AudioIOCTLFuncs)/sizeof(USHORT);
  132.  
  133. USHORT trk;                     // Tracks and number of supported tracks
  134.                                 // are device dependent parameters.
  135. ULONG trk_array[2];             // 2 track device
  136.  
  137. MCI_AUDIO_IOBUFFER xmitio;
  138. MCI_AUDIO_IOBUFFER recio;
  139.  
  140. USHORT  EndOfData;
  141.