void SoundSource::Update(float timeStep) { if (!audio_ || !IsEnabledEffective()) return; // If there is no actual audio output, perform fake mixing into a nonexistent buffer to check stopping/looping if (!audio_->IsInitialized()) MixNull(timeStep); // Free the stream if playback has stopped if (soundStream_ && !position_) StopLockless(); bool playing = IsPlaying(); if (!playing && sendFinishedEvent_) { sendFinishedEvent_ = false; // Make a weak pointer to self to check for destruction during event handling WeakPtr<SoundSource> self(this); soundFinished(node_,this,sound_); //TODO: verify same semantics as original : node_->SendEvent(E_SOUNDFINISHED, eventData); if (self.Expired()) return; DoAutoRemove(autoRemove_); } }
void SoundSource::Update(float timeStep) { if (!audio_ || !IsEnabledEffective()) return; // If there is no actual audio output, perform fake mixing into a nonexistent buffer to check stopping/looping if (!audio_->IsInitialized()) MixNull(timeStep); // Free the stream if playback has stopped if (soundStream_ && !position_) StopLockless(); // Check for autoremove if (autoRemove_) { if (!IsPlaying()) { autoRemoveTimer_ += timeStep; if (autoRemoveTimer_ > AUTOREMOVE_DELAY) { Remove(); // Note: this object is now deleted, so only returning immediately is safe return; } } else autoRemoveTimer_ = 0.0f; } }