Mercurial > fife-parpg
comparison engine/core/audio/soundemitter.cpp @ 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 | 454ed60ad7b2 |
children |
comparison
equal
deleted
inserted
replaced
359:ad5818097cd6 | 360:11896fe26c1d |
---|---|
101 m_soundclip->addRef(); | 101 m_soundclip->addRef(); |
102 | 102 |
103 attachSoundClip(); | 103 attachSoundClip(); |
104 } | 104 } |
105 | 105 |
106 void SoundEmitter::setCallback(const type_callback& cb) { | |
107 m_callback = cb; | |
108 } | |
109 | |
106 void SoundEmitter::attachSoundClip() { | 110 void SoundEmitter::attachSoundClip() { |
107 if (!m_soundclip->isStream()) { | 111 if (!m_soundclip->isStream()) { |
108 // non-streaming | 112 // non-streaming |
109 alSourceQueueBuffers(m_source, m_soundclip->countBuffers(), m_soundclip->getBuffers()); | 113 alSourceQueueBuffers(m_source, m_soundclip->countBuffers(), m_soundclip->getBuffers()); |
110 alSourcei(m_source, AL_LOOPING, m_loop ? AL_TRUE : AL_FALSE); | 114 alSourcei(m_source, AL_LOOPING, m_loop ? AL_TRUE : AL_FALSE); |
143 // check if the playback has been finished | 147 // check if the playback has been finished |
144 alGetSourcei(m_source, AL_BUFFERS_QUEUED, &bufs); | 148 alGetSourcei(m_source, AL_BUFFERS_QUEUED, &bufs); |
145 if (bufs == 0) { | 149 if (bufs == 0) { |
146 setPeriod(-1); | 150 setPeriod(-1); |
147 alSourceStop(m_source); | 151 alSourceStop(m_source); |
152 if(m_callback) { | |
153 m_callback(); | |
154 } | |
148 } | 155 } |
149 continue; | 156 continue; |
150 } | 157 } |
151 } | 158 } |
152 alSourceQueueBuffers(m_source, 1, &buffer); | 159 alSourceQueueBuffers(m_source, 1, &buffer); |