Ticket #8904: bs2-archive-pre.patch
File bs2-archive-pre.patch, 7.4 KB (added by , 16 years ago) |
---|
-
animation.cpp
865 865 // Factory function for creating the appropriate cutscene player 866 866 /////////////////////////////////////////////////////////////////////////////// 867 867 868 MoviePlayer * makeMoviePlayer(Sword2Engine *vm,const char *name) {868 MoviePlayer *Sword2Engine::makeMoviePlayer(const char *name) { 869 869 static char filename[20]; 870 870 871 871 #ifdef USE_ZLIB 872 872 snprintf(filename, sizeof(filename), "%s.dxa", name); 873 873 874 874 if (Common::File::exists(filename)) { 875 return new MoviePlayerDXA( vm, name);875 return new MoviePlayerDXA(this, name); 876 876 } 877 877 #endif 878 878 … … 880 880 snprintf(filename, sizeof(filename), "%s.mp2", name); 881 881 882 882 if (Common::File::exists(filename)) { 883 return new MoviePlayerMPEG( vm, name);883 return new MoviePlayerMPEG(this, name); 884 884 } 885 885 #endif 886 886 887 return new MoviePlayerDummy( vm, name);887 return new MoviePlayerDummy(this, name); 888 888 } 889 889 890 890 } // End of namespace Sword2 -
function.cpp
2139 2139 // pause sfx during sequence 2140 2140 _vm->_sound->pauseFx(); 2141 2141 2142 MoviePlayer *player = makeMoviePlayer(_vm,filename);2142 MoviePlayer *player = _vm->makeMoviePlayer(filename); 2143 2143 2144 2144 if (player->load()) { 2145 2145 player->play(_sequenceTextList, _sequenceTextLines, _smackerLeadIn, _smackerLeadOut); -
music.cpp
51 51 52 52 static Audio::AudioStream *makeCLUStream(Common::File *fp, int size); 53 53 54 static Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, int cd, uint32 id, uint32 *numSamples) { 55 bool alreadyOpen; 54 Audio::AudioStream *resetAudioStream(SoundFileHandle *fh, const char *base, uint32 id, uint32 *numSamples, bool alreadyOpen) { 56 55 57 if (!fh->file.isOpen()) {58 alreadyOpen = false;59 60 struct {61 const char *ext;62 int mode;63 } file_types[] = {64 #ifdef USE_FLAC65 { "clf", kFlacMode },66 #endif67 #ifdef USE_VORBIS68 { "clg", kVorbisMode },69 #endif70 #ifdef USE_MAD71 { "cl3", kMP3Mode },72 #endif73 { "clu", kCLUMode }74 };75 76 int soundMode = 0;77 char filename[20];78 79 for (int i = 0; i < ARRAYSIZE(file_types); i++) {80 sprintf(filename, "%s%d.%s", base, cd, file_types[i].ext);81 if (Common::File::exists(filename)) {82 soundMode = file_types[i].mode;83 break;84 }85 86 sprintf(filename, "%s.%s", base, file_types[i].ext);87 if (Common::File::exists(filename)) {88 soundMode = file_types[i].mode;89 break;90 }91 }92 93 if (soundMode == 0)94 return NULL;95 96 fh->file.open(filename);97 fh->fileType = soundMode;98 if (!fh->file.isOpen()) {99 warning("BS2 getAudioStream: Failed opening file '%s'", filename);100 return NULL;101 }102 if (fh->fileSize != fh->file.size()) {103 if (fh->idxTab) {104 free(fh->idxTab);105 fh->idxTab = NULL;106 }107 }108 } else109 alreadyOpen = true;110 111 56 uint32 entrySize = (fh->fileType == kCLUMode) ? 2 : 3; 112 57 113 58 if (!fh->idxTab) { … … 173 118 default: 174 119 return NULL; 175 120 } 121 176 122 } 177 123 124 Audio::AudioStream *Sound::getAudioStream(SoundFileHandle *fh, const char *base, int cd, uint32 id, uint32 *numSamples) { 125 bool alreadyOpen; 126 127 if (!fh->file.isOpen()) { 128 alreadyOpen = false; 129 130 struct { 131 const char *ext; 132 int mode; 133 } file_types[] = { 134 #ifdef USE_FLAC 135 { "clf", kFlacMode }, 136 #endif 137 #ifdef USE_VORBIS 138 { "clg", kVorbisMode }, 139 #endif 140 #ifdef USE_MAD 141 { "cl3", kMP3Mode }, 142 #endif 143 { "clu", kCLUMode } 144 }; 145 146 int soundMode = 0; 147 char filename[20]; 148 149 for (int i = 0; i < ARRAYSIZE(file_types); i++) { 150 sprintf(filename, "%s%d.%s", base, cd, file_types[i].ext); 151 if (Common::File::exists(filename)) { 152 soundMode = file_types[i].mode; 153 break; 154 } 155 156 sprintf(filename, "%s.%s", base, file_types[i].ext); 157 if (Common::File::exists(filename)) { 158 soundMode = file_types[i].mode; 159 break; 160 } 161 } 162 163 if (soundMode == 0) 164 return NULL; 165 166 fh->file.open(filename); 167 fh->fileType = soundMode; 168 if (!fh->file.isOpen()) { 169 warning("BS2 getAudioStream: Failed opening file '%s'", filename); 170 return NULL; 171 } 172 if (fh->fileSize != fh->file.size()) { 173 if (fh->idxTab) { 174 free(fh->idxTab); 175 fh->idxTab = NULL; 176 } 177 } 178 } else 179 alreadyOpen = true; 180 181 return resetAudioStream(fh, base, id, numSamples, alreadyOpen); 182 } 183 184 178 185 // ---------------------------------------------------------------------------- 179 186 // Custom AudioStream class to handle Broken Sword 2's audio compression. 180 187 // ---------------------------------------------------------------------------- … … 262 269 // The length of a fade-in/out, in milliseconds. 263 270 #define FADE_LENGTH 3000 264 271 265 MusicInputStream::MusicInputStream(int cd, SoundFileHandle *fh, uint32 musicId, bool looping) { 266 _cd = cd; 272 MusicInputStream::MusicInputStream(Audio::AudioStream *decoder, SoundFileHandle *fh, uint32 musicId, uint32 numSamples, bool looping) { 267 273 _fh = fh; 268 274 _musicId = musicId; 275 _numSamples = numSamples; 269 276 _looping = looping; 270 277 271 278 _bufferEnd = _buffer + BUFFER_SIZE; 272 279 _remove = false; 273 280 _fading = 0; 274 281 275 _decoder = getAudioStream(_fh, "music", _cd, _musicId, &_numSamples);282 _decoder = decoder; 276 283 if (_decoder) { 277 284 _samplesLeft = _numSamples; 278 285 _fadeSamples = (getRate() * FADE_LENGTH) / 1000; … … 283 290 } 284 291 } 285 292 293 286 294 MusicInputStream::~MusicInputStream() { 287 295 delete _decoder; 288 296 _decoder = NULL; … … 390 398 if (!_samplesLeft) { 391 399 if (_looping) { 392 400 delete _decoder; 393 _decoder = getAudioStream(_fh, "music", _cd, _musicId, &_numSamples);401 _decoder = resetAudioStream(_fh, "music", _musicId, &_numSamples, true); 394 402 _samplesLeft = _numSamples; 395 403 } else 396 404 _remove = true; … … 617 625 fh->inUse = true; 618 626 _mutex.unlock(); 619 627 620 MusicInputStream *tmp = new MusicInputStream(cd, fh, musicId, loop); 628 uint32 numSamples; 629 Audio::AudioStream *decoder = getAudioStream(fh, "music", cd, musicId, &numSamples); 630 MusicInputStream *tmp = new MusicInputStream(decoder, fh, musicId, numSamples, loop); 621 631 622 632 if (tmp->isReady()) { 623 633 _mutex.lock(); -
sound.h
155 155 } 156 156 157 157 public: 158 MusicInputStream( int cd, SoundFileHandle *fh, uint32 musicId, bool looping);158 MusicInputStream(Audio::AudioStream *decoder, SoundFileHandle *fh, uint32 musicId, uint32 numSamples, bool looping); 159 159 ~MusicInputStream(); 160 160 161 161 int readBuffer(int16 *buffer, const int numSamples); … … 281 281 int32 streamCompMusic(uint32 musicId, bool loop); 282 282 void stopMusic(bool immediately); 283 283 int32 musicTimeRemaining(); 284 285 Audio::AudioStream *getAudioStream(SoundFileHandle *fh, const char *base, int cd, uint32 id, uint32 *numSamples); 284 286 }; 285 287 286 288 } // End of namespace Sword2 -
sword2.h
62 62 class FontRenderer; 63 63 class Gui; 64 64 class Debugger; 65 class MoviePlayer; 65 66 66 67 enum { 67 68 RD_LEFTBUTTONDOWN = 0x01, … … 228 229 229 230 void runStart(int start); 230 231 232 MoviePlayer *makeMoviePlayer(const char *name); 233 231 234 // Convenience alias for OSystem::getMillis(). 232 235 // This is a bit hackish, of course :-). 233 236 uint32 getMillis();