comparison engine/core/audio/soundemitter.h @ 360:11896fe26c1d

Added SoundEmitter::setCallback(). The callback will be called when a stream has finished playing. The SWIG interface for this function currently does NOT exist. [t:346]
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 02 Oct 2009 14:05:08 +0000
parents 362fe23920b9
children 64738befdf3b
comparison
equal deleted inserted replaced
359:ad5818097cd6 360:11896fe26c1d
25 // Standard C++ library includes 25 // Standard C++ library includes
26 26
27 // Platform specific includes 27 // Platform specific includes
28 28
29 // 3rd party library includes 29 // 3rd party library includes
30 #include <boost/function.hpp>
30 31
31 // FIFE includes 32 // FIFE includes
32 // These includes are split up in two parts, separated by one empty line 33 // These includes are split up in two parts, separated by one empty line
33 // First block: files included from the FIFE root src directory 34 // First block: files included from the FIFE root src directory
34 // Second block: files included from the same folder 35 // Second block: files included from the same folder
44 45
45 /** The class for playing audio files 46 /** The class for playing audio files
46 */ 47 */
47 class SoundEmitter : private TimeEvent { 48 class SoundEmitter : private TimeEvent {
48 public: 49 public:
50 typedef boost::function0<void> type_callback;
51
49 SoundEmitter(SoundManager* manager, SoundClipPool* pool, unsigned int uid); 52 SoundEmitter(SoundManager* manager, SoundClipPool* pool, unsigned int uid);
50
51 ~SoundEmitter(); 53 ~SoundEmitter();
52 54
53 /** Returns the emitter-id 55 /** Returns the emitter-id
54 */ 56 */
55 unsigned int getID() { 57 unsigned int getID() {
76 78
77 /** Sets the sound clip to be used by this emitter. 79 /** Sets the sound clip to be used by this emitter.
78 * @param sound_id SoundClipPool id of the sound to be used. 80 * @param sound_id SoundClipPool id of the sound to be used.
79 */ 81 */
80 void setSoundClip(unsigned int sound_id); 82 void setSoundClip(unsigned int sound_id);
83
84 /** Sets the callback to use when the STREAM has finished being played.
85 * NOTE: This only works with streaming audio.
86 *
87 * @param cb function callback
88 */
89 void setCallback(const type_callback& cb);
81 90
82 /** Reset the emitter, free all internal buffers 91 /** Reset the emitter, free all internal buffers
83 * 92 *
84 * @param defaultall If set to true, emitter position, velocity, gain and type will be set to the default values 93 * @param defaultall If set to true, emitter position, velocity, gain and type will be set to the default values
85 */ 94 */
183 192
184 /** Internal function to attach a soundclip to the source 193 /** Internal function to attach a soundclip to the source
185 */ 194 */
186 void attachSoundClip(); 195 void attachSoundClip();
187 196
188 SoundManager* m_manager; 197 SoundManager* m_manager;
189 SoundClipPool* m_pool; 198 SoundClipPool* m_pool;
190 ALuint m_source; // The openAL-source 199 ALuint m_source; // The openAL-source
191 SoundClip* m_soundclip; // the attached soundclip 200 SoundClip* m_soundclip; // the attached soundclip
192 unsigned int m_soundclipid;// id of the attached soundclip 201 unsigned int m_soundclipid;// id of the attached soundclip
193 unsigned int m_streamid; // the id of the stream 202 unsigned int m_streamid; // the id of the stream
194 unsigned int m_emitterid; // the emitter-id 203 unsigned int m_emitterid; // the emitter-id
195 bool m_loop; // loop? 204 bool m_loop; // loop?
205 type_callback m_callback;
196 }; 206 };
197 } 207 }
198 208
199 #endif 209 #endif