home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2003 March / VPR0303A.ISO / AIBO / MoNet / SoundAgent / SoundAgent.h < prev    next >
C/C++ Source or Header  |  2002-12-19  |  2KB  |  74 lines

  1. //
  2. // Copyright 2002 Sony Corporation 
  3. //
  4. // Permission to use, copy, modify, and redistribute this software for
  5. // non-commercial use is hereby granted.
  6. //
  7. // This software is provided "as is" without warranty of any kind,
  8. // either expressed or implied, including but not limited to the
  9. // implied warranties of fitness for a particular purpose.
  10. //
  11.  
  12. #ifndef SoundAgent_h_DEFINED
  13. #define SoundAgent_h_DEFINED
  14.  
  15. #include <OPENR/OObject.h>
  16. #include <OPENR/OSubject.h>
  17. #include <OPENR/OObserver.h>
  18. #include <OPENR/ODataArchive.h>
  19. #include <MoNetData.h>
  20. #include <ODA.h>
  21. #include "WAV.h"
  22. #include "def.h"
  23.  
  24. enum SoundAgentState {
  25.     SAS_IDLE,
  26.     SAS_START,
  27.     SAS_PLAYING
  28. };
  29.  
  30. static const char* const SPEAKER_LOCATOR   = "PRM:/r1/c1/c2/c3/s1-Speaker:S1";
  31.  
  32. class SoundAgent : public OObject {
  33. public:
  34.     SoundAgent();
  35.     virtual ~SoundAgent() {}
  36.  
  37.     OSubject*  subject[numOfSubject];
  38.     OObserver* observer[numOfObserver];
  39.  
  40.     virtual OStatus DoInit   (const OSystemEvent& event);
  41.     virtual OStatus DoStart  (const OSystemEvent& event);
  42.     virtual OStatus DoStop   (const OSystemEvent& event);
  43.     virtual OStatus DoDestroy(const OSystemEvent& event);
  44.  
  45.     void NotifyCommand(const ONotifyEvent& event);
  46.     void ReadyPlay(const OReadyEvent& event);
  47.  
  48. private:
  49.     MoNetStatus Play(int index, OVRSyncKey syncKey, byte* data);
  50.     void        OpenSpeaker();
  51.     void        NewSoundVectorData();
  52.     void        LoadODA();
  53.     void        SetPowerAndVolume();
  54.     WAVError    CopyWAVTo(RCRegion* region);
  55.     RCRegion*   FindFreeRegion();
  56.     void ReplyAgentResult(MoNetAgentID agt, int idx, MoNetStatus st);
  57.  
  58.     //
  59.     // 8KHz 8bits MONO (8 * 1 * 1 * 32 = 256)
  60.     //
  61.     static const size_t SOUND_UNIT_SIZE  = 256; // bytes / 32ms
  62.     static const size_t SOUND_NUM_BUFFER = 4;
  63.  
  64.     SoundAgentState soundAgentState;
  65.     OPrimitiveID    speakerID;
  66.     ODesignDataID   soundDataID;
  67.     ODA             soundODA;
  68.     int             playingIndex;
  69.     WAV             playingWAV;
  70.     RCRegion*       region[SOUND_NUM_BUFFER];
  71. };
  72.  
  73. #endif // SoundAgent_h_DEFINED
  74.