home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mmpm21tk.zip / TK / ADMCT / ADMCCAP.C next >
C/C++ Source or Header  |  1993-04-05  |  11KB  |  327 lines

  1. /****************************************************************************
  2. *
  3. * SOURCE FILE NAME: ADMCCAP.C
  4. *
  5. * DESCRIPTIVE NAME: Reports device capabilities
  6. *
  7. *              Copyright (c) IBM Corporation  1991, 1993
  8. *                        All Rights Reserved
  9. *
  10. *
  11. * NOTES:  This file illustrates the following concepts:
  12. *  A. How to process the capability message commands.
  13. *      These are messages which this MCD supports (such as play, close etc.)
  14. *      Messages (or commands to the caller) such as sysinfo are
  15. *      not supported by this MCD.
  16. *  B. How to process the capability item flag.
  17. *      Items describe particular features (such as the ability to record)
  18. *      which the MCD either does or does not support.
  19. *
  20. *********************** END OF SPECIFICATIONS ********************************/
  21. #define INCL_BASE
  22. #define INCL_DOSMODULEMGR
  23. #define INCL_DOSSEMAPHORES
  24.  
  25. #include <os2.h>                        // OS2 defines.
  26. #include <string.h>                     // String functions.
  27. #include <os2medef.h>                   // MME includes files.
  28. #include <math.h>                       // Standard Math Lib
  29. #include <stdlib.h>                     // Standard Library
  30. #include <audio.h>                      // Audio Device defines
  31. #include <ssm.h>                        // SSM spi includes.
  32. #include <mcios2.h>                     // MM Error Messages.
  33. #include <mmioos2.h>                    // MMIO Include.
  34. #include <mmdrvos2.h>                   // MCI Driver include.
  35. #include <mcd.h>                        // AudioIFDriverInterface.
  36. #include <hhpheap.h>                    // Heap Manager Definitions
  37. #include <qos.h>
  38. #include <audiomcd.h>                   // Component Definitions.
  39. #include <admcfunc.h>
  40.  
  41.  
  42.  
  43. /********************* START OF SPECIFICATIONS *******************************
  44. *
  45. * SUBROUTINE NAME:              MCDCAPS
  46. *
  47. * DESCRIPTIVE NAME: Waveform Device Capabilities.
  48. *
  49. * FUNCTION: Get Waveform Device Static Capabilities.
  50. *
  51. * NOTES:
  52. *
  53. * ENTRY POINTS:
  54. *
  55. * INPUT: MCI_GETDEVCAPS message.
  56. *
  57. * EXIT-NORMAL: MCIERR_SUCCESS.
  58. *
  59. * EXIT_ERROR:  Error Code.
  60. *
  61. * EFFECTS:
  62. *
  63. * INTERNAL REFERENCES:
  64. *
  65. * EXTERNAL REFERENCES: None.
  66. *
  67. *********************** END OF SPECIFICATIONS ********************************/
  68.  
  69. RC MCICaps( FUNCTION_PARM_BLOCK *pFuncBlock )
  70. {
  71.   ULONG                  ulrc;                // MME Error Value
  72.   ULONG                  ulParam1;            // Msg Flags
  73.   INSTANCE               *ulpInstance;       // Local Instance
  74.   PMCI_GETDEVCAPS_PARMS  pParams;             // Msg Data Ptr
  75.   ULONG                  ulType;              // Msgs supported.
  76.   ULONG                  ulCapsFlags;         // Mask for Incoming MCI Flags
  77.   PMCI_WAVE_GETDEVCAPS_PARMS   pExtDevCaps;
  78.  
  79.  
  80.   /**************************************
  81.   * Derefernce Pointers.
  82.   **************************************/
  83.   ulParam1    = pFuncBlock->ulParam1;
  84.  
  85.   pParams     = ( PMCI_GETDEVCAPS_PARMS) pFuncBlock->ulParam2;
  86.  
  87.   ulpInstance = (INSTANCE *) pFuncBlock->ulpInstance;
  88.  
  89.   ulCapsFlags = ulParam1;
  90.  
  91.   /* Mask out all of the flags that we support */
  92.  
  93.   ulCapsFlags &= ~( MCI_WAIT + MCI_NOTIFY +
  94.                     MCI_GETDEVCAPS_MESSAGE + MCI_GETDEVCAPS_ITEM +
  95.                     MCI_GETDEVCAPS_EXTENDED );
  96.  
  97.   /************************************************
  98.   * If there are any other flags, they are invalid.
  99.   ************************************************/
  100.  
  101.   if (ulCapsFlags > 0 )
  102.       return ( MCIERR_INVALID_FLAG );
  103.  
  104.   /********************************************
  105.   * Check for Invalid Combination of flags
  106.   ********************************************/
  107.  
  108.   if (ulParam1 & MCI_GETDEVCAPS_ITEM && ulParam1 & MCI_GETDEVCAPS_MESSAGE)
  109.       return ( MCIERR_FLAGS_NOT_COMPATIBLE );
  110.  
  111.   /*********************************************
  112.   * Ensure that the devcaps parms that the caller
  113.   * used a valid.
  114.   *********************************************/
  115.   ulrc = CheckMem ( (PVOID)pParams,
  116.                     sizeof (MCI_GETDEVCAPS_PARMS),
  117.                     PAG_READ | PAG_WRITE );
  118.  
  119.   if (ulrc != MCIERR_SUCCESS)
  120.       return ( MCIERR_MISSING_PARAMETER );
  121.  
  122.   ulType = ulParam1 & (MCI_GETDEVCAPS_MESSAGE | MCI_GETDEVCAPS_ITEM | MCI_GETDEVCAPS_EXTENDED);
  123.  
  124.   /************************************
  125.   * The caller MUST specify either the
  126.   * devcaps message or item flags.
  127.   *************************************/
  128.  
  129.   if ( !ulType )
  130.      {
  131.      return (MCIERR_MISSING_FLAG);
  132.      }
  133.  
  134.   if ( ulType == MCI_GETDEVCAPS_MESSAGE )
  135.      {
  136.  
  137.      switch ( pParams->usMessage )
  138.        {
  139.        /*************************************************
  140.        * The MCD currently supports the messages below:
  141.        * If we support the messages return TRUE and
  142.        * a true/false return.
  143.        *************************************************/
  144.  
  145.        case MCI_RELEASEDEVICE :
  146.        case MCI_ACQUIREDEVICE :
  147.        case MCI_OPEN          :
  148.        case MCI_PLAY          :
  149.        case MCI_PAUSE         :
  150.        case MCI_SEEK          :
  151.        case MCI_RECORD        :
  152.        case MCI_CLOSE         :
  153.        case MCI_INFO          :
  154.        case MCI_GETDEVCAPS    :
  155.        case MCI_SET           :
  156.        case MCI_STATUS        :
  157.        case MCI_MASTERAUDIO   :
  158.        case MCI_CUE           :
  159.        case MCI_STOP          :
  160.        case MCI_LOAD          :
  161.        case MCI_RESUME        :
  162.        case MCI_SET_POSITION_ADVISE:
  163.        case MCI_SET_CUEPOINT  :
  164.        case MCI_CONNECTOR     :
  165.        case MCI_SET_SYNC_OFFSET:
  166.        case MCI_SAVE          :
  167.  
  168.             pParams->ulReturn = MCI_TRUE;
  169.             ulrc = MAKEULONG (ulrc, MCI_TRUE_FALSE_RETURN);
  170.            break;
  171.  
  172.        /******************************
  173.         * List Unsupported Functions
  174.        ******************************/
  175.  
  176.  
  177.       case MCI_DEVICESETTINGS:
  178.       case MCI_STEP:
  179.       case MCI_SYSINFO:
  180.       case MCI_UPDATE:
  181.       case MCI_GETTOC:
  182.       case MCI_SPIN:
  183.       case MCI_ESCAPE:
  184.            pParams->ulReturn = MCI_FALSE;
  185.            ulrc = MAKEULONG (ulrc, MCI_TRUE_FALSE_RETURN);
  186.           break;
  187.  
  188.       default:
  189.           return ( MCIERR_UNRECOGNIZED_COMMAND );
  190.  
  191.       } /* switch of message */
  192.  
  193.     } /* message flag was sent */
  194.   else if ( ulType & MCI_GETDEVCAPS_EXTENDED )
  195.     {
  196.  
  197.     /*********************************************
  198.     * Ensure that the devcaps parms that the caller
  199.     * used a valid (these are wave specific).
  200.     *********************************************/
  201.     pExtDevCaps = ( PMCI_WAVE_GETDEVCAPS_PARMS ) pParams;
  202.     ulrc = CheckMem ( (PVOID)pExtDevCaps,
  203.                       sizeof (MCI_WAVE_GETDEVCAPS_PARMS ),
  204.                       PAG_READ | PAG_WRITE );
  205.   
  206.     if (ulrc != MCIERR_SUCCESS)
  207.         return ( MCIERR_MISSING_PARAMETER );
  208.  
  209.  
  210.     ulrc = ulpInstance->pfnVSD ( &MIX,
  211.                                  MCI_GETDEVCAPS,
  212.                                  pParams->ulItem,
  213.                                  (LONG)  &pExtDevCaps,
  214.                                  0L);
  215.  
  216.     return ( ulrc );
  217.  
  218.     } /* extended devcaps */
  219.  
  220.  
  221.   else /* if ( ulType == MCI_GETDEVCAPS_ITEM ) */
  222.  
  223.     {
  224.        switch (pParams->ulItem)
  225.        {
  226.  
  227.        case MCI_GETDEVCAPS_DEVICE_TYPE:
  228.             pParams->ulReturn = MCI_DEVTYPE_WAVEFORM_AUDIO;
  229.             ulrc = MAKEULONG (ulrc, MCI_DEVICENAME_RETURN);
  230.             break;
  231.  
  232.        case MCI_GETDEVCAPS_CAN_RECORD:
  233.              /***************************************
  234.              * When we loaded the file, we found out
  235.              * from the IO proc if it has the ability
  236.              * to record so examine this flag.
  237.              ****************************************/
  238.              if (ulpInstance->ulCapabilities & CAN_RECORD) 
  239.                  {
  240.                  ulrc = ulpInstance->pfnVSD ( &MIX,
  241.                                               MCI_GETDEVCAPS,
  242.                                               pParams->ulItem,
  243.                                               (LONG)  &pParams->ulReturn,
  244.                                               0 );
  245.  
  246.                  }
  247.              else
  248.                  {
  249.                  pParams->ulReturn = MCI_FALSE;
  250.                  }
  251.             ulrc = MAKEULONG (ulrc, MCI_TRUE_FALSE_RETURN);
  252.             break;
  253.  
  254.        case MCI_GETDEVCAPS_CAN_SETVOLUME:
  255.            ulrc = mciSendCommand ( ulpInstance->usAmpDeviceID,
  256.                                    MCI_GETDEVCAPS,
  257.                                    ulParam1,
  258.                                    (PVOID) pParams,
  259.                                    pFuncBlock->usUserParm);
  260.  
  261.  
  262. //            ulrc = MAKEULONG (ulrc, MCI_TRUE_FALSE_RETURN);
  263.  
  264.        break;
  265.  
  266.        /* We have the following static capabilities */
  267.  
  268.        case MCI_GETDEVCAPS_HAS_AUDIO:
  269.        case MCI_GETDEVCAPS_USES_FILES:
  270.        case MCI_GETDEVCAPS_CAN_PLAY:
  271.        case MCI_GETDEVCAPS_CAN_STREAM:
  272.             pParams->ulReturn = MCI_TRUE;
  273.             ulrc = MAKEULONG (ulrc, MCI_TRUE_FALSE_RETURN);
  274.             break;
  275.  
  276.        case MCI_GETDEVCAPS_HAS_VIDEO:
  277.        case MCI_GETDEVCAPS_CAN_EJECT:
  278.        case MCI_GETDEVCAPS_CAN_PROCESS_INTERNAL:
  279.        case MCI_GETDEVCAPS_CAN_LOCKEJECT:
  280.             pParams->ulReturn = MCI_FALSE;
  281.             ulrc = MAKEULONG (ulrc, MCI_TRUE_FALSE_RETURN);
  282.             break;
  283.  
  284.        case MCI_GETDEVCAPS_CAN_SAVE:
  285.              /***************************************
  286.              * When we loaded the file, we found out
  287.              * from the IO proc if it has the ability
  288.              * to save so examine this flag.
  289.              ****************************************/
  290.              pParams->ulReturn = (ulpInstance->ulCapabilities & CAN_SAVE) ? 1 : 0;
  291.  
  292.              ulrc = MAKEULONG (ulrc, MCI_TRUE_FALSE_RETURN);
  293.              break;
  294.  
  295.        case MCI_GETDEVCAPS_CAN_RECORD_INSERT:
  296.              /***************************************
  297.              * When we loaded the file, we found out
  298.              * from the IO proc if it has the ability
  299.              * to save so examine this flag.
  300.              ****************************************/
  301.              pParams->ulReturn = (ulpInstance->ulCapabilities & CAN_INSERT) ? 1 : 0;
  302.  
  303.              ulrc = MAKEULONG (ulrc, MCI_TRUE_FALSE_RETURN);
  304.              break;
  305.  
  306.        case MCI_GETDEVCAPS_PREROLL_TYPE:
  307.             pParams->ulReturn = MCI_PREROLL_NOTIFIED;
  308.             ulrc = MAKEULONG (ulrc, MCI_PREROLL_TYPE_RETURN );
  309.             break;
  310.  
  311.        case MCI_GETDEVCAPS_PREROLL_TIME:
  312.             pParams->ulReturn = 0;
  313.             ulrc = MAKEULONG (ulrc, MCI_INTEGER_RETURNED);
  314.             break;
  315.  
  316.        default:
  317.             return ( MCIERR_UNSUPPORTED_FLAG );
  318.  
  319.        } /* items of item */
  320.  
  321.     } /* GETDEVCAPS item flag passed */
  322.   return (ulrc);
  323.  
  324. } /* MCICaps */
  325.  
  326.  
  327.