home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / toolkit / mm / ultimoio / ulsrv.c < prev   
C/C++ Source or Header  |  1996-11-19  |  16KB  |  277 lines

  1. /*************************START OF SPECIFICATIONS *************************/
  2. /* SOURCE FILE NAME:  ULSRV.C                                             */
  3. /*                                                                        */
  4. /* DESCRIPTIVE NAME: File Format Specific IO Proc service routines        */
  5. /*                                                                        */
  6. /* COPYRIGHT:     IBM - International Business Machines                   */
  7. /*            Copyright (c) IBM Corporation  1991, 1992, 1993             */
  8. /*                        All Rights Reserved                             */
  9. /*                                                                        */
  10. /* STATUS: OS/2 Release 2.0                                               */
  11. /*                                                                        */
  12. /* FUNCTION: This source module contains service routines for the IOProc. */
  13. /*                                                                        */
  14. /* NOTES:                                                                 */
  15. /*    DEPENDENCIES: none                                                  */
  16. /*    RESTRICTIONS: Runs in 32 bit protect mode (OS/2 2.0)                */
  17. /*                                                                        */
  18. /* ENTRY POINTS:                                                          */
  19. /*      ffSeekTrack                                                       */
  20. /*      ffSeekToDataBegin                                                 */
  21. /*      ffFindExtAudioTrack                                               */
  22. /*      ffCleanUp                                                         */
  23. /*                                                                        */
  24. /************************** END OF SPECIFICATIONS *************************/
  25.  
  26. #include        <stdio.h>
  27. #include        <string.h>
  28. #include        <stdlib.h>
  29. #include        <memory.h>
  30.  
  31. #define         INCL_DOS                      /* #define  INCL_DOSPROCESS  */
  32. #define         INCL_ERRORS
  33. #define         INCL_WIN
  34. #define         INCL_GPI
  35. #include        <os2.h>                       /* OS/2 headers              */
  36. #include        <pmbitmap.h>
  37.  
  38. #define         INCL_OS2MM
  39. #define         INCL_MMIO_CODEC
  40. #define         INCL_MMIO_DOSIOPROC
  41. #include        <os2me.h>                     /* Multi-Media IO extensions */
  42. #include        <hhpheap.h>
  43. #include        <ioi.h>
  44.  
  45.  
  46. /************************** START OF SPECIFICATIONS *************************/
  47. /*                                                                          */
  48. /* SUBROUTINE NAME: ffSeekTrack                                             */
  49. /*                                                                          */
  50. /* DESCRIPTIVE NAME: Do seek within a track of a file                       */
  51. /*                                                                          */
  52. /* FUNCTION: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  */
  53. /*                                                                          */
  54. /* NOTES: None                                                              */
  55. /*                                                                          */
  56. /* ENTRY POINT: SeekTrack                                                   */
  57. /*   LINKAGE:   CALL FAR (00:32)                                            */
  58. /*                                                                          */
  59. /* INPUT:                                                                   */
  60. /*              CCCCCT     CCCC                                             */
  61. /*              CCCCC      CCCCCCCC                                         */
  62. /*                                                                          */
  63. /* EXIT-NORMAL:                                                             */
  64. /*                                                                          */
  65. /* EXIT-ERROR:                                                              */
  66. /*              NULL (0L)                                                   */
  67. /*                                                                          */
  68. /* SIDE EFFECTS:                                                            */
  69. /*                                                                          */
  70. /*************************** END OF SPECIFICATIONS **************************/
  71. LONG ffSeekTrack ( PMMIOINFO pmmioinfo,
  72.                    HMMIO hmmio,
  73.                    LONG lSeekValue,
  74.                    LONG lSeekType )
  75.  
  76. {
  77.    LONG   rc = MMIO_SUCCESS;
  78.  
  79.    /************************************************************************/
  80.    /* Translated Seek (Seek past header if seek position = 0)              */
  81.    /************************************************************************/
  82.    if (pmmioinfo->ulTranslate & MMIO_TRANSLATEDATA) {
  83.       //
  84.       //  ##BILL currently un-supported
  85.       //
  86.       }
  87.  
  88.    /************************************************************************/
  89.    /* Raw Seek (Seek to absolute position without regard for headers)      */
  90.    /************************************************************************/
  91.    else {
  92.       //
  93.       //  ##BILL currently un-supported
  94.       //
  95.       }
  96.  
  97.  
  98.   return(rc);
  99. }
  100.  
  101.  
  102. /************************** START OF SPECIFICATIONS *************************/
  103. /*                                                                          */
  104. /* SUBROUTINE NAME:  ffSeekToDataBegin                                      */
  105. /*                                                                          */
  106. /* DESCRIPTIVE NAME: Seek to the beginning of the data (in file not track)  */
  107. /*                                                                          */
  108. /* FUNCTION: This function seeks to the beginning of the file data.         */
  109. /*                                                                          */
  110. /*                                                                          */
  111. /* NOTES: None                                                              */
  112. /*                                                                          */
  113. /* ENTRY POINT: ffSeekToDataBegin                                           */
  114. /*   LINKAGE:   CALL FAR (00:32)                                            */
  115. /*                                                                          */
  116. /* INPUT:     PMMIOINFO  pmmioinfo - pointer to MMIOINFO instance structure */
  117. /*            PINSTANCE  pinstance - pointer to instance structure          */
  118. /*                                                                          */
  119. /*                                                                          */
  120. /* EXIT-NORMAL:                                                             */
  121. /*              lNewPosition                                                */
  122. /*                                                                          */
  123. /* EXIT-ERROR:                                                              */
  124. /*              MMIO_ERROR                                                  */
  125. /*                                                                          */
  126. /* SIDE EFFECTS:                                                            */
  127. /*                                                                          */
  128. /*************************** END OF SPECIFICATIONS **************************/
  129. LONG ffSeekToDataBegin ( PMMIOINFO pmmioinfo,
  130.                          PINSTANCE pinstance)
  131.  
  132. {
  133.    LONG            rc = MMIO_SUCCESS;                      /* Return code.         */
  134.    LONG            lFilePosition;                          /* File position.       */
  135.    MMCKINFO        mmckinfo;
  136.  
  137.    /* Check if we already know where data begins, if so, then no need to do descend again */
  138.    if (pinstance->ulMisc1) {
  139.       lFilePosition = ioSeekFile((PLONG)&pmmioinfo->ulErrorRet,pinstance->hmmioFileHandle,pinstance->ulMisc2);
  140.       if (lFilePosition < MMIO_SUCCESS) {
  141.          return(MMIO_ERROR);
  142.          }
  143.       }
  144.  
  145.    else {
  146.       /* set file pointer to beginning of file.*/
  147.       lFilePosition = ioSeekFile((PLONG)&pmmioinfo->ulErrorRet,pinstance->hmmioFileHandle,0L);
  148.       if (lFilePosition < MMIO_SUCCESS) {
  149.          return(MMIO_ERROR);
  150.          }
  151.  
  152.       /* Descend into the RIFF chunk */
  153.       memset (&mmckinfo, '\0', sizeof(MMCKINFO));
  154.       mmckinfo.fccType = mmioStringToFOURCC(UMFORM_MOVIE ,0L);
  155.       if (rc = mmioDescend(pinstance->hmmioFileHandle,
  156.                            &mmckinfo,
  157.                            NULL,
  158.                            MMIO_FINDRIFF)) {
  159.          pmmioinfo->ulErrorRet = rc;
  160.          return (MMIO_ERROR);
  161.          }
  162.  
  163.       /* Find the Data Frame List Chunk                                          */
  164.       memset (&mmckinfo, '\0', sizeof(MMCKINFO));
  165.       mmckinfo.fccType = mmioStringToFOURCC(UMFORM_FRAMEDATALIST,0L);
  166.       if (rc = mmioDescend(pinstance->hmmioFileHandle,
  167.                            &mmckinfo,
  168.                            NULL,
  169.                            MMIO_FINDLIST)) {
  170.          pmmioinfo->ulErrorRet = rc;
  171.          return (MMIO_ERROR);
  172.          }
  173.  
  174.       lFilePosition = mmckinfo.ulDataOffset + SIZEOF_FORM;
  175.       pinstance->ulMisc1 = lFilePosition + mmckinfo.ckSize - SIZEOF_FORM;  /* Save end of chunk list for read routine */
  176.       pinstance->ulMisc2 = lFilePosition;      /* Save start of chunk list for read routine */
  177.       }
  178.  
  179.    return(lFilePosition);
  180. }
  181.  
  182.  
  183. /************************** START OF SPECIFICATIONS *************************/
  184. /*                                                                          */
  185. /* SUBROUTINE NAME: ffFindExtAudioTrack                                     */
  186. /*                                                                          */
  187. /* DESCRIPTIVE NAME: Find an external audio track and return ptr to tracki. */
  188. /*                                                                          */
  189. /* FUNCTION: Finds the first external audio file tracki structure.          */
  190. /*                                                                          */
  191. /* NOTES: None                                                              */
  192. /*                                                                          */
  193. /* ENTRY POINT: ffFindExtAudioTrack                                         */
  194. /*   LINKAGE:   CALL FAR (00:32)                                            */
  195. /*                                                                          */
  196. /* INPUT:                                                                   */
  197. /*              CCCCCT     CCCC                                             */
  198. /*              CCCCC      CCCCCCCC                                         */
  199. /*                                                                          */
  200. /* EXIT-NORMAL:  ptracki                                                    */
  201. /*                                                                          */
  202. /* EXIT-ERROR:  NULL (0L)                                                   */
  203. /*                                                                          */
  204. /* SIDE EFFECTS:                                                            */
  205. /*                                                                          */
  206. /*************************** END OF SPECIFICATIONS **************************/
  207. PTRACKI ffFindExtAudioTrack ( PINSTANCE pinstance,
  208.                               ULONG ulNumTracks,
  209.                               PTRACKMAP patrackmapList)
  210.  
  211. {
  212. //   PTRACKI    ptracki;      /* Pointer to internal track structure */
  213. //   ULONG      i;
  214. //
  215. //   /**************************************************************************/
  216. //   /* For each track to see if there is a reference to an external audio     */
  217. //   /* file track. AND make sure that at least one entry is provided for      */
  218. //   /* in the trackmap table for the record information.                      */
  219. //   /**************************************************************************/
  220. //   for ( i = 0; i < ulNumTracks; i++) {
  221. //      ptracki = ioFindTracki(pinstance,patrackmapList[i].ulTrackID);
  222. //      if ((ptracki->hmmioTrackFileHandle) && (ptracki->ulNumEntries)) {
  223. //         return(ptracki);
  224. //         }
  225. //      }
  226.     return(NULL);
  227. }
  228.  
  229.  
  230. /************************** START OF SPECIFICATIONS *************************/
  231. /*                                                                          */
  232. /* SUBROUTINE NAME: ffCleanUp                                               */
  233. /*                                                                          */
  234. /* DESCRIPTIVE NAME: Ultimotion specific clean up routine                   */
  235. /*                                                                          */
  236. /* FUNCTION: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  */
  237. /*                                                                          */
  238. /* NOTES: None                                                              */
  239. /*                                                                          */
  240. /* ENTRY POINT: ffCleanUp                                                   */
  241. /*   LINKAGE:   CALL FAR (00:32)                                            */
  242. /*                                                                          */
  243. /* INPUT:                                                                   */
  244. /*              CCCCCT     CCCC                                             */
  245. /*              CCCCC      CCCCCCCC                                         */
  246. /*                                                                          */
  247. /* EXIT-NORMAL:                                                             */
  248. /*                                                                          */
  249. /* EXIT-ERROR:                                                              */
  250. /*                                                                          */
  251. /* SIDE EFFECTS:                                                            */
  252. /*                                                                          */
  253. /*************************** END OF SPECIFICATIONS **************************/
  254. LONG ffCleanUp ( PINSTANCE pinstance )
  255.  
  256. {
  257. //-PTRACKI         ptracki;                       /* Pointer to track list. */   /*OLD_EXTAUDIO*/
  258. //                                                                               /*OLD_EXTAUDIO*/
  259. ///**************************************************************************/   /*OLD_EXTAUDIO*/
  260. ///* ptrackiList is a link list, CleanUp all external audio read buffers.   */   /*OLD_EXTAUDIO*/
  261. ///**************************************************************************/   /*OLD_EXTAUDIO*/
  262. // while (pinstance->ptrackiList) {                                              /*OLD_EXTAUDIO*/
  263. //    ptracki = pinstance->ptrackiList;                                          /*OLD_EXTAUDIO*/
  264. //    if (ptracki) {                                                             /*OLD_EXTAUDIO*/
  265. //       if (ptracki->ulMisc2) {                                                 /*OLD_EXTAUDIO*/
  266. //          ENTERCRITX;                                                          /*OLD_EXTAUDIO*/ 
  267. //          HhpFreeMem(hheap,(PVOID)ptracki->ulMisc2);                           /*OLD_EXTAUDIO*/
  268. //          EXITCRIT;                                                            /*OLD_EXTAUDIO*/
  269. //          ptracki->ulMisc2 = 0L;                                               /*OLD_EXTAUDIO*/
  270. //          }                                                                    /*OLD_EXTAUDIO*/
  271. //       pinstance->ptrackiList = ptracki->ptrackiNext;                          /*OLD_EXTAUDIO*/
  272. //       }                                                                       /*OLD_EXTAUDIO*/
  273. //----} /* end loop */                                                           /*OLD_EXTAUDIO*/
  274.  
  275.    return(MMIO_SUCCESS);
  276. }
  277.