aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2009-05-23 23:58:40 +0000
committerJohannes Schickel2009-05-23 23:58:40 +0000
commitb28279accccdfe65096bb58bb8368f8a43c609d3 (patch)
tree243c01014c64c622605cce4c369e2d539471d9ce
parentdfb6ca6bae37e54cd8477c8313077c22fcd5a1c7 (diff)
downloadscummvm-rg350-b28279accccdfe65096bb58bb8368f8a43c609d3.tar.gz
scummvm-rg350-b28279accccdfe65096bb58bb8368f8a43c609d3.tar.bz2
scummvm-rg350-b28279accccdfe65096bb58bb8368f8a43c609d3.zip
Cleanup.
svn-id: r40841
-rw-r--r--engines/kyra/sound.cpp54
-rw-r--r--engines/kyra/sound.h11
-rw-r--r--engines/kyra/sound_lol.cpp9
-rw-r--r--engines/kyra/sound_towns.cpp2
4 files changed, 35 insertions, 41 deletions
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp
index 975cff740a..00aba95d0a 100644
--- a/engines/kyra/sound.cpp
+++ b/engines/kyra/sound.cpp
@@ -66,21 +66,20 @@ bool Sound::voiceFileIsPresent(const char *file) {
return false;
}
-int32 Sound::voicePlay(const char *file, uint8 volume, bool isSfx, bool appendSuffix) {
- int32 ptime = 0;
- Audio::AudioStream *audioStream = getVoiceStream(file, &ptime, appendSuffix);
+int32 Sound::voicePlay(const char *file, uint8 volume, bool isSfx) {
+ Audio::AudioStream *audioStream = getVoiceStream(file);
if (!audioStream) {
warning("Couldn't load sound file '%s'", file);
return 0;
}
- playVoiceStream(audioStream, file, volume, isSfx) ;
-
- return ptime;
+ int playTime = audioStream->getTotalPlayTime();
+ playVoiceStream(audioStream, file, volume, isSfx);
+ return playTime;
}
-Audio::AudioStream *Sound::getVoiceStream(const char *file, int32 *totalPlayingTime, bool appendSuffix) {
+Audio::AudioStream *Sound::getVoiceStream(const char *file) {
char filenamebuffer[25];
Audio::AudioStream *audioStream = 0;
@@ -95,28 +94,6 @@ Audio::AudioStream *Sound::getVoiceStream(const char *file, int32 *totalPlayingT
break;
}
- int32 vocStreamPlayTime = 0;
-
- if (!audioStream) {
- strcpy(filenamebuffer, file);
- if (appendSuffix)
- strcat(filenamebuffer, ".VOC");
-
- uint32 fileSize = 0;
- byte *fileData = _vm->resource()->fileData(filenamebuffer, &fileSize);
- if (!fileData)
- return 0;
-
- Common::MemoryReadStream vocStream(fileData, fileSize);
- audioStream = Audio::makeVOCStream(vocStream, Audio::Mixer::FLAG_UNSIGNED);
-
- if (audioStream)
- vocStreamPlayTime = vocStream.size() * 1000 / audioStream->getRate();
- } else {
- vocStreamPlayTime = audioStream->getTotalPlayTime();
- }
-
- *totalPlayingTime = vocStreamPlayTime;
return audioStream;
}
@@ -259,6 +236,21 @@ bool KyraEngine_v1::snd_voiceIsPlaying() {
// static res
+namespace {
+
+// A simple wrapper to create VOC streams the way like creating MP3, OGG/Vorbis and FLAC streams.
+// Possible TODO: Think of making this complete and moving it to sound/voc.cpp ?
+Audio::AudioStream *makeVOCStream(Common::SeekableReadStream *stream, bool disposeAfterUse, uint32 startTime, uint32 duration, uint numLoops) {
+ Audio::AudioStream *as = Audio::makeVOCStream(*stream, Audio::Mixer::FLAG_UNSIGNED);
+
+ if (disposeAfterUse)
+ delete stream;
+
+ return as;
+}
+
+} // end of anonymous namespace
+
const Sound::SpeechCodecs Sound::_supportedCodecs[] = {
#ifdef USE_FLAC
{ ".VOF", Audio::makeFlacStream },
@@ -269,6 +261,10 @@ const Sound::SpeechCodecs Sound::_supportedCodecs[] = {
#ifdef USE_MAD
{ ".VO3", Audio::makeMP3Stream },
#endif // USE_MAD
+
+ { ".VOC", makeVOCStream },
+ { "", makeVOCStream },
+
{ 0, 0 }
};
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index bf121ede2b..49a92c89f4 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -187,17 +187,14 @@ public:
* specified voice file, it stops the
* current voice.
*
- * TODO: add support for queueing voice
- * files
- *
* @param file file to be played
* @param volume volume of the voice file
* @param isSfx marks file as sfx instead of voice
* @return playtime of the voice file (-1 marks unknown playtime)
*/
- virtual int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false, bool appendSuffix = true);
+ virtual int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false);
- Audio::AudioStream *getVoiceStream(const char *file, int32 *totalPlayingTime, bool appendSuffix = true);
+ Audio::AudioStream *getVoiceStream(const char *file);
void playVoiceStream(Audio::AudioStream * stream, const char *handleName, uint8 volume = 255, bool isSfx = false);
@@ -461,7 +458,7 @@ public:
void haltTrack();
void beginFadeOut();
- int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false, bool appendSuffix = true) { return -1; }
+ int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false) { return -1; }
void playSoundEffect(uint8);
protected:
@@ -488,7 +485,7 @@ public:
void haltTrack();
void beginFadeOut();
- int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false, bool appendSuffix = true);
+ int32 voicePlay(const char *file, uint8 volume = 255, bool isSfx = false);
void playSoundEffect(uint8 track);
protected:
diff --git a/engines/kyra/sound_lol.cpp b/engines/kyra/sound_lol.cpp
index 862788d524..9759d830cc 100644
--- a/engines/kyra/sound_lol.cpp
+++ b/engines/kyra/sound_lol.cpp
@@ -106,11 +106,12 @@ bool LoLEngine::snd_playCharacterSpeech(int id, int8 speaker, int) {
delete *i;
_speechList.clear();
- int32 pt = 0;
for (Common::List<const char*>::iterator i = playList.begin(); i != playList.end(); ++i) {
- Audio::AudioStream *a = _sound->getVoiceStream(*i, &pt, false);
- _speechList.push_back(a);
- _activeVoiceFileTotalTime += pt;
+ Audio::AudioStream *a = _sound->getVoiceStream(*i);
+ if (a) {
+ _activeVoiceFileTotalTime += a->getTotalPlayTime();
+ _speechList.push_back(a);
+ }
}
//_activeVoiceFileTotalTime = _sound->voicePlay(_activeVoiceFile, 255, false, false);
diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp
index 2340f81aa8..f96e37b94f 100644
--- a/engines/kyra/sound_towns.cpp
+++ b/engines/kyra/sound_towns.cpp
@@ -4231,7 +4231,7 @@ void SoundTownsPC98_v2::beginFadeOut() {
haltTrack();
}
-int32 SoundTownsPC98_v2::voicePlay(const char *file, uint8, bool, bool) {
+int32 SoundTownsPC98_v2::voicePlay(const char *file, uint8, bool) {
static const uint16 rates[] = { 0x10E1, 0x0CA9, 0x0870, 0x0654, 0x0438, 0x032A, 0x021C, 0x0194 };
static const char patternHOF[] = "%s.PCM";
static const char patternLOL[] = "%s.VOC";