[Scummvm-cvs-logs] SF.net SVN: scummvm:[55865] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Thu Feb 10 13:40:48 CET 2011
Revision: 55865
http://scummvm.svn.sourceforge.net/scummvm/?rev=55865&view=rev
Author: thebluegr
Date: 2011-02-10 12:40:48 +0000 (Thu, 10 Feb 2011)
Log Message:
-----------
SCI: Moved some audio resource code to resource_audio.cpp
Modified Paths:
--------------
scummvm/trunk/engines/sci/resource.cpp
scummvm/trunk/engines/sci/resource_audio.cpp
Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp 2011-02-10 01:19:48 UTC (rev 55864)
+++ scummvm/trunk/engines/sci/resource.cpp 2011-02-10 12:40:48 UTC (rev 55865)
@@ -558,75 +558,6 @@
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)
Modified: scummvm/trunk/engines/sci/resource_audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource_audio.cpp 2011-02-10 01:19:48 UTC (rev 55864)
+++ scummvm/trunk/engines/sci/resource_audio.cpp 2011-02-10 12:40:48 UTC (rev 55865)
@@ -824,4 +824,73 @@
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list