home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cset21v6.zip / MMPM2TK / TK / MCDTEMP / MCDOPEN.C < prev    next >
C/C++ Source or Header  |  1993-03-22  |  8KB  |  150 lines

  1. /****************************************************************************/
  2. /*                                                                          */
  3. /* SOURCE FILE NAME:  MCDOPEN.C                                             */
  4. /*                                                                          */
  5. /* DESCRIPTIVE NAME:  MCI_OPEN MESSAGE HANDLER                              */
  6. /*                                                                          */
  7. /* COPYRIGHT:  (c) IBM Corp. 1991 - 1993                                    */
  8. /*                                                                          */
  9. /* FUNCTION:  This file contains routines to handle the MCI_OPEN message.   */
  10. /*            The processing of this message show allocate the instance     */
  11. /*            structure and initialize it but NOT make it active.  The      */
  12. /*            MCIDRV_RESTORE message will make it active.                   */
  13. /*                                                                          */
  14. /* ENTRY POINTS:                                                            */
  15. /*       MCIOpen() - MCI_OPEN message handler                               */
  16. /*       MCIOpenErr() - Error handler for MCI_OPEN message                  */
  17. /****************************************************************************/
  18. #define INCL_BASE                    // Base OS2 functions
  19. #define INCL_DOSSEMAPHORES           // OS2 Semaphore function
  20. #define INCL_MCIOS2                  // use the OS/2 like MMPM/2 headers
  21.  
  22. #include <os2.h>                     // OS2 defines.
  23. #include <string.h>                  // C string functions
  24. #include <os2me.h>                   // MME includes files.
  25. #include <stdlib.h>                  // Math functions
  26. #include "mcdtemp.h"                 // Function Prototypes.
  27.  
  28.  
  29. /****************************************************************************/
  30. /*                                                                          */
  31. /* SUBROUTINE NAME:  MCIOpen                                                */
  32. /*                                                                          */
  33. /* DESCRIPTIVE NAME:  MCI_OPEN message processor                            */
  34. /*                                                                          */
  35. /* FUNCTION:  Process the MCI_OPEN message.                                 */
  36. /*                                                                          */
  37. /* PARAMETERS:                                                              */
  38. /*      FUNCTION_PARM_BLOCK  *pFuncBlock -- Pointer to function parameter   */
  39. /*                                          block.                          */
  40. /* EXIT CODES:                                                              */
  41. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  42. /*            .                                                             */
  43. /*            .                                                             */
  44. /*            .                                                             */
  45. /*            .                                                             */
  46. /*                                                                          */
  47. /****************************************************************************/
  48. RC MCIOpen (FUNCTION_PARM_BLOCK *pFuncBlock)
  49. {
  50.   ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  51.   ULONG                ulParam1;                 // Message flags
  52.   PMCI_INFO_PARMS      pInfoParms;               // Pointer to info structure
  53.   PMMDRV_OPEN_PARMS    pDrvOpenParms;            // Pointer to MMDRV_OPEN structure
  54.   PINSTANCE            pInstance;                // Pointer to instance
  55.  
  56.   /*****************************************************/
  57.   /* dereference the values from pFuncBlock            */
  58.   /*****************************************************/
  59.   ulParam1       = pFuncBlock->ulParam1;
  60.   pDrvOpenParms  = (PMMDRV_OPEN_PARMS)pFuncBlock->pParam2;
  61.  
  62.   /*******************************************************************/
  63.   /* Allocate and initialize the instance structure                  */
  64.   /*******************************************************************/
  65.   if (!(pInstance = malloc(sizeof(INSTANCE))))
  66.      ulrc = MCIERR_OUT_OF_MEMORY;
  67.   else
  68.      {
  69.      if (DosCreateMutexSem(NULL,&(pInstance->hmtxAccessSem),DC_SEM_SHARED,FALSE))
  70.         ulrc = MCIERR_DRIVER_INTERNAL;
  71.  
  72.      if (!ulrc)
  73.         {
  74.         /*******************************************************************/
  75.         /* Set up default values in instance structure.                    */
  76.         /*  NOTE this is a minimal instance structure                      */
  77.         /*******************************************************************/
  78.         memset(pInstance, 0, sizeof(INSTANCE));
  79.         pInstance->usDeviceID = pDrvOpenParms->usDeviceID;
  80.         pInstance->ulTimeFormat = MCI_FORMAT_MMTIME;
  81.         pInstance->ulSpeedFormat = MCI_FORMAT_PERCENTAGE;
  82.         pInstance->ulState = MCD_MODE_OPENING;
  83.         pInstance->ulMode = MCI_MODE_NOT_READY;
  84.         pInstance->Active = FALSE;
  85.         pInstance->ulVolume = 75L;
  86.         pInstance->ulMasterVolume = -1L;
  87.         pInstance->Speaker = TRUE;
  88.         pInstance->Headphone = TRUE;
  89.         pInstance->usDeviceType = pDrvOpenParms->usDeviceType;
  90.         pInstance->usDeviceOrd = pDrvOpenParms->usDeviceOrd;
  91.         memcpy(pDrvOpenParms->pDevParm, pInstance->szDevParams, MAX_DEV_PARAMS);
  92.         pDrvOpenParms->pInstance = pInstance;
  93.         pDrvOpenParms->usResourceUnitsRequired = 1;
  94.         pDrvOpenParms->usResourceClass = 1;
  95.         GetINIInstallName(pInstance);
  96.         GetDeviceInfo(pInstance);
  97.         }
  98.      }
  99.  
  100.  
  101.   return (ulrc);
  102.  
  103. }      /* end of MCIOpen */
  104.  
  105.  
  106. /****************************************************************************/
  107. /*                                                                          */
  108. /* SUBROUTINE NAME:  MCIOpenErr                                             */
  109. /*                                                                          */
  110. /* DESCRIPTIVE NAME:  MCI_OPEN message processor for errors                 */
  111. /*                                                                          */
  112. /* FUNCTION:  Process the MCI_OPEN message for errors                       */
  113. /*                                                                          */
  114. /* PARAMETERS:                                                              */
  115. /*      FUNCTION_PARM_BLOCK  *pFuncBlock -- Pointer to function parameter   */
  116. /*                                          block.                          */
  117. /* EXIT CODES:                                                              */
  118. /*      MCIERR_SUCCESS    -- Action completed without error.                */
  119. /*            .                                                             */
  120. /*            .                                                             */
  121. /*            .                                                             */
  122. /*            .                                                             */
  123. /*                                                                          */
  124. /****************************************************************************/
  125. RC MCIOpenErr (FUNCTION_PARM_BLOCK *pFuncBlock)
  126. {
  127.   ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  128.   ULONG                ulParam1;                 // Message flags
  129.   PMCI_INFO_PARMS      pInfoParms;               // Pointer to info structure
  130.   PMMDRV_OPEN_PARMS    pDrvOpenParms;            // Pointer to MMDRV_OPEN structure
  131.   PINSTANCE            pInstance;                // Pointer to instance
  132.  
  133.   /*****************************************************/
  134.   /* dereference the values from pFuncBlock            */
  135.   /*****************************************************/
  136.   ulParam1       = pFuncBlock->ulParam1;
  137.   pDrvOpenParms  = (PMMDRV_OPEN_PARMS)pFuncBlock->pParam2;
  138.  
  139.   /*******************************************************/
  140.   /* Validate that we have only valid flags              */
  141.   /*******************************************************/
  142.   if (ulParam1 & ~(MCIOPENVALIDFLAGS))
  143.      return(MCIERR_INVALID_FLAG);
  144.  
  145.  
  146.   return (ulrc);
  147.  
  148. }      /* end of MCIOpenErr */
  149.  
  150.