Mercurial > fife-parpg
changeset 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 | ad5818097cd6 |
children | f55ddf7fdad5 |
files | engine/core/audio/soundemitter.cpp engine/core/audio/soundemitter.h |
diffstat | 2 files changed, 26 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- 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 <boost/function.hpp> // 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<void> 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; }; }