aboutsummaryrefslogtreecommitdiff
path: root/engines/lastexpress/game
diff options
context:
space:
mode:
authorJulien Templier2011-01-25 02:17:05 +0000
committerJulien Templier2011-01-25 02:17:05 +0000
commit8db6eb7b87b11229df91f59a70c7d7820a696e9e (patch)
tree365107a6b4de81b9301e8dbffde5c48da5e52eac /engines/lastexpress/game
parent8f7418556a1e6dfd19c53ab44c7e567413df5aa0 (diff)
downloadscummvm-rg350-8db6eb7b87b11229df91f59a70c7d7820a696e9e.tar.gz
scummvm-rg350-8db6eb7b87b11229df91f59a70c7d7820a696e9e.tar.bz2
scummvm-rg350-8db6eb7b87b11229df91f59a70c7d7820a696e9e.zip
LASTEXPRESS: Add per-entry sound stream (this fixes all dialog being cut as soon as a new sound is queued)
svn-id: r55513
Diffstat (limited to 'engines/lastexpress/game')
-rw-r--r--engines/lastexpress/game/sound.cpp25
-rw-r--r--engines/lastexpress/game/sound.h16
2 files changed, 20 insertions, 21 deletions
diff --git a/engines/lastexpress/game/sound.cpp b/engines/lastexpress/game/sound.cpp
index 2b86f2c378..4ea80bd21c 100644
--- a/engines/lastexpress/game/sound.cpp
+++ b/engines/lastexpress/game/sound.cpp
@@ -25,8 +25,6 @@
#include "lastexpress/game/sound.h"
-#include "lastexpress/data/snd.h"
-
#include "lastexpress/game/action.h"
#include "lastexpress/game/entities.h"
#include "lastexpress/game/inventory.h"
@@ -106,8 +104,6 @@ static const SoundManager::FlagType soundFlags[32] = {
};
SoundManager::SoundManager(LastExpressEngine *engine) : _engine(engine), _state(0), _currentType(kSoundType16), _flag(0) {
- _soundStream = new StreamedSound();
-
// Initialize unknown data
_data0 = 0;
_data1 = 0;
@@ -126,8 +122,6 @@ SoundManager::~SoundManager() {
_cache.clear();
- SAFE_DELETE(_soundStream);
-
_currentSubtitle = NULL;
// Zero passed pointers
@@ -146,11 +140,11 @@ void SoundManager::handleTimer() {
SAFE_DELETE(*i);
i = _cache.reverse_erase(i);
continue;
- } else if (!entry->isStreamed) {
- entry->isStreamed = true;
+ } else if (!entry->soundStream) {
+ entry->soundStream = new StreamedSound();
// TODO: stream any sound in the queue after filtering
- _soundStream->load(entry->stream);
+ entry->soundStream->load(entry->stream);
}
}
}
@@ -367,8 +361,12 @@ void SoundManager::resetEntry(SoundEntry *entry) {
entry->entity = kEntityPlayer;
if (entry->stream) {
- if (!entry->isStreamed)
+ if (!entry->soundStream) {
SAFE_DELETE(entry->stream);
+ } else {
+ entry->soundStream->stop();
+ SAFE_DELETE(entry->soundStream);
+ }
entry->stream = NULL;
}
@@ -1882,8 +1880,11 @@ void SoundManager::playLoopingSound() {
warning("SoundManager::playLoopingSound: not implemented!");
}
-void SoundManager::stopAllSound() const {
- _soundStream->stop();
+void SoundManager::stopAllSound() {
+ Common::StackLock locker(_mutex);
+
+ for (Common::List<SoundEntry *>::iterator i = _cache.begin(); i != _cache.end(); ++i)
+ (*i)->soundStream->stop();
}
} // End of namespace LastExpress
diff --git a/engines/lastexpress/game/sound.h b/engines/lastexpress/game/sound.h
index 4f613014e6..9471e1f4ee 100644
--- a/engines/lastexpress/game/sound.h
+++ b/engines/lastexpress/game/sound.h
@@ -69,6 +69,7 @@
*/
+#include "lastexpress/data/snd.h"
#include "lastexpress/data/subtitle.h"
#include "lastexpress/shared.h"
@@ -83,7 +84,6 @@
namespace LastExpress {
class LastExpressEngine;
-class StreamedSound;
class SubtitleManager;
class SoundManager : Common::Serializable {
@@ -197,7 +197,7 @@ public:
SoundManager::FlagType getSoundFlag(EntityIndex index) const;
// Debug
- void stopAllSound() const;
+ void stopAllSound();
// Serializable
void saveLoadWithSerializer(Common::Serializer &ser);
@@ -271,7 +271,8 @@ private:
//int next; // offset to the next structure in the list (not used)
SubtitleEntry *subtitle;
- bool isStreamed; // TEMPORARY
+ // Sound stream
+ StreamedSound *soundStream;
SoundEntry() {
status.status = 0;
@@ -292,15 +293,15 @@ private:
subtitle = NULL;
- isStreamed = false;
+ soundStream = NULL;
}
~SoundEntry() {
// Entries that have been queued would have their streamed disposed automatically
- if (!isStreamed)
+ if (!soundStream)
SAFE_DELETE(stream);
- //delete subtitle;
+ delete soundStream;
}
};
@@ -328,9 +329,6 @@ private:
int _state;
SoundType _currentType;
- // Sound stream
- StreamedSound *_soundStream;
-
Common::Mutex _mutex;
// Unknown data