00001 // 00002 // Copyright 2002,2003,2004 Sony Corporation 00003 // 00004 // Permission to use, copy, modify, and redistribute this software for 00005 // non-commercial use is hereby granted. 00006 // 00007 // This software is provided "as is" without warranty of any kind, 00008 // either expressed or implied, including but not limited to the 00009 // implied warranties of fitness for a particular purpose. 00010 // 00011 00012 #ifndef SoundPlay_h_DEFINED 00013 #define SoundPlay_h_DEFINED 00014 00015 #include <OPENR/OObject.h> 00016 #include <OPENR/OSubject.h> 00017 #include <OPENR/OObserver.h> 00018 #include "WAV.h" 00019 #include "def.h" 00020 00021 enum SoundPlayState { 00022 SPS_IDLE, 00023 SPS_START 00024 }; 00025 00026 static const char* const SPEAKER_LOCATOR = "PRM:/r1/c1/c2/c3/s1-Speaker:S1"; 00027 static const char* const SPEAKER_LOCATOR_ERS7 = "PRM:/s1-Speaker:S1"; 00028 00029 class SoundPlay : public OObject { 00030 public: 00031 SoundPlay(); 00032 virtual ~SoundPlay() {} 00033 00034 OSubject* subject[numOfSubject]; 00035 OObserver* observer[numOfObserver]; 00036 00037 virtual OStatus DoInit (const OSystemEvent& event); 00038 virtual OStatus DoStart (const OSystemEvent& event); 00039 virtual OStatus DoStop (const OSystemEvent& event); 00040 virtual OStatus DoDestroy(const OSystemEvent& event); 00041 00042 void Ready(const OReadyEvent& event); 00043 00044 private: 00045 static const size_t SOUND_NUM_BUFFER = 2; 00046 00047 void OpenSpeaker(); 00048 void NewSoundVectorData(); 00049 void LoadWAV(); 00050 void SetPowerAndVolume(); 00051 WAVError CopyWAVTo(RCRegion* region); 00052 RCRegion* FindFreeRegion(); 00053 00054 SoundPlayState soundPlayState; 00055 OPrimitiveID speakerID; 00056 ODesignDataID wavID; 00057 WAV wav; 00058 RCRegion* region[SOUND_NUM_BUFFER]; 00059 }; 00060 00061 #endif // SoundPlay_h_DEFINED