# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1254492308 0 # Node ID 11896fe26c1daad46b41615c4d111dab36a1804b # Parent ad5818097cd6e8cfb18799e76cda46bd8b09e2f7 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] diff -r ad5818097cd6 -r 11896fe26c1d engine/core/audio/soundemitter.cpp --- a/engine/core/audio/soundemitter.cpp Sat Sep 26 10:38:24 2009 +0000 +++ b/engine/core/audio/soundemitter.cpp Fri Oct 02 14:05:08 2009 +0000 @@ -103,6 +103,10 @@ attachSoundClip(); } + void SoundEmitter::setCallback(const type_callback& cb) { + m_callback = cb; + } + void SoundEmitter::attachSoundClip() { if (!m_soundclip->isStream()) { // non-streaming @@ -145,6 +149,9 @@ if (bufs == 0) { setPeriod(-1); alSourceStop(m_source); + if(m_callback) { + m_callback(); + } } continue; } diff -r ad5818097cd6 -r 11896fe26c1d engine/core/audio/soundemitter.h --- a/engine/core/audio/soundemitter.h Sat Sep 26 10:38:24 2009 +0000 +++ b/engine/core/audio/soundemitter.h Fri Oct 02 14:05:08 2009 +0000 @@ -27,6 +27,7 @@ // Platform specific includes // 3rd party library includes +#include // FIFE includes // These includes are split up in two parts, separated by one empty line @@ -46,8 +47,9 @@ */ class SoundEmitter : private TimeEvent { public: + typedef boost::function0 type_callback; + SoundEmitter(SoundManager* manager, SoundClipPool* pool, unsigned int uid); - ~SoundEmitter(); /** Returns the emitter-id @@ -79,6 +81,13 @@ */ void setSoundClip(unsigned int sound_id); + /** Sets the callback to use when the STREAM has finished being played. + * NOTE: This only works with streaming audio. + * + * @param cb function callback + */ + void setCallback(const type_callback& cb); + /** Reset the emitter, free all internal buffers * * @param defaultall If set to true, emitter position, velocity, gain and type will be set to the default values @@ -185,14 +194,15 @@ */ void attachSoundClip(); - SoundManager* m_manager; - SoundClipPool* m_pool; - ALuint m_source; // The openAL-source - SoundClip* m_soundclip; // the attached soundclip - unsigned int m_soundclipid;// id of the attached soundclip - unsigned int m_streamid; // the id of the stream - unsigned int m_emitterid; // the emitter-id - bool m_loop; // loop? + SoundManager* m_manager; + SoundClipPool* m_pool; + ALuint m_source; // The openAL-source + SoundClip* m_soundclip; // the attached soundclip + unsigned int m_soundclipid;// id of the attached soundclip + unsigned int m_streamid; // the id of the stream + unsigned int m_emitterid; // the emitter-id + bool m_loop; // loop? + type_callback m_callback; }; }