Ticket #8491: modules.diff
File modules.diff, 11.7 KB (added by , 18 years ago) |
---|
-
configure
40 40 _tremor=auto 41 41 _flac=auto 42 42 _mad=auto 43 _mikmod=auto 43 44 _alsa=auto 44 45 _zlib=auto 45 46 _mpeg2=auto … … 355 356 --with-flac-prefix=DIR Prefix where libFLAC is installed (optional) 356 357 --disable-flac disable FLAC support [autodetect] 357 358 359 --with-mikmod-prefix=DIR Prefix where libmikmod is installed (optional) 360 --disable-mikmod disable MikMod support [autodetect] 361 358 362 --with-zlib-prefix=DIR Prefix where zlib is installed (optional) 359 363 --disable-zlib disable zlib (compression) support [autodetect] 360 364 … … 412 416 --disable-flac) _flac=no ;; 413 417 --enable-mad) _mad=yes ;; 414 418 --disable-mad) _mad=no ;; 419 --enable-mikmod) _mikmod=yes ;; 420 --disable-mikmod) _mikmod=no ;; 415 421 --enable-zlib) _zlib=yes ;; 416 422 --disable-zlib) _zlib=no ;; 417 423 --enable-nasm) _nasm=yes ;; … … 461 467 MAD_CFLAGS="-I$arg/include" 462 468 MAD_LIBS="-L$arg/lib" 463 469 ;; 470 --with-mikmod-prefix=*) 471 _prefix=`echo $ac_option | cut -d '=' -f 2` 472 MIKMOD_CFLAGS="-I$_prefix/include" 473 MIKMOD_LIBS="-L$_prefix/lib" 474 ;; 464 475 --with-zlib-prefix=*) 465 476 arg=`echo $ac_option | cut -d '=' -f 2` 466 477 ZLIB_CFLAGS="-I$arg/include" … … 1081 1092 echo "$_mad" 1082 1093 1083 1094 # 1095 # Check for MikMod (MOD decoder library) 1096 # 1097 1098 echocheck "MikMod" 1099 if test "$_mikmod" = auto ; then 1100 _mikmod=no 1101 cat > $TMPC << EOF 1102 #include <mikmod.h> 1103 int main(void) {return 0; } 1104 EOF 1105 cc_check $LDFLAGS $CXXFLAGS $MIKMOD_CFLAGS $MIKMOD_LIBS -lmikmod && _mikmod=yes 1106 fi 1107 if test "$_mikmod" = yes ; then 1108 _def_mikmod='#define USE_MIKMOD' 1109 LIBS="$LIBS $MIKMOD_LIBS -lmikmod" 1110 INCLUDES="$INCLUDES $MIKMOD_CFLAGS" 1111 else 1112 _def_mikmod='#undef USE_MIKMOD' 1113 fi 1114 echo "$_mikmod" 1115 1116 # 1084 1117 # Check for ALSA 1085 1118 # 1086 1119 echocheck "ALSA >= 0.9" … … 1358 1391 $_def_vorbis 1359 1392 $_def_tremor 1360 1393 $_def_flac 1394 $_def_mikmod 1361 1395 $_def_mad 1362 1396 $_def_alsa 1363 1397 $_def_zlib -
sound/module.mk
11 11 midiparser_smf.o \ 12 12 midiparser_xmidi.o \ 13 13 mixer.o \ 14 mod.o \ 14 15 mp3.o \ 15 16 mpu401.o \ 16 17 null.o \ -
sound/mod.cpp
1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003-2005 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 * $URL$ 19 * $Id$ 20 * 21 */ 22 23 #include "sound/mod.h" 24 25 #ifdef USE_MIKMOD 26 27 #include "common/file.h" 28 #include "common/util.h" 29 30 #include "sound/audiostream.h" 31 #include "sound/mixer.h" 32 33 #include <mikmod.h> 34 35 namespace Audio { 36 37 void initMOD(Audio::Mixer *mixer) { 38 // We only use the MikMod library for decoding. Therefore, we only need 39 // the "No Sound" driver. 40 MikMod_RegisterDriver(&drv_nos); 41 MikMod_RegisterAllLoaders(); 42 43 md_mixfreq = mixer->getOutputRate(); 44 45 CHAR mmArgs[] = ""; 46 47 MikMod_Init(mmArgs); 48 } 49 50 void exitMOD() { 51 MikMod_Exit(); 52 } 53 54 55 // These are wrapper functions to allow using a File object to provide data to 56 // the MOD reader 57 58 struct MFILEREADER { 59 MREADER core; 60 MODULE *module; 61 Common::SeekableReadStream *file; 62 }; 63 64 static int mm_eof_wrapper(struct MREADER *reader) { 65 return (((MFILEREADER *)reader)->file->pos() == ((MFILEREADER *)reader)->file->size()); 66 } 67 68 static BOOL mm_read_wrapper(struct MREADER *reader, void *dest, size_t length) { 69 return ((MFILEREADER *)reader)->file->read(dest, length); 70 } 71 72 static int mm_get_wrapper(struct MREADER *reader) { 73 Common::SeekableReadStream *file = ((MFILEREADER *)reader)->file; 74 75 if (file->pos() == file->size()) 76 return EOF; 77 78 return file->readByte(); 79 } 80 81 static BOOL mm_seek_wrapper(struct MREADER *reader, long offset, int whence) { 82 ((MFILEREADER *)reader)->file->seek(offset, whence); 83 return 0; 84 } 85 86 static long mm_tell_wrapper(struct MREADER *reader) { 87 return ((MFILEREADER *)reader)->file->pos(); 88 } 89 90 static MODULE *loadModuleFromFile(Common::SeekableReadStream *file) { 91 assert(file); 92 93 MFILEREADER *reader = (MFILEREADER *)malloc(sizeof(MFILEREADER)); 94 95 assert(reader); 96 97 reader->core.Eof = &mm_eof_wrapper; 98 reader->core.Read = &mm_read_wrapper; 99 reader->core.Get = &mm_get_wrapper; 100 reader->core.Seek = &mm_seek_wrapper; 101 reader->core.Tell = &mm_tell_wrapper; 102 103 reader->file = file; 104 105 MODULE *module = Player_LoadGeneric((MREADER *)reader, 64, 0); 106 module->wrap = true; 107 108 if (!module) { 109 free(reader); 110 return NULL; 111 } 112 113 Player_Start(module); 114 Player_SetPosition(0); 115 116 return module; 117 } 118 119 120 #pragma mark - 121 #pragma mark --- MOD stream --- 122 #pragma mark - 123 124 125 class MODInputStream : public AudioStream { 126 private: 127 int16 _buffer[4096]; 128 const int16 *_bufferEnd; 129 const int16 *_pos; 130 MODULE *_module; 131 132 void refill(); 133 inline bool eosIntern() const; 134 135 public: 136 MODInputStream(Common::SeekableReadStream *file); 137 ~MODInputStream(); 138 139 int readBuffer(int16 *buffer, const int numSamples); 140 141 bool endOfData() const { return eosIntern(); } 142 bool isStereo() const { return true; } 143 144 int getRate() const { return md_mixfreq; } 145 }; 146 147 MODInputStream::MODInputStream(Common::SeekableReadStream *file) { 148 _module = loadModuleFromFile(file); 149 150 // Read in initial data 151 refill(); 152 } 153 154 MODInputStream::~MODInputStream() { 155 if (_module) { 156 Player_Free(_module); 157 } 158 } 159 160 inline bool MODInputStream::eosIntern() const { 161 return _pos >= _bufferEnd; 162 } 163 164 int MODInputStream::readBuffer(int16 *buffer, const int numSamples) { 165 int samples = 0; 166 while (samples < numSamples && !eosIntern()) { 167 const int len = MIN(numSamples - samples, (int)(_bufferEnd - _pos)); 168 memcpy(buffer, _pos, len * 2); 169 buffer += len; 170 _pos += len; 171 samples += len; 172 if (_pos >= _bufferEnd) { 173 refill(); 174 } 175 } 176 return samples; 177 } 178 179 void MODInputStream::refill() { 180 // Read the samples 181 uint len_left = sizeof(_buffer); 182 char *read_pos = (char *)_buffer; 183 184 Player_Start(_module); 185 186 int len = VC_WriteBytes((SBYTE *)_buffer, len_left); 187 188 len_left -= len; 189 read_pos += len; 190 191 _pos = _buffer; 192 _bufferEnd = (int16 *)read_pos; 193 } 194 195 AudioStream *makeMODStream(Common::SeekableReadStream *file) { 196 return new MODInputStream(file); 197 } 198 199 } 200 #endif -
sound/mixer.cpp
33 33 #include "sound/flac.h" 34 34 #include "sound/mp3.h" 35 35 #include "sound/vorbis.h" 36 #include "sound/mod.h" 36 37 37 38 38 39 namespace Audio { … … 126 127 error("OSystem returned invalid sample rate"); 127 128 128 129 debug(1, "Output sample rate: %d Hz", _outputRate); 130 131 #ifdef USE_MIKMOD 132 initMOD(this); 133 #endif 129 134 } 130 135 131 136 Mixer::~Mixer() { … … 134 139 135 140 delete _premixChannel; 136 141 _premixChannel = 0; 142 143 #ifdef USE_MIKMOD 144 exitMOD(); 145 #endif 137 146 } 138 147 139 148 bool Mixer::isPaused() { -
sound/mod.h
1 /* ScummVM - Scumm Interpreter 2 * Copyright (C) 2003-2005 The ScummVM project 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 * $URL$ 19 * $Id$ 20 * 21 */ 22 23 #ifndef SOUND_MOD_H 24 #define SOUND_MOD_H 25 26 #include "common/stdafx.h" 27 #include "common/scummsys.h" 28 29 #ifdef USE_MIKMOD 30 31 namespace Common { 32 class SeekableReadStream; 33 } 34 namespace Audio { 35 36 class AudioStream; 37 class Mixer; 38 39 void initMOD(Audio::Mixer *mixer); 40 void exitMOD(); 41 42 AudioStream *makeMODStream(Common::SeekableReadStream *file); 43 44 } 45 46 #endif 47 #endif -
engines/agos/agos.cpp
34 34 #include "agos/vga.h" 35 35 36 36 #include "sound/mididrv.h" 37 #include "sound/mod.h" 37 38 38 39 #ifdef PALMOS_68K 39 40 #include "globals.h" … … 2312 2313 2313 2314 vc34_setMouseOff(); 2314 2315 2316 if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) { 2317 _initMouse = 1; 2318 loadMusic(0); 2319 } 2320 2315 2321 if ((getPlatform() == Common::kPlatformAmiga || getPlatform() == Common::kPlatformMacintosh) && 2316 2322 getGameType() == GType_FF) { 2317 2323 _moviePlay->load((const char *)"epic.dxa"); … … 2351 2357 char buf[4]; 2352 2358 2353 2359 if (getPlatform() == Common::kPlatformAmiga || getPlatform() == Common::kPlatformAtariST) { 2354 if (getFeatures() & GF_CRUNCHED) { 2355 // TODO Add support for decruncher 2356 debug(5,"loadMusic - Decrunch %dtune attempt", music); 2357 } 2358 // TODO Add Protracker support for simon1amiga/cd32 2359 debug(5,"playMusic - Load %dtune attempt", music); 2360 return; 2360 Audio::AudioStream *modStream; 2361 char filename[15]; 2362 File f; 2363 2364 if (getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) 2365 sprintf(filename, "elvira2"); 2366 else if (getPlatform() == Common::kPlatformAtariST) 2367 sprintf(filename, "%dtune.pkd", music); 2368 else 2369 sprintf(filename, "%dtune", music); 2370 2371 f.open(filename); 2372 if (f.isOpen() == false) 2373 warning("loadMusic: Can't load music from '%s'", filename); 2374 2375 if (!(getGameType() == GType_ELVIRA1 && getFeatures() & GF_DEMO) && 2376 getFeatures() & GF_CRUNCHED) { 2377 uint srcSize = f.size(); 2378 byte *srcBuffer = (byte *)malloc(srcSize); 2379 if (f.read(srcBuffer, srcSize) != srcSize) 2380 error("loadMusic: Read failed"); 2381 2382 uint dstSize = READ_BE_UINT32(srcBuffer + srcSize - 4); 2383 byte *dst = (byte *)malloc(dstSize); 2384 decrunchFile(srcBuffer, dst, srcSize); 2385 2386 Common::MemoryReadStream stream(dst, dstSize); 2387 modStream = Audio::makeMODStream(&stream); 2388 } else { 2389 modStream = Audio::makeMODStream(&f); 2390 } 2391 2392 _mixer->stopAll(); 2393 _mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, modStream); 2361 2394 } else if (getGameType() == GType_SIMON2) { 2362 2395 midi.stop(); 2363 2396 _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET); -
base/version.cpp
76 76 "MP3 " 77 77 #endif 78 78 79 #ifdef USE_MIKMOD 80 "MikMod " 81 #endif 82 79 83 #ifdef USE_ALSA 80 84 "ALSA " 81 85 #endif