diff options
author | Alejandro Marzini | 2010-07-30 05:28:09 +0000 |
---|---|---|
committer | Alejandro Marzini | 2010-07-30 05:28:09 +0000 |
commit | fb4086cadb8ce3e473dae40558d713e7a31b3858 (patch) | |
tree | 95c19d544da914c43a43f0538a1977f43e17cb39 /sound | |
parent | 7b070bbef8275ff25dfc2cbc3106acfdc8de74a5 (diff) | |
parent | a17e3c444917ca90dfd537c2102a6150e7ffe977 (diff) | |
download | scummvm-rg350-fb4086cadb8ce3e473dae40558d713e7a31b3858.tar.gz scummvm-rg350-fb4086cadb8ce3e473dae40558d713e7a31b3858.tar.bz2 scummvm-rg350-fb4086cadb8ce3e473dae40558d713e7a31b3858.zip |
Merged from trunk, from Rev 50841 to HEAD
svn-id: r51495
Diffstat (limited to 'sound')
-rw-r--r-- | sound/audiostream.cpp | 2 | ||||
-rw-r--r-- | sound/decoders/aiff.cpp | 4 | ||||
-rw-r--r-- | sound/decoders/mac_snd.cpp | 116 | ||||
-rw-r--r-- | sound/decoders/mac_snd.h | 58 | ||||
-rw-r--r-- | sound/decoders/mp3.cpp | 6 | ||||
-rw-r--r-- | sound/mididrv.cpp | 13 | ||||
-rw-r--r-- | sound/mididrv.h | 2 | ||||
-rw-r--r-- | sound/midiparser.cpp | 4 | ||||
-rw-r--r-- | sound/midiparser_smf.cpp | 6 | ||||
-rw-r--r-- | sound/module.mk | 1 | ||||
-rw-r--r-- | sound/musicplugin.h | 2 | ||||
-rw-r--r-- | sound/rate_arm_asm.s | 30 | ||||
-rw-r--r-- | sound/softsynth/mt32.cpp | 4 | ||||
-rw-r--r-- | sound/softsynth/opl/dbopl.cpp | 2 | ||||
-rw-r--r-- | sound/softsynth/opl/mame.cpp | 4 |
15 files changed, 201 insertions, 53 deletions
diff --git a/sound/audiostream.cpp b/sound/audiostream.cpp index a092e6c29d..b3efb2cefe 100644 --- a/sound/audiostream.cpp +++ b/sound/audiostream.cpp @@ -393,7 +393,7 @@ Timestamp convertTimeToStreamPos(const Timestamp &where, int rate, bool isStereo // // An example is when converting the timestamp 500ms to a 11025 Hz based // stream. It would have an internal frame counter of 5512.5. Now when - // doing calculations at frame precision, this might lead to unexpected + // doing calculations at frame precision, this might lead to unexpected // results: The frame difference between a timestamp 1000ms and the above // mentioned timestamp (both with 11025 as framerate) would be 5512, // instead of 5513, which is what a frame-precision based code would expect. diff --git a/sound/decoders/aiff.cpp b/sound/decoders/aiff.cpp index b76410f8d1..ce8c6ad32c 100644 --- a/sound/decoders/aiff.cpp +++ b/sound/decoders/aiff.cpp @@ -175,7 +175,9 @@ SeekableAudioStream *makeAIFFStream(Common::SeekableReadStream *stream, data = (byte *)malloc(size); assert(data); stream->read(data, size); - delete stream; + + if (disposeAfterUse == DisposeAfterUse::YES) + delete stream; // Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES. return makeRawStream(data, size, rate, flags); diff --git a/sound/decoders/mac_snd.cpp b/sound/decoders/mac_snd.cpp new file mode 100644 index 0000000000..d6894f1144 --- /dev/null +++ b/sound/decoders/mac_snd.cpp @@ -0,0 +1,116 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/* + * The code in this file is based on information found at + * http://developer.apple.com/legacy/mac/library/documentation/mac/Sound/Sound-60.html#HEADING60-15 + * + * We implement both type 1 and type 2 snd resources, but only those that are sampled + */ + +#include "common/util.h" +#include "common/stream.h" + +#include "sound/decoders/mac_snd.h" +#include "sound/audiostream.h" +#include "sound/decoders/raw.h" + +namespace Audio { + +SeekableAudioStream *makeMacSndStream(Common::SeekableReadStream *stream, + DisposeAfterUse::Flag disposeAfterUse) { + + uint16 sndType = stream->readUint16BE(); + + if (sndType == 1) { + // "normal" snd resources + if (stream->readUint16BE() != 1) { + warning("makeMacSndStream(): Unsupported data type count"); + return 0; + } + + if (stream->readUint16BE() != 5) { + // 5 == sampled + warning("makeMacSndStream(): Unsupported data type"); + return 0; + } + + stream->readUint32BE(); // initialization option + } else if (sndType == 2) { + // old HyperCard snd resources + stream->readUint16BE(); // reference count (unused) + } else { + warning("makeMacSndStream(): Unknown format type %d", sndType); + return 0; + } + + // We really should never get this as long as we have sampled data only + if (stream->readUint16BE() != 1) { + warning("makeMacSndStream(): Unsupported command count"); + return 0; + } + + uint16 command = stream->readUint16BE(); + + // 0x8050 - soundCmd (with dataOffsetFlag set): install a sampled sound as a voice + // 0x8051 - bufferCmd (with dataOffsetFlag set): play a sample sound + if (command != 0x8050 && command != 0x8051) { + warning("makeMacSndStream(): Unsupported command %04x", command); + return 0; + } + + stream->readUint16BE(); // 0 + uint32 soundHeaderOffset = stream->readUint32BE(); + + stream->seek(soundHeaderOffset); + + uint32 soundDataOffset = stream->readUint32BE(); + uint32 size = stream->readUint32BE(); + uint16 rate = stream->readUint32BE() >> 16; // Really fixed point, but we only support integer rates + stream->readUint32BE(); // loop start + stream->readUint32BE(); // loop end + byte encoding = stream->readByte(); + stream->readByte(); // base frequency + + if (encoding != 0) { + // 0 == PCM + warning("makeMacSndStream(): Unsupported compression %d", encoding); + return 0; + } + + stream->skip(soundDataOffset); + + byte *data = (byte *)malloc(size); + assert(data); + stream->read(data, size); + + if (disposeAfterUse == DisposeAfterUse::YES) + delete stream; + + // Since we allocated our own buffer for the data, we must specify DisposeAfterUse::YES. + return makeRawStream(data, size, rate, Audio::FLAG_UNSIGNED); +} + +} // End of namespace Audio diff --git a/sound/decoders/mac_snd.h b/sound/decoders/mac_snd.h new file mode 100644 index 0000000000..198a61333e --- /dev/null +++ b/sound/decoders/mac_snd.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +/** + * @file + * Sound decoder used in engines: + * - sci + */ + +#ifndef SOUND_MAC_SND_H +#define SOUND_MAC_SND_H + +#include "common/scummsys.h" +#include "common/types.h" + +namespace Common { class SeekableReadStream; } + +namespace Audio { + +class SeekableAudioStream; + +/** + * Try to load a Mac snd resource from the given seekable stream and create a SeekableAudioStream + * from that data. + * + * @param stream the SeekableReadStream from which to read the snd data + * @param disposeAfterUse whether to delete the stream after use + * @return a new SeekableAudioStream, or NULL, if an error occurred + */ +SeekableAudioStream *makeMacSndStream( + Common::SeekableReadStream *stream, + DisposeAfterUse::Flag disposeAfterUse); + +} // End of namespace Audio + +#endif diff --git a/sound/decoders/mp3.cpp b/sound/decoders/mp3.cpp index 2f0419d35e..e54d646b0a 100644 --- a/sound/decoders/mp3.cpp +++ b/sound/decoders/mp3.cpp @@ -348,13 +348,13 @@ int MP3Stream::readBuffer(int16 *buffer, const int numSamples) { SeekableAudioStream *makeMP3Stream( Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse) { - + #if defined(__PSP__) SeekableAudioStream *s = 0; - + if (Mp3PspStream::isOkToCreateStream()) s = new Mp3PspStream(stream, disposeAfterUse); - + if (!s) // go to regular MAD mp3 stream if ME fails s = new MP3Stream(stream, disposeAfterUse); #else diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index aaff78bf92..c7587992e0 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -94,7 +94,7 @@ MusicType MidiDriver::getMusicType(MidiDriver::DeviceHandle handle) { } } } - + return MT_INVALID; } @@ -139,7 +139,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { if (flags & MDT_PCJR) return hdl; break; - + case MT_CMS: if (flags & MDT_CMS) return hdl; @@ -149,7 +149,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { if (flags & MDT_ADLIB) return hdl; break; - + case MT_TOWNS: if (flags & MDT_TOWNS) return hdl; @@ -261,12 +261,15 @@ MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &ident const MusicPlugin::List p = MusicMan.getPlugins(); if (p.begin() == p.end()) - error("Music plugins must be loaded prior to calling this method."); + error("Music plugins must be loaded prior to calling this method"); for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { MusicDevices i = (**m)->getDevices(); for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { - if (identifier.equals(d->getCompleteId()) || identifier.equals(d->getCompleteName())) { + // The music driver id isn't unique, but it will match + // driver's first device. This is useful when selecting + // the driver from the command line. + if (identifier.equals(d->getMusicDriverId()) || identifier.equals(d->getCompleteId()) || identifier.equals(d->getCompleteName())) { return d->getHandle(); } } diff --git a/sound/mididrv.h b/sound/mididrv.h index 5fffd430fb..1184adee6c 100644 --- a/sound/mididrv.h +++ b/sound/mididrv.h @@ -124,7 +124,7 @@ public: /** Returns device handle based on the present devices and the flags parameter. */ static DeviceHandle detectDevice(int flags); - + /** Find the music driver matching the given driver name/description. */ static DeviceHandle getDeviceHandle(const Common::String &identifier); diff --git a/sound/midiparser.cpp b/sound/midiparser.cpp index d58471765e..929b1d8b12 100644 --- a/sound/midiparser.cpp +++ b/sound/midiparser.cpp @@ -333,7 +333,7 @@ void MidiParser::hangAllActiveNotes() { uint32 advance_tick = _position._last_event_tick; while (true) { - int i, j; + int i; for (i = 0; i < 128; ++i) if (temp_active[i] != 0) break; @@ -349,7 +349,7 @@ void MidiParser::hangAllActiveNotes() { } else if (_next_event.event == 0xFF && _next_event.ext.type == 0x2F) { // warning("MidiParser::hangAllActiveNotes(): Hit End of Track with active notes left"); for (i = 0; i < 128; ++i) { - for (j = 0; j < 16; ++j) { + for (int j = 0; j < 16; ++j) { if (temp_active[i] & (1 << j)) { activeNote(j, i, false); sendToDriver(0x80 | j, i, 0); diff --git a/sound/midiparser_smf.cpp b/sound/midiparser_smf.cpp index 4261b1d770..a9c6f1eb3b 100644 --- a/sound/midiparser_smf.cpp +++ b/sound/midiparser_smf.cpp @@ -230,10 +230,8 @@ bool MidiParser_SMF::loadMusic(byte *data, uint32 size) { // If this is a Type 1 MIDI, we need to now compress // our tracks down into a single Type 0 track. - if (_buffer) { - free(_buffer); - _buffer = 0; - } + free(_buffer); + _buffer = 0; if (midi_type == 1) { // FIXME: Doubled the buffer size to prevent crashes with the diff --git a/sound/module.mk b/sound/module.mk index a578e2894a..a3fa4027c9 100644 --- a/sound/module.mk +++ b/sound/module.mk @@ -16,6 +16,7 @@ MODULE_OBJS := \ decoders/aiff.o \ decoders/flac.o \ decoders/iff_sound.o \ + decoders/mac_snd.o \ decoders/mp3.o \ decoders/raw.o \ decoders/vag.o \ diff --git a/sound/musicplugin.h b/sound/musicplugin.h index 3823f2fd3d..bbb4ed778c 100644 --- a/sound/musicplugin.h +++ b/sound/musicplugin.h @@ -50,7 +50,7 @@ public: * device name (if it isn't the default one) and the name of the driver. */ Common::String getCompleteName(); - + /** * Returns a user readable string that contains the name of the current * device name (if it isn't the default one) and the id of the driver. diff --git a/sound/rate_arm_asm.s b/sound/rate_arm_asm.s index a0e116f8f7..9431ae0649 100644 --- a/sound/rate_arm_asm.s +++ b/sound/rate_arm_asm.s @@ -212,9 +212,6 @@ SimpleRate_M_end: SimpleRate_M_read: LDR r0, [r13,#8] @ r0 = sr (8 = 4*2) ADD r0, r0, #16 @ r0 = inPtr = inBuf - .ifdef PALMOS_MODE - LDR r10,[r13,#4*8] @ restore r10 - .endif STMFD r13!,{r0,r2-r3,r12,r14} MOV r1, r0 @ r1 = inBuf @@ -229,9 +226,6 @@ SimpleRate_M_read: SUBS r1, r0, #1 @ r1 = inLen-1 LDMFD r13!,{r0,r2-r3,r12,r14} BLT SimpleRate_M_end - .ifdef PALMOS_MODE - MOV r10,#0 - .endif SUBS r2, r2, #1 @ r2 = opos-- ADDGE r0, r0, #2 @ if (r2 >= 0) { sr.inPtr++ BGE SimpleRate_M_loop @ and loop } @@ -297,9 +291,6 @@ SimpleRate_S_end: SimpleRate_S_read: LDR r0, [r13,#8] @ r0 = sr (8 = 4*2) ADD r0, r0, #16 @ r0 = inPtr = inBuf - .ifdef PALMOS_MODE - LDR r10,[r13,#4*8] @ restore r10 - .endif STMFD r13!,{r0,r2-r3,r12,r14} MOV r1, r0 @ r1 = inBuf LDR r0, [r13,#20] @ r0 = AudioStream & input (20 = 4*5) @@ -313,9 +304,6 @@ SimpleRate_S_read: SUBS r1, r0, #2 @ r1 = inLen-2 LDMFD r13!,{r0,r2-r3,r12,r14} BLT SimpleRate_S_end - .ifdef PALMOS_MODE - MOV r10,#0 - .endif SUBS r2, r2, #1 @ r2 = opos-- ADDGE r0, r0, #4 @ if (r2 >= 0) { sr.inPtr += 2 BGE SimpleRate_S_loop @ and loop } @@ -382,9 +370,6 @@ SimpleRate_R_end: SimpleRate_R_read: LDR r0, [r13,#8] @ r0 = sr (8 = 4*2) ADD r0, r0, #16 @ r0 = inPtr = inBuf - .ifdef PALMOS_MODE - LDR r10,[r13,#4*8] @ restore r10 - .endif STMFD r13!,{r0,r2-r3,r12,r14} MOV r1, r0 @ r1 = inBuf @@ -399,9 +384,6 @@ SimpleRate_R_read: SUBS r1, r0, #2 @ r1 = inLen-2 LDMFD r13!,{r0,r2-r3,r12,r14} BLT SimpleRate_R_end - .ifdef PALMOS_MODE - MOV r10,#0 - .endif SUBS r2, r2, #1 @ r2 = opos-- ADDGE r0, r0, #4 @ if (r2 >= 0) { sr.inPtr += 2 BGE SimpleRate_R_loop @ and loop } @@ -484,9 +466,6 @@ LinearRate_M_end: LDMFD r13!,{r4-r11,PC} LinearRate_M_read: ADD r0, r2, #28 @ r0 = inPtr = inBuf - .ifdef PALMOS_MODE - LDR r10,[r13,#4*8] @ restore r10 - .endif STMFD r13!,{r0,r2-r3,r12,r14} MOV r1, r0 @ r1 = inBuf @@ -501,9 +480,6 @@ LinearRate_M_read: SUBS r1, r0, #1 @ r1 = inLen-1 LDMFD r13!,{r0,r2-r3,r12,r14} BLT LinearRate_M_end - .ifdef PALMOS_MODE - MOV r10,#0 - .endif B LinearRate_M_read_return _ARM_LinearRate_S: @@ -592,9 +568,6 @@ LinearRate_S_end: LDMFD r13!,{r4-r11,PC} LinearRate_S_read: ADD r0, r2, #28 @ r0 = inPtr = inBuf - .ifdef PALMOS_MODE - LDR r10,[r13,#4*8] @ restore r10 - .endif STMFD r13!,{r0,r2-r3,r12,r14} MOV r1, r0 @ r1 = inBuf @@ -697,9 +670,6 @@ LinearRate_R_end: LDMFD r13!,{r4-r11,PC} LinearRate_R_read: ADD r0, r2, #28 @ r0 = inPtr = inBuf - .ifdef PALMOS_MODE - LDR r10,[r13,#4*8] @ restore r10 - .endif STMFD r13!,{r0,r2-r3,r12,r14} MOV r1, r0 @ r1 = inBuf diff --git a/sound/softsynth/mt32.cpp b/sound/softsynth/mt32.cpp index 95263a040d..54366a4300 100644 --- a/sound/softsynth/mt32.cpp +++ b/sound/softsynth/mt32.cpp @@ -149,7 +149,7 @@ static void drawProgress(float progress) { Common::Rect r(x, y, x + w, y + h); uint32 col; - + if (screenFormat.bytesPerPixel > 1) col = screenFormat.RGBToColor(0, 171, 0); else @@ -184,7 +184,7 @@ static void drawMessage(int offset, const Common::String &text) { uint16 y = g_system->getHeight() / 2 - h / 2 + offset * (h + 1); uint32 col; - + if (screenFormat.bytesPerPixel > 1) col = screenFormat.RGBToColor(0, 0, 0); else diff --git a/sound/softsynth/opl/dbopl.cpp b/sound/softsynth/opl/dbopl.cpp index db07eaf8cc..857ed78436 100644 --- a/sound/softsynth/opl/dbopl.cpp +++ b/sound/softsynth/opl/dbopl.cpp @@ -418,7 +418,7 @@ Bits Operator::TemplateVolume( ) { } //In sustain phase, but not sustaining, do regular release case RELEASE: - vol += RateForward( releaseAdd );; + vol += RateForward( releaseAdd ); if ( GCC_UNLIKELY(vol >= ENV_MAX) ) { volume = ENV_MAX; SetState( OFF ); diff --git a/sound/softsynth/opl/mame.cpp b/sound/softsynth/opl/mame.cpp index 9e7cbfe3dc..f6da659918 100644 --- a/sound/softsynth/opl/mame.cpp +++ b/sound/softsynth/opl/mame.cpp @@ -33,7 +33,7 @@ #include "mame.h" -#if defined (_WIN32_WCE) || defined (__SYMBIAN32__) || defined(PALMOS_MODE) || defined(__GP32__) || defined(GP2X) || defined (__MAEMO__) || defined(__DS__) || defined (__MINT__) || defined(__N64__) +#if defined (_WIN32_WCE) || defined (__SYMBIAN32__) || defined(__GP32__) || defined(GP2X) || defined (__MAEMO__) || defined(__DS__) || defined (__MINT__) || defined(__N64__) #include "common/config-manager.h" #endif @@ -1212,7 +1212,7 @@ FM_OPL *makeAdLibOPL(int rate) { // We need to emulate one YM3812 chip int env_bits = FMOPL_ENV_BITS_HQ; int eg_ent = FMOPL_EG_ENT_HQ; -#if defined (_WIN32_WCE) || defined(__SYMBIAN32__) || defined(PALMOS_MODE) || defined(__GP32__) || defined (GP2X) || defined(__MAEMO__) || defined(__DS__) || defined (__MINT__) || defined(__N64__) +#if defined (_WIN32_WCE) || defined(__SYMBIAN32__) || defined(__GP32__) || defined (GP2X) || defined(__MAEMO__) || defined(__DS__) || defined (__MINT__) || defined(__N64__) if (ConfMan.hasKey("FM_high_quality") && ConfMan.getBool("FM_high_quality")) { env_bits = FMOPL_ENV_BITS_HQ; eg_ent = FMOPL_EG_ENT_HQ; |