home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / mm / mcdtemp / mcdproc.c < prev    next >
C/C++ Source or Header  |  1999-05-11  |  7KB  |  187 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* SOURCE FILE NAME:  MCDPROC.C                                             */
  4. /*                                                                          */
  5. /* DESCRIPTIVE NAME:  MCD TEMPLATE MAIN PROCEDURE                           */
  6. /*                                                                          */
  7. /* COPYRIGHT:  (c) IBM Corp. 1991 - 1993                                    */
  8. /*                                                                          */
  9. /* FUNCTION:  This file contains the main procedure for the MCD template.   */
  10. /*                                                                          */
  11. /* NOTES:  For specific streaming or MMIO samples see the CD audio and      */
  12. /*         waveform audio samples in the toolkit.  See the programming      */
  13. /*         reference and programming guide for more details on MCDs and     */
  14. /*         MCI messages and structures.                                     */
  15. /*                                                                          */
  16. /* ENTRY POINTS:                                                            */
  17. /*       mciDriverEntry - performs component specific messages of this MCI  */
  18. /*                        Driver.                                           */
  19. /*                                                                          */
  20. /****************************************************************************/
  21. #define INCL_BASE
  22. #define INCL_DOSMODULEMGR
  23. #define INCL_DOSSEMAPHORES
  24.  
  25.  
  26. #define INCL_MCIOS2                  // use the OS/2 like MMPM/2 headers
  27.  
  28. #include <os2.h>                     // OS2 defines.
  29. #include <string.h>                  // string prototypes
  30. #include <stdlib.h>                  // standard C functions
  31. #include <os2me.h>                   // MME includes files.
  32. #include "mcdtemp.h"                 // MCD Function Prototypes and typedefs
  33.  
  34.  
  35. /****************************************************************************/
  36. /*                                                                          */
  37. /* SUBROUTINE NAME:  mciDriverEntry                                         */
  38. /*                                                                          */
  39. /* DESCRIPTIVE NAME:  MCI Driver Entry                                      */
  40. /*                                                                          */
  41. /* FUNCTION:  Processes the MCI messages sent from MDM..                    */
  42. /*                                                                          */
  43. /* PARAMETERS:                                                              */
  44. /*      PVOID  lpInstance -- Pointer to device handle.                      */
  45. /*      USHORT usMessage  -- Command message.                               */
  46. /*      ULONG  ulParam1   -- Flag for this message.                         */
  47. /*      PVOID  pParam2    -- Pointer to data record structure.              */
  48. /*      USHORT usUserParm -- User Parameter for mciDriverNotify.            */
  49. /*                                                                          */
  50. /* EXIT CODES:                                                              */
  51. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  52. /*            .                                                             */
  53. /*            .                                                             */
  54. /*            .                                                             */
  55. /*            .                                                             */
  56. /*                                                                          */
  57. /****************************************************************************/
  58.  
  59. /* This MCI driver is compiled with optlink linkage in C-SET/2
  60.    The following pragma allows other dll's etc to call in */
  61.  
  62. #pragma linkage(mciDriverEntry, system )
  63.  
  64. ULONG APIENTRY mciDriverEntry(PVOID pInstance,
  65.                               USHORT usMessage,
  66.                               ULONG ulParam1,
  67.                               PVOID pParam2,
  68.                               USHORT usUserParm)
  69.  
  70.  
  71. {
  72.   ULONG                   ulrc;                // Return Code
  73.   FUNCTION_PARM_BLOCK     ParamBlock;          // Encapsulate Parameters
  74.  
  75.   /***********************************************/
  76.   /* Copy the mciDriverEntry parameters to a     */
  77.   /* structure which contains all of them.  This */
  78.   /* simplifies calling functions etc. since we  */
  79.   /* can pass one parameter rather than 5 or 6.  */
  80.   /***********************************************/
  81.  
  82.   ParamBlock.usMessage    = usMessage;
  83.   ParamBlock.pInstance    = (PINSTANCE)pInstance;
  84.   ParamBlock.usUserParm   = usUserParm;
  85.   ParamBlock.ulParam1     = ulParam1;
  86.   ParamBlock.pParam2      = (PVOID)pParam2;
  87.  
  88.   /***********************************************/
  89.   /* Switch based on the MCI message.            */
  90.   /* For each message perform error checking and */
  91.   /* then message processing.                    */
  92.   /*                                             */
  93.   /***********************************************/
  94.   switch (usMessage)
  95.     {
  96.  
  97.     case MCI_OPEN:
  98.       ulrc = MCIOpenErr(&ParamBlock);
  99.       if (!ulrc)
  100.          ulrc = MCIOpen(&ParamBlock);
  101.      break;
  102.  
  103.     case MCI_CLOSE:
  104.       ulrc = MCICloseErr(&ParamBlock);
  105.       if (!ulrc)
  106.          ulrc = MCIClose(&ParamBlock);
  107.      break;
  108.  
  109.     case MCIDRV_SAVE:
  110.       ulrc = MCIDRVSaveErr(&ParamBlock);
  111.       if (!ulrc)
  112.          ulrc = MCIDRVSave(&ParamBlock);
  113.      break;
  114.  
  115.     case MCIDRV_RESTORE:
  116.       ulrc = MCIDRVRestoreErr(&ParamBlock);
  117.       if (!ulrc)
  118.          ulrc = MCIDRVRestore(&ParamBlock);
  119.      break;
  120.  
  121.     case MCI_STATUS:
  122.       ulrc = MCIStatusErr(&ParamBlock);
  123.       if (!ulrc)
  124.          ulrc = MCIStatus(&ParamBlock);
  125.      break;
  126.  
  127.     case MCI_INFO:
  128.       ulrc = MCIInfoErr(&ParamBlock);
  129.       if (!ulrc)
  130.          ulrc = MCIInfo(&ParamBlock);
  131.      break;
  132.  
  133.     case MCI_ESCAPE:
  134.     case MCI_PLAY:
  135.     case MCI_SEEK:
  136.     case MCI_STOP:
  137.     case MCI_PAUSE:
  138.     case MCI_GETDEVCAPS:
  139.     case MCI_SPIN:
  140.     case MCI_SET:
  141.     case MCI_STEP:
  142.     case MCI_RECORD:
  143.     case MCI_SAVE:
  144.     case MCI_CUE:
  145.     case MCI_UPDATE:
  146.     case MCI_SET_CUEPOINT:
  147.     case MCI_SET_POSITION_ADVISE:
  148.     case MCI_SET_SYNC_OFFSET:
  149.     case MCI_LOAD:
  150.     case MCI_MASTERAUDIO:
  151.     case MCI_GETTOC:
  152.     case MCI_DEVICESETTINGS:
  153.     case MCI_CONNECTOR:
  154.     case MCI_RESUME:
  155.     case MCI_CONNECTORINFO:
  156.     case MCI_CONNECTION:
  157.     case MCI_CAPTURE:
  158.     case MCI_FREEZE:
  159.     case MCI_GETIMAGEBUFFER:
  160.     case MCI_GETIMAGEPALETTE:
  161.     case MCI_PUT:
  162.     case MCI_REALIZE:
  163.     case MCI_REWIND:
  164.     case MCI_RESTORE:
  165.     case MCI_SETIMAGEBUFFER:
  166.     case MCI_SETIMAGEPALETTE:
  167.     case MCI_UNFREEZE:
  168.     case MCI_WHERE:
  169.     case MCI_WINDOW:
  170.     case MCI_DELETE:
  171.     case MCI_CUT:
  172.     case MCI_PASTE:
  173.     case MCI_COPY:
  174.     case MCI_REDO:
  175.     case MCI_UNDO:
  176.     default:
  177.       ulrc = MCIERR_UNRECOGNIZED_COMMAND;
  178.       break;
  179.  
  180.  
  181.     }   /* Switch */
  182.  
  183.  
  184.   return (ulrc);    /* Return to MDM */
  185.  
  186. } /* mciDriverEntry */
  187.