home *** CD-ROM | disk | FTP | other *** search
/ Game Audio Programming / GameAudioProgramming.iso / Game_Audio / audio_sdk / src / AudioLib / Segment.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-07-06  |  2.5 KB  |  101 lines

  1. /***********************************************************\
  2. Copyright (C) James Boer, 2002. 
  3. All rights reserved worldwide.
  4.  
  5. This software is provided "as is" without express or implied
  6. warranties. You may freely copy and compile this source into
  7. applications you distribute provided that the copyright text
  8. below is included in the resulting source code, for example:
  9. "Portions Copyright (C) James Boer, 2002"
  10. \***********************************************************/
  11. #ifndef __SEGMENT_H
  12. #define __SEGMENT_H
  13.  
  14. #include "Audio.h"
  15. #include "FileStream.h"
  16.  
  17. struct IDirectMusicSegment8;
  18. struct IDirectMusicSegmentState8;
  19. struct IDirectMusicAudioPath;
  20.  
  21. namespace Audio
  22. {
  23.  
  24.  
  25.  
  26. class Segment : public ISegment
  27. {
  28. DEFINE_POOL(Segment);
  29.  
  30. public:
  31.     bool Init(const SegmentInit& init);
  32.     void Destroy();
  33.  
  34.     bool IsInitialized() const    {  return m_bInitialized;  }
  35.  
  36.     bool Load();
  37.     bool Unload();
  38.     bool IsLoaded()    const    {  return m_bLoaded;  }
  39.  
  40.     // Required interface functions
  41.     bool Play();
  42.     bool Stop();
  43.     bool Pause();
  44.  
  45.     bool IsPlaying() const;
  46.     bool IsPaused() const;
  47.  
  48.     bool IsLooping() const;
  49.  
  50.     // Generic property support (for driver-specific extensions)
  51.     bool QuerySupport(const GUID& guid, uint32 nID, uint32* pTypeSupport);
  52.     bool Get(const GUID& guidProperty, uint32 nID, void* pInstanceData,
  53.         uint32 nInstanceLength, void* pPropData, 
  54.         uint32 nPropLength, uint32* pBytesReturned);
  55.     bool Set(const GUID& guidProperty, uint32 nID, void* pInstanceData,
  56.         uint32 nInstanceLength, void* pPropData, 
  57.         uint32 nPropLength, bool bStoreProperty);
  58.  
  59. public:
  60.     void Term();
  61.     IDirectMusicSegment8* Obj()
  62.     {  return m_pSegment;  }
  63.     void Clear();
  64.     uint32 GetLastPlayTime() const;
  65.     bool operator < (const Segment& seg) const;
  66.     bool IsLoading()            {  return m_bLoading;  }
  67.     bool DoLoad();
  68.     bool IsMusic()                {  return m_Init.m_bMusic;  }
  69.  
  70. private:
  71.     Segment();
  72.     virtual ~Segment();
  73.     // Actually plays the segment.  The Play() call may only queue the
  74.     // segment to play next, if there is a segment already playing.
  75.     bool DoPlay();
  76.  
  77.  
  78. private:
  79.  
  80.     IDirectMusicSegment8*        m_pSegment;
  81.     IDirectMusicSegmentState8*    m_pSegState;
  82.     SegmentInit                    m_Init;
  83.     bool                        m_bInitialized;
  84.     bool                        m_bPaused;
  85.     bool                        m_b3DSegment;
  86.     int32                        m_iPlayStartTime;
  87.     int32                        m_iPauseTime;
  88.  
  89.     // Last time the sound was played (used for prioritization)
  90.     uint32                        m_nLastTimePlayed;
  91.  
  92.     // Load and Play status flags
  93.     bool                        m_bQueuePlayback;
  94.     bool                        m_bLoading;
  95.     bool                        m_bLoaded;
  96. };
  97.  
  98. }; // namespace Audio
  99.  
  100.  
  101. #endif // __SEGMENT_H