home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / audio / wavefile / wavefile.h < prev    next >
C/C++ Source or Header  |  1997-10-05  |  4KB  |  133 lines

  1. /**************************************************************************
  2.  *
  3.  *  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4.  *  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5.  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6.  *  PURPOSE.
  7.  *
  8.  *  Copyright (C) 1992 - 1997 Microsoft Corporation.  All Rights Reserved.
  9.  *
  10.  **************************************************************************/
  11. /****************************************************************************
  12.  *
  13.  *  WAVEFILE.H
  14.  *
  15.  *  header file for routines for reading WAVE files
  16.  *
  17.  ***************************************************************************/
  18.  
  19. /*    -    -    -    -    -    -    -    -    */
  20. #include "extra.h"
  21. #include "wavefile.rc"
  22.  
  23. extern HMODULE ghModule; // = NULL; // global HMODULE/HINSTANCE for resource access
  24. /*    -    -    -    -    -    -    -    -    */
  25.  
  26. /*
  27. ** This class is used to implement a handler for a type of file with only
  28. ** one stream.  In this case, we don't have to worry about allocating more
  29. ** than one stream object for each file object, so we can combine the
  30. ** two together in a single class.
  31. **
  32. */
  33.  
  34. HRESULT WaveFileCreate(
  35.     IUnknown FAR*    pUnknownOuter,
  36.     REFIID        riid,
  37.     void FAR* FAR*    ppv);
  38.  
  39. typedef struct {
  40.  
  41.     /*
  42.     ** This implementation of a file handler is done in C, not C++, so a few
  43.     ** things work differently than in C++.  Our structure contains Vtbls
  44.     ** (pointer to function tables) for three interfaces... Unknown, AVIStream,
  45.     ** and AVIFile, as well as our private data we need to implement the
  46.     ** handler.
  47.     **
  48.     */
  49.  
  50.     IAVIStreamVtbl FAR    *AVIStream;
  51.     IAVIFileVtbl FAR    *AVIFile;
  52.     IUnknownVtbl FAR    *Unknown;
  53.     IPersistFileVtbl FAR    *Persist;
  54.  
  55.     // This is our controlling object.
  56.     IUnknown FAR*    pUnknownOuter;
  57.  
  58.     //
  59.     // WaveFile instance data
  60.     //
  61.     HMMIO            hmmio;        // file I/O
  62.  
  63.     MMCKINFO        ckData;
  64.  
  65.     LONG            refs;        // for UNKNOWN
  66.     AVISTREAMINFOW        avistream;    // for STREAM
  67.  
  68.     LPWAVEFORMAT        lpFormat;    // stream format
  69.     LONG            cbFormat;
  70.     BOOL            fDirty;
  71.     UINT            mode;
  72.     EXTRA            extra;
  73.     AVIFILEINFOW        avihdr;
  74. } WAVESTUFF, FAR *LPWAVESTUFF;
  75.  
  76. /*
  77. ** Whenever a function is called with a pointer to one of our Vtbls, we need
  78. ** to back up and get a pointer to the beginning of our structure.  Depending
  79. ** on which pointer we are passed, we need to back up a different number of
  80. ** bytes.  C++ would make this easier, by declaring backpointers.
  81. */
  82.  
  83. WAVESTUFF ws;
  84. #define WAVESTUFF_FROM_UNKNOWN(pu)    (LPWAVESTUFF)((LPBYTE)(pu) - ((LPBYTE)&ws.Unknown - (LPBYTE)&ws))
  85. #define WAVESTUFF_FROM_FILE(pf)        (LPWAVESTUFF)((LPBYTE)(pf) - ((LPBYTE)&ws.AVIFile - (LPBYTE)&ws))
  86. #define WAVESTUFF_FROM_STREAM(ps)    (LPWAVESTUFF)((LPBYTE)(ps) - ((LPBYTE)&ws.AVIStream - (LPBYTE)&ws))
  87. #define WAVESTUFF_FROM_PERSIST(ppf)    (LPWAVESTUFF)((LPBYTE)(ppf) - ((LPBYTE)&ws.Persist - (LPBYTE)&ws))
  88.  
  89. /*    -    -    -    -    -    -    -    -    */
  90.  
  91. /*
  92. ** This class is our version of the IClassFactory interface.
  93. **
  94. ** COMPOBJ.DLL expects our DllGetClassObject() function to return an
  95. ** IClassFactory object which it can then call to get the object that
  96. ** implements the IAVIFile interface to actually open the file.  Whew.
  97. */
  98. typedef struct {
  99.     IClassFactoryVtbl FAR *lpVtbl;
  100.  
  101.     /*
  102.     ** Data local to this object: reference counts for the object
  103.     */
  104.     ULONG    ulRef;
  105.     CLSID FAR *    clsid;
  106. } WAVEFACTORY, FAR *LPWAVEFACTORY;
  107.  
  108. /*    -    -    -    -    -    -    -    -    */
  109.  
  110. /*
  111. ** These variables help keep track of whether the DLL is still in use,
  112. ** so that when our DllCanUnloadNow() function is called, we know what
  113. ** to say.
  114. */
  115.  
  116. extern UINT    uUseCount;
  117. extern UINT    uLockCount;
  118.  
  119. /*    -    -    -    -    -    -    -    -    */
  120.  
  121. //
  122. // This is our unique identifier
  123. //
  124. //  NOTE: If you modify this sample code to do something else, you MUST
  125. //        CHANGE THIS!
  126. //
  127. //  Run uuidgen.exe from the tools directory and get your own GUID.
  128. //  DO NOT USE THIS ONE!
  129. //
  130. //
  131. //
  132. DEFINE_GUID(CLSID_AVIWaveFileReader, 0x00020003, 0, 0, 0xC0,0,0,0,0,0,0,0x46);
  133.