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

  1. /********************* START OF SPECIFICATulIONS *********************
  2. *
  3. * SUBROUTINE NAME: MCIConnection
  4. *
  5. * DESCRIPTIVE NAME: Audio MCD Connection Routine
  6. *
  7. *              Copyright (c) IBM Corporation  1991, 1993
  8. *                        All Rights Reserved
  9. *
  10. * FUNCTION: Processes connection messages from MCI drivers and applications.
  11. *
  12. * NOTES:
  13. *
  14. * ENTRY POINTS:
  15. *
  16. * INPUT: MCI_STATUS message.
  17. *
  18. * EXIT-NORMAL:Lo Word Return  Code MCIERR_SUCCESS
  19. *
  20. * EXIT_ERROR:  Error Code.
  21. *
  22. * EFFECTS:
  23. *
  24. *
  25. * INTERNAL REFERENCES:
  26. *                        ConvertTimeUnits ().
  27. *                        ConVertToMM
  28. *                        SetAudioDevice().
  29. *                        SetWaveDeviceDefaults().
  30. *                        CheckMem ().
  31. *
  32. * EXTERNAL REFERENCES:
  33. *                        SpiGetTime       ()        - MME API
  34. *                        mciSendCommand   ()        - MME API
  35. *
  36. *********************** END OF SPECIFICATIONS **********************/
  37. #define INCL_BASE                       // Base Dos APIs.
  38. #define INCL_ERRORS                     // All the errors.
  39. #define INCL_MMIO_CODEC
  40.  
  41.  
  42. #include <os2.h>                        // OS2 includes.
  43. #include <string.h>                     // String Functions
  44. #include <math.h>                       // Math Functions
  45. #include <os2medef.h>                   // MME includes files.
  46. #include <ssm.h>                        // SSM spi includes.
  47. #include <meerror.h>                    // MM Error Messages.
  48. #include <mmioos2.h>                    // MMIO Include.
  49. #include <mcios2.h>                     // MM System Include.
  50. #include <mmdrvos2.h>                   // Mci Driver include.
  51. #include <mcd.h>                        // AUDIO IF DriverInterface.
  52. #include <hhpheap.h>                    // Heap Manager Definitions.
  53. #include <qos.h>
  54. #include <audiomcd.h>                   // Component Definitions.
  55. #include <admcfunc.h>                   // Function Prototypes
  56. #include <checkmem.h>
  57. #include <mcipriv.h>
  58.  
  59. #ifdef CONNECTION
  60. /********************* START OF SPECIFICATIONS *********************
  61. *
  62. * SUBROUTINE NAME: MCIConnection
  63. *
  64. * FUNCTION: Process MCI_CONNECTION message.
  65. *
  66. * NOTES: This function can make an MCI or SSM connection.
  67. *        it also can break an MCI or SSM connection.
  68. *
  69. * ENTRY POINTS:
  70. *
  71. * INPUT: FUNCTION_PARM_BLOCK
  72. *
  73. * EXIT-NORMAL: MCIERR_SUCCESS
  74. *
  75. * EXIT_ERROR:
  76. *
  77. * EFFECTS:
  78. *
  79. * EXTERNAL REFERENCES: mmioSendMessage()    - MMIO function
  80. *
  81. *********************** END OF SPECIFICATIONS **********************/
  82. ULONG MCIMakeConnection ( FUNCTION_PARM_BLOCK *pFuncBlock)
  83. {
  84.   ULONG                ulrc = MCIERR_SUCCESS;    // Error Value
  85. //  ULONG                ulConnFlags;
  86.   ULONG                ulParam1;       // Msg Flags
  87.  
  88.   INSTANCE             *pInstance;   // Local Instance
  89.  
  90.   PCONCB               pconcb = (PCONCB) pFuncBlock->ulParam2;
  91.  
  92. //  ulConnFlags = ulParam1 = pFuncBlock->ulParam1;
  93.  
  94.   pInstance= (INSTANCE *) pFuncBlock->ulpInstance;
  95.  
  96.    /*-------------------------------------
  97.    * If the caller wants to specify a
  98.    * connector type and its not digital
  99.    * wave stream connection --error out.
  100.    *------------------------------------*/
  101.  
  102.    if ( pconcb->ulConnectorType != MCI_WAVE_STREAM_CONNECTOR )
  103.       {
  104.       return ( MCIERR_INVALID_CONNECTOR_TYPE );
  105.       }
  106.  
  107. // what about Index?????
  108.  
  109.    if ( ulParam1 == MCIDRV_CONNECT_TARGET )
  110.       {
  111.       pconcb->hid = pInstance->StreamInfo.hidATarget;
  112.       pconcb->pevfn = (PEVFN)RecordEventRoutine;
  113.       pInstance->ulOperation = MCIDRV_INPUT;
  114.       }
  115.    else
  116.       {
  117.       pconcb->hid = pInstance->StreamInfo.hidASource;
  118.       pconcb->pevfn = (PEVFN) PlayEventRoutine;
  119.       pInstance->ulOperation = MCIDRV_OUTPUT;
  120.       }
  121.  
  122.    /* --------------------------------------------
  123.    * Fill in the remainder of the CONCB struct
  124.    * this includes:
  125.    *    DCB (Device Control Block )
  126.    *    SPCBKey (stream identifier )
  127.    *    Event Routine (where spi events come )
  128.    *    Event Control Block -- memory for events
  129.    *----------------------------------------------*/
  130.  
  131.    pconcb->pdcb = NULL;
  132.    pconcb->pspcbkey = NULL; // &pInstance->StreamInfo.SpcbKey;
  133.    pconcb->pMediaHeader = (PVOID) &pInstance->mmAudioHeader;
  134.  
  135.    pconcb->pevcb = (PEVCB) &pInstance->StreamInfo.Evcb;
  136. //   pconcb->phevent = &pInstance->StreamInfo.hEvent;
  137.  
  138.  
  139.    /* Set state variable to indicate conneciton has been made */
  140.  
  141.    pInstance->fConnected = TRUE;
  142.  
  143.   pInstance->ulFlags &= ~HAVE_SPCBKEY;
  144.   pInstance->pconcb = pFuncBlock->ulParam2;
  145.  
  146.   return ( ulrc );
  147.  
  148. } /* MCIConnection */
  149. #endif
  150.  
  151.  
  152. /************************ START OF SPECIFICATIONS **************************
  153. *
  154. * SUBROUTINE NAME: BreakMCIConnection
  155. *
  156. * DESCRIPTIVE NAME: This function will break the connection to whatever
  157. *                   device is connected to the audio MCD driver.  It will also
  158. *                   destroy any streams between the two connections.
  159. *
  160. * FUNCTION:
  161. *
  162. *************************** END OF SPECIFICATIONS *************************/
  163.  
  164. ULONG MCIBreakConnection( FUNCTION_PARM_BLOCK *pFuncBlock)
  165.  
  166. {
  167.    INSTANCE         *pInstance;   // Local Instance
  168.  
  169.    pInstance= (INSTANCE *) pFuncBlock->ulpInstance;
  170.  
  171.  
  172.    pInstance->fConnected = FALSE;
  173.  
  174.    return ( MCIERR_SUCCESS );
  175.  
  176. } /* MCIBreakConnection */
  177.  
  178. #ifdef CONNECTION
  179. /************************ START OF SPECIFICATIONS **************************
  180. *
  181. * SUBROUTINE NAME: MCITestConnection
  182. *
  183. * DESCRIPTIVE NAME: This function will determine if a connection can be made.
  184. *                   Caller must be using the wave stream connector and also pass
  185. *                   in a valid media header (i.e. MMAUDIOHEADER ).
  186. *
  187. * FUNCTION:
  188. *
  189. *************************** END OF SPECIFICATIONS *************************/
  190.  
  191. ULONG MCITestConnection( FUNCTION_PARM_BLOCK *pFuncBlock)
  192.  
  193. {
  194. ULONG            ulrc;           // Error Value
  195. ULONG            ulConnFlags;
  196.  
  197. INSTANCE         *pInstance;   // Local Instance
  198.  
  199. PCONCB           pconcb = (PCONCB) pFuncBlock->ulParam1;
  200. PMMAUDIOHEADER   pmmaudioheader = pconcb->pMediaHeader;
  201.  
  202.  
  203.  
  204. ulConnFlags = pFuncBlock->ulParam1;
  205.  
  206. //pInstance= (INSTANCE *) pFuncBlock->ulpInstance;
  207.  
  208.    /*-------------------------------------
  209.    * If the caller wants to specify a
  210.    * connector type and its not digital
  211.    * wave stream connection --error out.
  212.    *------------------------------------*/
  213.  
  214.    if ( pconcb->ulConnectorType != MCI_WAVE_STREAM_CONNECTOR )
  215.       {
  216.       return ( MCIERR_INVALID_CONNECTOR_TYPE );
  217.       }
  218.  
  219.    if ( pmmaudioheader->ulMediaType != MMIO_MEDIATYPE_AUDIO )
  220.       {
  221.       return ( MCIERR_INVALID_CONNECTOR_TYPE );
  222.       }
  223.  
  224.    return ( MCIERR_SUCCESS );
  225.  
  226. } /* MCITestConnection */
  227. #endif
  228.  
  229. /************************ START OF SPECIFICATIONS **************************
  230. *
  231. * SUBROUTINE NAME: MCIAssociate.
  232. *
  233. * DESCRIPTIVE NAME: This function will be called by MDM to associate any
  234. *                   audio specific information to our stream handler (usually
  235. *                   the file system stream handler).
  236. *
  237. * FUNCTION:
  238. *
  239. *************************** END OF SPECIFICATIONS *************************/
  240.  
  241. ULONG MCIAssociate ( FUNCTION_PARM_BLOCK *pFuncBlock)
  242.  
  243. {
  244.   ULONG                ulrc;           // Error Value
  245.   ULONG                ulConnFlags;
  246.  
  247.   INSTANCE             *pInstance;   // Local Instance
  248.  
  249.   PCONCB               pconcb = (PCONCB) pFuncBlock->ulParam2;
  250.   extern HID           hidASource;
  251.   extern HID           hidATarget;
  252.  
  253.  
  254.   ulConnFlags = pFuncBlock->ulParam1;
  255.  
  256.   pInstance= (INSTANCE *) pFuncBlock->ulpInstance;
  257.  
  258.   /*-----------------------------------------------------
  259.   * Indicate that we know that a stream has been created
  260.   * and store the stream handle for stream destruction.
  261.   *----------------------------------------------------*/
  262.   pInstance->StreamInfo.hStream = pconcb->hstream;
  263.  
  264.   /* Save the fact that we know the stream is created */
  265.   /***************************
  266.   * Set a flag which indicates
  267.   * that a stream has been
  268.   * created.
  269.   ****************************/
  270.   pInstance->ulCreateFlag = PREROLL_STATE;
  271.  
  272.   /* Perform associations if necessary */
  273.  
  274.   pInstance->ulOperation = ulConnFlags & ( MCIDRV_INPUT | MCIDRV_OUTPUT );
  275.   if ( pInstance->usPlayLstStrm )
  276.      {
  277.      ulrc = AssociatePlayList ( pInstance );
  278.      }
  279.   else
  280.      {
  281.      /**********************************************************
  282.      * The stream must be associated with a data object
  283.      * in our case a mmio file handle.  The file system
  284.      * stream handler (FSSH) will always be the stream handler
  285.      * that we want to associate the data object with,
  286.      * therefore, if we have created a playback stream then
  287.      * FSSH is the source, so associate with the source.  On a
  288.      * record stream, FSSH is the target, so associate with
  289.      * the target.
  290.      **********************************************************/
  291.  
  292.  
  293.      pInstance->StreamInfo.acbmmio.ulObjType = ACBTYPE_MMIO;
  294.      pInstance->StreamInfo.acbmmio.ulACBLen = sizeof (ACB_MMIO);
  295.      pInstance->StreamInfo.acbmmio.hmmio = pInstance->hmmio;
  296.      if ( ulConnFlags & MCIDRV_OUTPUT )
  297.          {
  298.  
  299.          ulrc = ADMCAssociate ( pconcb->hstream,
  300.                                hidASource,
  301.                                (PVOID) &pInstance->StreamInfo.acbmmio);
  302.  
  303.  
  304.          }  /* Associating play stream */
  305.  
  306.      else // if ( pInstance->ulOperation == MCIDRV_INPUT )
  307.          {
  308.          ulrc = ADMCAssociate ( pconcb->hstream,
  309.                                 hidATarget,
  310.                                 (PVOID) &pInstance->StreamInfo.acbmmio);
  311.  
  312.          } /* Associating record stream */
  313.  
  314.      } /* else this is not a playlist */
  315.  
  316.   return ( ulrc );
  317.  
  318. } /* MCIAssociate */
  319.  
  320. /************************ START OF SPECIFICATIONS **************************
  321. *
  322. * SUBROUTINE NAME: TestNetwork
  323. *
  324. * DESCRIPTIVE NAME: This function queries MDM to determine if the network
  325. *                   we are attached to can record.
  326. *
  327. * FUNCTION:
  328. *
  329. *************************** END OF SPECIFICATIONS *************************/
  330.  
  331. ULONG TestNetwork( INSTANCE                    *pInstance,
  332.                    PMCI_WAVE_GETDEVCAPS_PARMS  pExtDevCaps )
  333.  
  334. {
  335.    CONCB         concb;
  336.    MMAUDIOHEADER mmaudioheader;
  337.    ULONG         ulDirection;
  338.    ULONG         ulrc;
  339.  
  340.    if ( !pInstance->fConnected )
  341.       {
  342.       return (MCIERR_NO_CONNECTION );
  343.       }
  344.  
  345. //  pExtDevCaps->ulBitsPerSample;
  346.  
  347.  
  348.   mmaudioheader.mmXWAVHeader.WAVEHeader.usFormatTag       =  pExtDevCaps->ulFormatTag;
  349.   mmaudioheader.mmXWAVHeader.WAVEHeader.usChannels        =  pExtDevCaps->ulChannels ;
  350.   mmaudioheader.mmXWAVHeader.WAVEHeader.ulSamplesPerSec   =  pExtDevCaps->ulSamplesPerSec;
  351.  
  352.   //  If mmaudioheader contains !0, then assume source, else must be target.
  353.  
  354.   if ( pExtDevCaps->ulFormatMode == MCI_PLAY )
  355.      {
  356.      mmaudioheader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInMS = 1;
  357.      ulDirection = MCIDRV_CONNECT_TARGET;
  358.      }
  359.   else
  360.      {
  361.      mmaudioheader.mmXWAVHeader.XWAVHeaderInfo.ulAudioLengthInMS = 0;
  362.      ulDirection = MCIDRV_CONNECT_SOURCE;
  363.      }
  364.  
  365.   mmaudioheader.mmXWAVHeader.WAVEHeader.usBitsPerSample   =  pExtDevCaps->ulBitsPerSample;
  366.   mmaudioheader.ulMediaType = MMIO_MEDIATYPE_AUDIO;
  367.   mmaudioheader.ulHeaderLength = sizeof( MMAUDIOHEADER );
  368.  
  369.    concb.pMediaHeader = ( PVOID) &mmaudioheader;
  370. #ifndef CONNECTION
  371.    ulrc = mciSendCommand ( pInstance->usAmpDeviceID,
  372. #else
  373.    ulrc = mciSendCommand ( pInstance->usWaveDeviceID,
  374. #endif
  375.                            MCIDRV_TEST_CONNECTION,
  376.                            ulDirection,
  377.                            (PVOID) &concb,
  378.                            0 );
  379.  
  380.  
  381.    return ( ulrc );
  382.  
  383. } /* TestNetwork */
  384.  
  385.  
  386.  
  387. /************************ START OF SPECIFICATIONS **************************
  388. *
  389. * SUBROUTINE NAME: CanPlayRecord
  390. *
  391. * DESCRIPTIVE NAME: This function queries MDM to determine if the network
  392. *                   can either produce/consume information.
  393. *
  394. * FUNCTION:
  395. *
  396. *************************** END OF SPECIFICATIONS *************************/
  397.  
  398. ULONG CanPlayRecord( INSTANCE   *pInstance,
  399.                      ULONG      ulDirection )
  400.  
  401. {
  402.    CONCB   concb;
  403.    ULONG   ulrc;
  404.  
  405.  
  406.    if ( !pInstance->fConnected )
  407.       {
  408.       return (MCIERR_NO_CONNECTION );
  409.       }
  410.  
  411.    concb.pMediaHeader = ( PVOID) &pInstance->mmAudioHeader;
  412.    pInstance->mmAudioHeader.ulMediaType = MMIO_MEDIATYPE_AUDIO;
  413.  
  414. #ifndef CONNECTION
  415.    ulrc = mciSendCommand ( pInstance->usAmpDeviceID,
  416. #else
  417.    ulrc = mciSendCommand ( pInstance->usWaveDeviceID,
  418. #endif
  419.                            MCIDRV_TEST_CONNECTION,
  420.                            ulDirection,
  421.                            (PVOID) &concb,
  422.                            0 );
  423.  
  424.  
  425.    return ( ulrc );
  426.  
  427. } /* CanPlayRecord */
  428.  
  429. /************************ START OF SPECIFICATIONS **************************
  430. *
  431. * SUBROUTINE NAME: ModifyConnection
  432. *
  433. * DESCRIPTIVE NAME: This function queries MDM to determine if the network
  434. *                   can either produce/consume information.
  435. *
  436. * FUNCTION:
  437. *
  438. *************************** END OF SPECIFICATIONS *************************/
  439.  
  440. ULONG ModifyConnection( INSTANCE   *pInstance )
  441.  
  442. {
  443. extern HID   hidBSource;
  444. extern HID   hidBTarget;
  445.  
  446.  
  447.    CONCB   concb;
  448.    ULONG   ulrc;
  449.  
  450.    if ( !pInstance->fConnected )
  451.       {
  452.       return (MCIERR_NO_CONNECTION );
  453.       }
  454.  
  455.    concb.pMediaHeader = ( PVOID) &pInstance->mmAudioHeader;
  456.    pInstance->mmAudioHeader.ulMediaType = MMIO_MEDIATYPE_AUDIO;
  457.  
  458.  
  459. #ifndef CONNECTION
  460.    concb.ulFlags = VSD_SET_ALL;
  461.  
  462.    ulrc = mciSendCommand ( pInstance->usAmpDeviceID,
  463. #else
  464.    memmove( &concb, pInstance->pconcb, sizeof( CONCB ) );
  465.    concb.pMediaHeader = ( PVOID) &pInstance->mmAudioHeader;
  466.  
  467.    ulrc = mciSendCommand ( pInstance->usWaveDeviceID,
  468. #endif
  469.                            MCIDRV_MODIFY_CONNECTION,
  470.                            pInstance->ulOperation,
  471.                            (PVOID) &concb,
  472.                            0 );
  473.  
  474.    if ( ulrc )
  475.      return ( ULONG_LOWD(ulrc) );
  476.  
  477.  
  478. #ifndef CONNECTION
  479.    pInstance->StreamInfo.SpcbKey.ulDataType    = concb.pspcbkey->ulDataType;
  480.    pInstance->StreamInfo.SpcbKey.ulDataSubType = concb.pspcbkey->ulDataSubType;
  481.    pInstance->StreamInfo.SpcbKey.ulIntKey = 0;
  482.  
  483.    /*------------------------------------------------------
  484.    * Get certain streaming information from the stream handler
  485.    * we have loaded.
  486.    *--------------------------------------------------------*/
  487.    ulrc = SpiGetProtocol( concb.hid,
  488.                           &pInstance->StreamInfo.SpcbKey,
  489.                           &pInstance->StreamInfo.spcb );
  490.  
  491.    if ( ulrc )
  492.       {
  493.       return ( ulrc );
  494.       }
  495.  
  496.  
  497.    pInstance->ulBytes   = pInstance->StreamInfo.spcb.ulBytesPerUnit;
  498.    pInstance->ulMMTime  = pInstance->StreamInfo.spcb.mmtimePerUnit;
  499.  
  500.    /* Save the hid from the connected device--use for spcbkeys etc. */
  501.  
  502.    if ( pInstance->ulOperation == MCIDRV_INPUT )
  503.       {
  504.       hidBSource = concb.hid;
  505.       }
  506.    else
  507.       {
  508.       hidBTarget = concb.hid;
  509.       }
  510.  
  511.    memmove( &pInstance->StreamInfo.SpcbKey, concb.pspcbkey, sizeof( SPCBKEY) );
  512.    pInstance->pdcb = concb.pdcb;
  513. #else
  514.   pInstance->ulFlags &= ~HAVE_SPCBKEY;
  515. #endif
  516.    return ( ulrc );
  517.  
  518. } /* ModifyConnection */
  519.  
  520.  
  521. /************************ START OF SPECIFICATIONS **************************
  522. *
  523. * SUBROUTINE NAME: FindAmp
  524. *
  525. * DESCRIPTIVE NAME: Gets the device ID of the first Amplifier/Mixer in the network
  526. *                   All audio commands (such as volume, treble, bass etc.)
  527. *                   we can't process will go there.
  528. *
  529. * FUNCTION:
  530. *
  531. *************************** END OF SPECIFICATIONS *************************/
  532. #ifdef CONNECTION
  533. ULONG FindAmp( INSTANCE *pInstance )
  534.  
  535. {
  536. //   MCISYSYINFO_ID_PARMS   idparms;
  537.  
  538.    ULONG   ulrc = MCIERR_SUCCESS;
  539.  
  540.    if ( !pInstance->fConnected )
  541.       {
  542.       return (MCIERR_NO_CONNECTION );
  543.       }
  544.  
  545.    if ( pInstance->fFoundMixer )
  546.       {
  547.       return ( MCIERR_SUCCESS );
  548.       }
  549.  
  550.    /* Tell system we want the first mixer */
  551. #ifndef CONNECTION
  552.    pInstance->fFoundMixer = TRUE;
  553. #endif
  554. //   idparms.ulDeviceType = MCI_DEVTYPE_AMPMIXER;
  555. //   ulrc = mciSendCommand ( pInstance->usWaveDeviceID,
  556. //                           MCIDRV_SYSINFO,
  557. //                           SYSINFO_GET_ID,
  558. //                           (PVOID) &idparms,
  559. //                           0 );
  560.    ulrc = MCIERR_SUCCESS;  // temp hack
  561.    /* If we found a mixer, then these commands can be safely routed */
  562.  
  563.    if ( !ulrc )
  564.       {
  565. //      pInstance->usAmpDeviceID = idparms.usDeviceID;
  566.       pInstance->fFoundMixer = TRUE;
  567.       }
  568.    return ( ulrc );
  569.  
  570. } /* FindAmp */
  571. #endif
  572.  
  573. /************************ START OF SPECIFICATIONS **************************
  574. *
  575. * SUBROUTINE NAME: CheckForConnection
  576. *
  577. * DESCRIPTIVE NAME: Determines if MCD is connected to another MCD.
  578. *
  579. * FUNCTION:
  580. *
  581. *************************** END OF SPECIFICATIONS *************************/
  582.  
  583. ULONG CheckForConnection( INSTANCE *pInstance )
  584.  
  585. {
  586.    if ( !pInstance->fConnected )
  587.       {
  588.       return (MCIERR_NO_CONNECTION );
  589.       }
  590.  
  591.    return ( MCIERR_SUCCESS );
  592.  
  593. } /* CheckForConnection */
  594.  
  595.  
  596. /************************ START OF SPECIFICATIONS **************************
  597. *
  598. * SUBROUTINE NAME: GetStreamingSemaphore
  599. *
  600. * DESCRIPTIVE NAME: This function queries to acquire the streaming semaphore
  601. *                   for cross MCD control.
  602. *
  603. * FUNCTION:
  604. *
  605. *************************** END OF SPECIFICATIONS *************************/
  606. ULONG GetStreamingSemaphore( INSTANCE *pInstance )
  607.  
  608. {
  609. // return real semaphore when defined
  610. return ( MCIERR_SUCCESS );
  611. }
  612.  
  613. /************************ START OF SPECIFICATIONS **************************
  614. *
  615. * SUBROUTINE NAME: ReleaseStreamingSemaphore
  616. *
  617. * DESCRIPTIVE NAME: This function releases the streaming semaphore
  618. *                   for cross MCD control.
  619. *
  620. * FUNCTION:
  621. *
  622. *************************** END OF SPECIFICATIONS *************************/
  623. ULONG ReleaseStreamingSemaphore( INSTANCE *pInstance )
  624.  
  625. {
  626. // return real semaphore when defined
  627. return ( MCIERR_SUCCESS );
  628. }
  629.  
  630.  
  631.  
  632. /************************ START OF SPECIFICATIONS **************************
  633. *
  634. * SUBROUTINE NAME: StartPlayBack
  635. *
  636. * DESCRIPTIVE NAME: This function starts a streaming network.
  637. *
  638. * FUNCTION:
  639. *
  640. * ulStartFlags : MCIDRV_CUE_PLAYBACK
  641. *                MCIDRV_CUE_RECORD
  642. *                MCIDRV_START_PLAYBACK
  643. *                MCIDRV_START_RECORD
  644. *
  645. *************************** END OF SPECIFICATIONS *************************/
  646. ULONG StartStream( INSTANCE *pInstance,
  647.                    ULONG    ulStartFlags )
  648.  
  649. {
  650. //CONCB   concb;
  651. ULONG   ulrc;
  652. ULONG   ulSpiFlags = SPI_START_STREAM;
  653. CONCB   concb;
  654. #ifndef CONNECTION
  655.  
  656.    if ( ulStartFlags == MCIDRV_CUE_PLAYBACK )
  657.       {
  658.       ulSpiFlags = SPI_START_PREROLL;
  659.       }
  660.    ulrc = SpiStartStream(pInstance->StreamInfo.hStream, ulSpiFlags );
  661. #else
  662.  
  663.   concb.pMediaHeader = ( PVOID ) &pInstance->mmAudioHeader;
  664.   pInstance->mmAudioHeader.ulMediaType = MMIO_MEDIATYPE_AUDIO;
  665.  
  666.   ulrc = mciSendCommand ( pInstance->usWaveDeviceID,
  667.           MCIDRV_START,
  668.           ulStartFlags,
  669.           &concb,
  670.           0 );
  671.  
  672. #endif
  673.   return ( ulrc );
  674. }
  675. #ifdef CONNECTION
  676. /************************ START OF SPECIFICATIONS **************************
  677. *
  678. * SUBROUTINE NAME: GetSpcbkey
  679. *
  680. * DESCRIPTIVE NAME: This function starts a streaming network.
  681. *
  682. * FUNCTION:
  683. *
  684. *************************** END OF SPECIFICATIONS *************************/
  685. ULONG GetSpcbKeyInfo( INSTANCE *pInstance )
  686. {
  687.   ULONG    ulrc;
  688.  
  689.   /*----------------------------------------------------------
  690.   * Retrieve the mmtime and byte per unit numbers from the
  691.   * SPCB key so that can calculate values for seeks etc.
  692.   * This information will also be used to communicate network
  693.   * usage parameters to network io procs.
  694.   *---------------------------------------------------------*/
  695.   ulrc = SpiGetProtocol( 2, //pInstance->pconcb->hid,
  696.                          pInstance->pconcb->pspcbkey,
  697.                          &pInstance->StreamInfo.spcb );
  698.  
  699.   if ( ulrc )
  700.      {
  701.      return ( ulrc );
  702.      }
  703.  
  704.   pInstance->ulBytes  = pInstance->StreamInfo.spcb.ulBytesPerUnit;
  705.   pInstance->ulMMTime = pInstance->StreamInfo.spcb.mmtimePerUnit;
  706.  
  707.   return ( ulrc );
  708. }
  709. #endif
  710.