home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / OWLSRC.PAK / MCIWAV.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  1.6 KB  |  67 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.6  $
  6. //  Implements TMciWaveAudio
  7. //----------------------------------------------------------------------------
  8. #include <owl/pch.h>
  9. #if !defined(OWL_MCI_H)
  10. # include <owl/mci.h>
  11. #endif
  12.  
  13. OWL_DIAGINFO;
  14.  
  15. //
  16. // Initialize the structure for the waveaudio device.
  17. //
  18. static void InitParms(MCI_OPEN_PARMS& parms, uint32& command, const char far* deviceName,
  19.   const char far* elementName = 0, uint16 id = 0)
  20. {
  21.   command = (id == 0) ? MCI_OPEN_TYPE : MCI_OPEN_TYPE_ID;
  22.  
  23.   if (elementName != 0)  {
  24.     command |= MCI_OPEN_ELEMENT;
  25.     parms.lpstrElementName = elementName;
  26.   }
  27.  
  28.   parms.lpstrDeviceType = (id == 0) ? deviceName :
  29.                                       (LPSTR)MkUint32((uint16)deviceName, id);
  30. }
  31.  
  32. //
  33. // Constructs an MCI waveaudio (.WAV) device.
  34. //
  35. TMciWaveAudio::TMciWaveAudio(const char far* elementName,
  36.   const char far* deviceName, uint16 id)
  37. {
  38.   MCI_OPEN_PARMS parms;
  39.   uint32 command;
  40.  
  41.   ::InitParms(parms, command, deviceName == 0 ? "waveaudio" : deviceName,
  42.     elementName, id);
  43.   Open(parms, command);
  44. }
  45.  
  46. //
  47. // Plays the file on the waveaudio device.
  48. //
  49. uint32
  50. TMciWaveAudio::Play(uint32 flags, uint32 from, uint32 to)
  51. {
  52.   MCI_PLAY_PARMS parms;
  53.  
  54.   if (flags & MCI_NOTIFY)
  55.     parms.dwCallback = GetCallback();
  56.  
  57.   flags |= MCI_FROM;
  58.   parms.dwFrom = from;
  59.  
  60.   if (to != 0) {
  61.     flags |= MCI_TO;
  62.     parms.dwTo = to;
  63.   }
  64.  
  65.   return TMci::Play(parms, flags);
  66. }
  67.