void SoundQueue::fade(EntityIndex entity) { SoundEntry *entry = getEntry(entity); if (entry) { entry->fade(); entry->setEntity(kEntityPlayer); } }
void SoundQueue::removeFromQueue(EntityIndex entity) { Common::StackLock locker(_mutex); SoundEntry *entry = getEntry(entity); if (entry) entry->reset(); }
uint32 SoundQueue::getEntryTime(EntityIndex index) { SoundEntry *entry = getEntry(index); if (entry) return entry->getTime(); return 0; }
void SoundQueue::removeFromQueue(Common::String filename) { Common::StackLock locker(_mutex); SoundEntry *entry = getEntry(filename); if (entry) entry->reset(); }
void SoundQueue::processEntry(SoundType type) { Common::StackLock locker(_mutex); SoundEntry *entry = getEntry(type); if (entry) entry->update(0); }
////////////////////////////////////////////////////////////////////////// // Entry management ////////////////////////////////////////////////////////////////////////// void SoundQueue::setupEntry(SoundType type, EntityIndex index) { Common::StackLock locker(_mutex); SoundEntry *entry = getEntry(type); if (entry) entry->setEntity(index); }
void SoundQueue::fade(Common::String filename) { SoundEntry *entry = getEntry(filename); if (entry) { entry->fade(); entry->setEntity(kEntityPlayer); } }
bool SoundQueue::isBuffered(Common::String filename, bool testForEntity) { SoundEntry *entry = getEntry(filename); if (testForEntity) return entry != NULL && entry->getEntity() != kEntityPlayer; return (entry != NULL); }
uint32 SoundQueue::getEntryTime(EntityIndex index) { Common::StackLock locker(_mutex); SoundEntry *entry = getEntry(index); if (entry) return entry->getTime(); return 0; }
void SoundQueue::processEntry(Common::String filename) { Common::StackLock locker(_mutex); SoundEntry *entry = getEntry(filename); if (entry) { entry->update(0); entry->setEntity(kEntityPlayer); } }
void SoundQueue::processEntry(EntityIndex entity) { Common::StackLock locker(_mutex); SoundEntry *entry = getEntry(entity); if (entry) { entry->update(0); entry->setEntity(kEntityPlayer); } }
void SoundQueue::clearQueue() { Common::StackLock locker(_mutex); _flag |= 8; for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) { SoundEntry *entry = (*i); // Delete entry entry->close(); SAFE_DELETE(entry); i = _soundList.reverse_erase(i); } updateSubtitles(); }
////////////////////////////////////////////////////////////////////////// // Subtitles ////////////////////////////////////////////////////////////////////////// void SoundQueue::updateSubtitles() { Common::StackLock locker(_mutex); uint32 index = 0; SubtitleEntry *subtitle = NULL; for (Common::List<SubtitleEntry *>::iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { uint32 current_index = 0; SoundEntry *soundEntry = (*i)->getSoundEntry(); SoundStatus status = (SoundStatus)soundEntry->getStatus().status; if (!(status & kSoundStatus_40) || status & kSoundStatus_180 || soundEntry->getTime() == 0 || (status & kSoundStatusFilter) < 6 || ((getFlags()->nis & 0x8000) && soundEntry->getPriority() < 90)) { current_index = 0; } else { current_index = soundEntry->getPriority() + (status & kSoundStatusFilter); if (_currentSubtitle == (*i)) current_index += 4; } if (index < current_index) { index = current_index; subtitle = (*i); } } if (_currentSubtitle == subtitle) { if (subtitle) subtitle->setupAndDraw(); return; } if (!subtitle) return; if (_subtitlesFlag & 1) subtitle->drawOnScreen(); subtitle->loadData(); subtitle->setupAndDraw(); }
void SoundQueue::destroyAllSound() { _flag |= 8; for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) { SoundEntry *entry = (*i); if (entry == NULL) error("[SoundQueue::destroyAllSound] Invalid entry found in sound queue"); // Delete entry entry->kill(); SAFE_DELETE(entry); i = _soundList.reverse_erase(i); } updateSubtitles(); }
void SoundQueue::updateQueue() { if (getAmbientState() & kAmbientSoundEnabled) { SoundEntry *entry = getEntry(kSoundTagAmbient); if (!entry || getFlags()->flag_3 || (entry && entry->getTime() > getSound()->getAmbientSoundDuration())) { getSound()->playAmbientSound(0x45); } else { if (getSound()->needToChangeAmbientVolume()) { entry->setVolumeSmoothly(getSound()->getChangedAmbientVolume()); getSound()->clearAmbientVolumeChange(); } } } for (Common::List<SoundEntry *>::iterator it = _soundList.begin(); it != _soundList.end(); ++it) { SoundEntry *entry = *it; if (entry == NULL) error("[SoundQueue::updateQueue] Invalid entry found in sound queue"); // Original removes the entry data from the cache and sets the archive as not loaded // and if the sound data buffer is not full, loads a new entry to be played based on // its priority and volume if (!entry->update() && !(entry->getStatus() & kSoundFlagKeepAfterFinish)) { entry->close(); SAFE_DELETE(entry); it = _soundList.reverse_erase(it); } } // Original update the current entry, loading another set of samples to be decoded getFlags()->flag_3 = false; }
////////////////////////////////////////////////////////////////////////// // Timer ////////////////////////////////////////////////////////////////////////// void SoundQueue::handleTimer() { Common::StackLock locker(_mutex); for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) { SoundEntry *entry = (*i); // When the entry has stopped playing, we remove his buffer if (entry->isFinished()) { entry->close(); SAFE_DELETE(entry); i = _soundList.reverse_erase(i); continue; } // Queue the entry data, applying filtering entry->play(); } }
////////////////////////////////////////////////////////////////////////// // Subtitles ////////////////////////////////////////////////////////////////////////// void SoundQueue::updateSubtitles() { uint32 index = 0; SubtitleEntry *subtitle = NULL; for (Common::List<SubtitleEntry *>::iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { uint32 current_index = 0; SoundEntry *soundEntry = (*i)->getSoundEntry(); SoundFlag status = (SoundFlag)soundEntry->getStatus(); if (!(status & kSoundFlagPlaying) || status & kSoundFlagMute || soundEntry->getTime() == 0 || (status & kSoundVolumeMask) < kVolume6 || ((getFlags()->nis & 0x8000) && soundEntry->getPriority() < 90)) { current_index = 0; } else { current_index = soundEntry->getPriority() + (status & kSoundVolumeMask); if (_currentSubtitle == (*i)) current_index += 4; } if (index < current_index) { index = current_index; subtitle = (*i); } } if (_currentSubtitle == subtitle) { if (subtitle) subtitle->setupAndDraw(); return; } if (!subtitle) return; if (_subtitlesFlag & 1) subtitle->drawOnScreen(); subtitle->loadData(); subtitle->setupAndDraw(); }
////////////////////////////////////////////////////////////////////////// // Savegame ////////////////////////////////////////////////////////////////////////// void SoundQueue::saveLoadWithSerializer(Common::Serializer &s) { s.syncAsUint32LE(_ambientState); s.syncAsUint32LE(_currentTag); // Save or load each entry data if (s.isSaving()) { // Compute the number of entries to save uint32 numEntries = count(); s.syncAsUint32LE(numEntries); for (Common::List<SoundEntry *>::iterator i = _soundList.begin(); i != _soundList.end(); ++i) if ((*i)->needSaving()) (*i)->saveLoadWithSerializer(s); } else { uint32 numEntries; s.syncAsUint32LE(numEntries); for (uint32 i = 0; i < numEntries; i++) { SoundEntry* entry = new SoundEntry(_engine); entry->saveLoadWithSerializer(s); addToQueue(entry); } } }
void SoundQueue::updateQueue() { Common::StackLock locker(_mutex); ++_flag; if (getSoundState() & kSoundState1) { SoundEntry *entry = getEntry(kSoundType1); if (!entry || getFlags()->flag_3 || (entry && entry->getTime() > getSound()->getLoopingSoundDuration())) { getSound()->playLoopingSound(0x45); } else { if (getSound()->getData1() && getSound()->getData2() >= getSound()->getData1()) { entry->update(getSound()->getData0()); getSound()->setData1(0); } } } for (Common::List<SoundEntry *>::iterator it = _soundList.begin(); it != _soundList.end(); ++it) { SoundEntry *entry = *it; // Original removes the entry data from the cache and sets the archive as not loaded // and if the sound data buffer is not full, loads a new entry to be played based on // its priority and filter id if (!entry->updateSound() && !(entry->getStatus().status3 & 0x8)) { entry->close(); SAFE_DELETE(entry); it = _soundList.reverse_erase(it); } } // Original update the current entry, loading another set of samples to be decoded getFlags()->flag_3 = false; --_flag; }
void SoundQueue::stop(Common::String filename) { SoundEntry *entry = getEntry(filename); if (entry) entry->kill(); }
void SoundQueue::stop(EntityIndex entity) { SoundEntry *entry = getEntry(entity); if (entry) entry->kill(); }
////////////////////////////////////////////////////////////////////////// // Entry management ////////////////////////////////////////////////////////////////////////// void SoundQueue::assignNISLink(EntityIndex index) { SoundEntry *entry = getEntry(kSoundTagLink); if (entry) entry->setEntity(index); }
void SoundQueue::fade(SoundTag tag) { SoundEntry *entry = getEntry(tag); if (entry) entry->fade(); }