aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2011-02-10 12:40:48 +0000
committerFilippos Karapetis2011-02-10 12:40:48 +0000
commitd915560f4475a30ab7ff961b3af8e109e3e8ffa7 (patch)
treede6a487c7e5ec908a1aca05f1b2e4342379a9615
parent24eab0ac73f293f5f05344c3278ca5dcfd76dacd (diff)
downloadscummvm-rg350-d915560f4475a30ab7ff961b3af8e109e3e8ffa7.tar.gz
scummvm-rg350-d915560f4475a30ab7ff961b3af8e109e3e8ffa7.tar.bz2
scummvm-rg350-d915560f4475a30ab7ff961b3af8e109e3e8ffa7.zip
SCI: Moved some audio resource code to resource_audio.cpp
svn-id: r55865
-rw-r--r--engines/sci/resource.cpp69
-rw-r--r--engines/sci/resource_audio.cpp69
2 files changed, 69 insertions, 69 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 1530cc2c58..a4d4b31597 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -558,75 +558,6 @@ Common::SeekableReadStream *ResourceSource::getVolumeFile(ResourceManager *resMa
return fileStream;
}
-void WaveResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
- Common::SeekableReadStream *fileStream = getVolumeFile(resMan, res);
- if (!fileStream)
- return;
-
- fileStream->seek(res->_fileOffset, SEEK_SET);
- res->loadFromWaveFile(fileStream);
- if (_resourceFile)
- delete fileStream;
-}
-
-void AudioVolumeResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
- Common::SeekableReadStream *fileStream = getVolumeFile(resMan, res);
- if (!fileStream)
- return;
-
- if (_audioCompressionType) {
- // this file is compressed, so lookup our offset in the offset-translation table and get the new offset
- // also calculate the compressed size by using the next offset
- int32 *mappingTable = _audioCompressionOffsetMapping;
- int32 compressedOffset = 0;
-
- do {
- if (*mappingTable == res->_fileOffset) {
- mappingTable++;
- compressedOffset = *mappingTable;
- // Go to next compressed offset and use that to calculate size of compressed sample
- switch (res->getType()) {
- case kResourceTypeSync:
- case kResourceTypeSync36:
- // we should already have a (valid) size
- break;
- default:
- mappingTable += 2;
- res->size = *mappingTable - compressedOffset;
- }
- break;
- }
- mappingTable += 2;
- } while (*mappingTable);
-
- if (!compressedOffset)
- error("could not translate offset to compressed offset in audio volume");
- fileStream->seek(compressedOffset, SEEK_SET);
-
- switch (res->getType()) {
- case kResourceTypeAudio:
- case kResourceTypeAudio36:
- // Directly read the stream, compressed audio wont have resource type id and header size for SCI1.1
- res->loadFromAudioVolumeSCI1(fileStream);
- if (_resourceFile)
- delete fileStream;
- return;
- default:
- break;
- }
- } else {
- // original file, directly seek to given offset and get SCI1/SCI1.1 audio resource
- fileStream->seek(res->_fileOffset, SEEK_SET);
- }
- if (getSciVersion() < SCI_VERSION_1_1)
- res->loadFromAudioVolumeSCI1(fileStream);
- else
- res->loadFromAudioVolumeSCI11(fileStream);
-
- if (_resourceFile)
- delete fileStream;
-}
-
void ResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
Common::SeekableReadStream *fileStream = getVolumeFile(resMan, res);
if (!fileStream)
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index 9949373852..183e200e9d 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -824,4 +824,73 @@ byte SoundResource::getInitialVoiceCount(byte channel) {
return data[channel * 2];
}
+void WaveResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
+ Common::SeekableReadStream *fileStream = getVolumeFile(resMan, res);
+ if (!fileStream)
+ return;
+
+ fileStream->seek(res->_fileOffset, SEEK_SET);
+ res->loadFromWaveFile(fileStream);
+ if (_resourceFile)
+ delete fileStream;
+}
+
+void AudioVolumeResourceSource::loadResource(ResourceManager *resMan, Resource *res) {
+ Common::SeekableReadStream *fileStream = getVolumeFile(resMan, res);
+ if (!fileStream)
+ return;
+
+ if (_audioCompressionType) {
+ // this file is compressed, so lookup our offset in the offset-translation table and get the new offset
+ // also calculate the compressed size by using the next offset
+ int32 *mappingTable = _audioCompressionOffsetMapping;
+ int32 compressedOffset = 0;
+
+ do {
+ if (*mappingTable == res->_fileOffset) {
+ mappingTable++;
+ compressedOffset = *mappingTable;
+ // Go to next compressed offset and use that to calculate size of compressed sample
+ switch (res->getType()) {
+ case kResourceTypeSync:
+ case kResourceTypeSync36:
+ // we should already have a (valid) size
+ break;
+ default:
+ mappingTable += 2;
+ res->size = *mappingTable - compressedOffset;
+ }
+ break;
+ }
+ mappingTable += 2;
+ } while (*mappingTable);
+
+ if (!compressedOffset)
+ error("could not translate offset to compressed offset in audio volume");
+ fileStream->seek(compressedOffset, SEEK_SET);
+
+ switch (res->getType()) {
+ case kResourceTypeAudio:
+ case kResourceTypeAudio36:
+ // Directly read the stream, compressed audio wont have resource type id and header size for SCI1.1
+ res->loadFromAudioVolumeSCI1(fileStream);
+ if (_resourceFile)
+ delete fileStream;
+ return;
+ default:
+ break;
+ }
+ } else {
+ // original file, directly seek to given offset and get SCI1/SCI1.1 audio resource
+ fileStream->seek(res->_fileOffset, SEEK_SET);
+ }
+ if (getSciVersion() < SCI_VERSION_1_1)
+ res->loadFromAudioVolumeSCI1(fileStream);
+ else
+ res->loadFromAudioVolumeSCI11(fileStream);
+
+ if (_resourceFile)
+ delete fileStream;
+}
+
} // End of namespace Sci