Skip to content

Commit

Permalink
Merge branch 'master' into teenagentRefactor
Browse files Browse the repository at this point in the history
Conflicts:
	engines/teenagent/callbacks.cpp
  • Loading branch information
digitall committed Oct 12, 2012
2 parents 80af0e2 + 2b55837 commit 151b7be
Show file tree
Hide file tree
Showing 1,141 changed files with 177,782 additions and 14,617 deletions.
423 changes: 229 additions & 194 deletions AUTHORS

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion NEWS
@@ -1,7 +1,26 @@
For a more comprehensive changelog of the latest experimental code, see:
https://github.com/scummvm/scummvm/commits/

1.5.0 (????-??-??)
1.6.0 (????-??-??)
General:
- Added a new save/load chooser based on a grid of thumbnails. This is only
supported for resolutions bigger than 640x400. The old chooser is still
available and used for games without thumbnail support. It is possible to
select the old one as default too.
- Rewrote VideoDecoder subsystem.
- Added Galician translation.

Cine:
- Improved audio support for Amiga and AtariST versions of Future Wars.
Now music fades out slowly instead of stopping immediately. Sound
effects are now properly panned, when requested by the game.

SCUMM:
- Implemented Monkey Island 2 Macintosh's audio driver. Now we properly
support its sample based audio output. The same output is also used for
the m68k Macintosh version of Indiana Jones and the Fate of Atlantis.

1.5.0 (2012-07-27)
New Games:
- Added support for Backyard Baseball 2003.
- Added support for Blue Force.
Expand Down
2 changes: 1 addition & 1 deletion README
Expand Up @@ -2125,7 +2125,7 @@ Lands of Lore: The Throne of Chaos adds the following non-standard keywords:
Space Quest IV CD adds the following non-standard keyword:

silver_cursors bool If true, an alternate set of silver mouse cursors
is used instead of the original golden ones
is used instead of the original golden ones

Simon the Sorcerer 1 and 2 add the following non-standard keywords:

Expand Down
38 changes: 38 additions & 0 deletions audio/audiostream.cpp
Expand Up @@ -386,4 +386,42 @@ Timestamp convertTimeToStreamPos(const Timestamp &where, int rate, bool isStereo
return Timestamp(result.secs(), result.numberOfFrames(), result.framerate());
}

/**
* An AudioStream wrapper that cuts off the amount of samples read after a
* given time length is reached.
*/
class LimitingAudioStream : public AudioStream {
public:
LimitingAudioStream(AudioStream *parentStream, const Audio::Timestamp &length, DisposeAfterUse::Flag disposeAfterUse) :
_parentStream(parentStream), _samplesRead(0), _disposeAfterUse(disposeAfterUse),
_totalSamples(length.convertToFramerate(getRate()).totalNumberOfFrames() * getChannels()) {}

~LimitingAudioStream() {
if (_disposeAfterUse == DisposeAfterUse::YES)
delete _parentStream;
}

int readBuffer(int16 *buffer, const int numSamples) {
// Cap us off so we don't read past _totalSamples
int samplesRead = _parentStream->readBuffer(buffer, MIN<int>(numSamples, _totalSamples - _samplesRead));
_samplesRead += samplesRead;
return samplesRead;
}

bool endOfData() const { return _parentStream->endOfData() || _samplesRead >= _totalSamples; }
bool isStereo() const { return _parentStream->isStereo(); }
int getRate() const { return _parentStream->getRate(); }

private:
int getChannels() const { return isStereo() ? 2 : 1; }

AudioStream *_parentStream;
DisposeAfterUse::Flag _disposeAfterUse;
uint32 _totalSamples, _samplesRead;
};

AudioStream *makeLimitingAudioStream(AudioStream *parentStream, const Timestamp &length, DisposeAfterUse::Flag disposeAfterUse) {
return new LimitingAudioStream(parentStream, length, disposeAfterUse);
}

} // End of namespace Audio
10 changes: 10 additions & 0 deletions audio/audiostream.h
Expand Up @@ -356,6 +356,16 @@ QueuingAudioStream *makeQueuingAudioStream(int rate, bool stereo);
*/
Timestamp convertTimeToStreamPos(const Timestamp &where, int rate, bool isStereo);

/**
* Factory function for an AudioStream wrapper that cuts off the amount of samples read after a
* given time length is reached.
*
* @param parentStream The stream to limit
* @param length The time length to limit the stream to
* @param disposeAfterUse Whether the parent stream object should be destroyed on destruction of the returned stream
*/
AudioStream *makeLimitingAudioStream(AudioStream *parentStream, const Timestamp &length, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);

} // End of namespace Audio

#endif
32 changes: 22 additions & 10 deletions audio/decoders/adpcm.cpp
Expand Up @@ -71,13 +71,19 @@ int Oki_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) {
int samples;
byte data;

assert(numSamples % 2 == 0);
for (samples = 0; samples < numSamples && !endOfData(); samples++) {
if (_decodedSampleCount == 0) {
data = _stream->readByte();
_decodedSamples[0] = decodeOKI((data >> 4) & 0x0f);
_decodedSamples[1] = decodeOKI((data >> 0) & 0x0f);
_decodedSampleCount = 2;
}

for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
data = _stream->readByte();
buffer[samples] = decodeOKI((data >> 4) & 0x0f);
buffer[samples + 1] = decodeOKI(data & 0x0f);
// (1 - (count - 1)) ensures that _decodedSamples acts as a FIFO of depth 2
buffer[samples] = _decodedSamples[1 - (_decodedSampleCount - 1)];
_decodedSampleCount--;
}

return samples;
}

Expand Down Expand Up @@ -117,13 +123,19 @@ int DVI_ADPCMStream::readBuffer(int16 *buffer, const int numSamples) {
int samples;
byte data;

assert(numSamples % 2 == 0);
for (samples = 0; samples < numSamples && !endOfData(); samples++) {
if (_decodedSampleCount == 0) {
data = _stream->readByte();
_decodedSamples[0] = decodeIMA((data >> 4) & 0x0f, 0);
_decodedSamples[1] = decodeIMA((data >> 0) & 0x0f, _channels == 2 ? 1 : 0);
_decodedSampleCount = 2;
}

for (samples = 0; samples < numSamples && !_stream->eos() && _stream->pos() < _endpos; samples += 2) {
data = _stream->readByte();
buffer[samples] = decodeIMA((data >> 4) & 0x0f);
buffer[samples + 1] = decodeIMA(data & 0x0f, _channels == 2 ? 1 : 0);
// (1 - (count - 1)) ensures that _decodedSamples acts as a FIFO of depth 2
buffer[samples] = _decodedSamples[1 - (_decodedSampleCount - 1)];
_decodedSampleCount--;
}

return samples;
}

Expand Down
22 changes: 16 additions & 6 deletions audio/decoders/adpcm_intern.h
Expand Up @@ -37,7 +37,6 @@
#include "common/stream.h"
#include "common/textconsole.h"


namespace Audio {

class ADPCMStream : public RewindableAudioStream {
Expand All @@ -64,12 +63,11 @@ class ADPCMStream : public RewindableAudioStream {
ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign);

virtual bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
virtual bool isStereo() const { return _channels == 2; }
virtual int getRate() const { return _rate; }
virtual bool isStereo() const { return _channels == 2; }
virtual int getRate() const { return _rate; }

virtual bool rewind();


/**
* This table is used by some ADPCM variants (IMA and OKI) to adjust the
* step for use on the next sample.
Expand All @@ -83,12 +81,18 @@ class ADPCMStream : public RewindableAudioStream {
class Oki_ADPCMStream : public ADPCMStream {
public:
Oki_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign)
: ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {}
: ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; }

virtual bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }

virtual int readBuffer(int16 *buffer, const int numSamples);

protected:
int16 decodeOKI(byte);

private:
uint8 _decodedSampleCount;
int16 _decodedSamples[2];
};

class Ima_ADPCMStream : public ADPCMStream {
Expand All @@ -108,9 +112,15 @@ class Ima_ADPCMStream : public ADPCMStream {
class DVI_ADPCMStream : public Ima_ADPCMStream {
public:
DVI_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign)
: Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {}
: Ima_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { _decodedSampleCount = 0; }

virtual bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos) && (_decodedSampleCount == 0); }

virtual int readBuffer(int16 *buffer, const int numSamples);

private:
uint8 _decodedSampleCount;
int16 _decodedSamples[2];
};

class Apple_ADPCMStream : public Ima_ADPCMStream {
Expand Down
1 change: 1 addition & 0 deletions audio/decoders/aiff.h
Expand Up @@ -23,6 +23,7 @@
/**
* @file
* Sound decoder used in engines:
* - pegasus
* - saga
* - sci
* - sword1
Expand Down
8 changes: 4 additions & 4 deletions audio/decoders/qdm2.cpp
Expand Up @@ -689,7 +689,7 @@ static int getVlc2(Common::BitStream *s, int16 (*table)[2], int bits, int maxDep
code = table[index][0];
n = table[index][1];

if(maxDepth > 2 && n < 0) {
if (maxDepth > 2 && n < 0) {
s->skip(nbBits);
index = s->getBits(-n) + code;
code = table[index][0];
Expand Down Expand Up @@ -861,9 +861,9 @@ void initVlcSparse(VLC *vlc, int nb_bits, int nb_codes,
const void *symbols, int symbols_wrap, int symbols_size) {
vlc->bits = nb_bits;

if(vlc->table_size && vlc->table_size == vlc->table_allocated) {
if (vlc->table_size && vlc->table_size == vlc->table_allocated) {
return;
} else if(vlc->table_size) {
} else if (vlc->table_size) {
error("called on a partially initialized table");
}

Expand Down Expand Up @@ -1353,7 +1353,7 @@ void QDM2Stream::fix_coding_method_array(int sb, int channels, sb_int8_array cod

for (ch = 0; ch < channels; ch++) {
for (j = 0; j < 64; ) {
if((coding_method[ch][sb][j] - 8) > 22) {
if ((coding_method[ch][sb][j] - 8) > 22) {
run = 1;
case_val = 8;
} else {
Expand Down
47 changes: 6 additions & 41 deletions audio/decoders/quicktime.cpp
Expand Up @@ -61,41 +61,6 @@ class SilentAudioStream : public AudioStream {
bool _isStereo;
};

/**
* An AudioStream wrapper that cuts off the amount of samples read after a
* given time length is reached.
*/
class LimitingAudioStream : public AudioStream {
public:
LimitingAudioStream(AudioStream *parentStream, const Audio::Timestamp &length,
DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES) :
_parentStream(parentStream), _samplesRead(0), _disposeAfterUse(disposeAfterUse),
_totalSamples(length.convertToFramerate(getRate()).totalNumberOfFrames() * getChannels()) {}

~LimitingAudioStream() {
if (_disposeAfterUse == DisposeAfterUse::YES)
delete _parentStream;
}

int readBuffer(int16 *buffer, const int numSamples) {
// Cap us off so we don't read past _totalSamples
int samplesRead = _parentStream->readBuffer(buffer, MIN<int>(numSamples, _totalSamples - _samplesRead));
_samplesRead += samplesRead;
return samplesRead;
}

bool endOfData() const { return _parentStream->endOfData() || _samplesRead >= _totalSamples; }
bool isStereo() const { return _parentStream->isStereo(); }
int getRate() const { return _parentStream->getRate(); }

private:
int getChannels() const { return isStereo() ? 2 : 1; }

AudioStream *_parentStream;
DisposeAfterUse::Flag _disposeAfterUse;
uint32 _totalSamples, _samplesRead;
};

/**
* An AudioStream wrapper that forces audio to be played in mono.
* It currently just ignores the right channel if stereo.
Expand Down Expand Up @@ -230,7 +195,7 @@ QuickTimeAudioDecoder::QuickTimeAudioTrack::QuickTimeAudioTrack(QuickTimeAudioDe

if (entry->getCodecTag() == MKTAG('r', 'a', 'w', ' ') || entry->getCodecTag() == MKTAG('t', 'w', 'o', 's'))
_parentTrack->sampleSize = (entry->_bitsPerSample / 8) * entry->_channels;

// Initialize our edit parser too
_curEdit = 0;
enterNewEdit(Timestamp());
Expand Down Expand Up @@ -263,7 +228,7 @@ void QuickTimeAudioDecoder::QuickTimeAudioTrack::queueAudio(const Timestamp &len
_skipSamples = Timestamp();
}

queueStream(new LimitingAudioStream(new SilentAudioStream(getRate(), isStereo()), editLength), editLength);
queueStream(makeLimitingAudioStream(new SilentAudioStream(getRate(), isStereo()), editLength), editLength);
_curEdit++;
enterNewEdit(nextEditTime);
} else {
Expand All @@ -289,7 +254,7 @@ void QuickTimeAudioDecoder::QuickTimeAudioTrack::queueAudio(const Timestamp &len
// we move on to the next edit
if (trackPosition >= nextEditTime || _curChunk >= _parentTrack->chunkCount) {
chunkLength = nextEditTime.convertToFramerate(getRate()) - getCurrentTrackTime();
stream = new LimitingAudioStream(stream, chunkLength);
stream = makeLimitingAudioStream(stream, chunkLength);
_curEdit++;
enterNewEdit(nextEditTime);

Expand Down Expand Up @@ -430,9 +395,9 @@ AudioStream *QuickTimeAudioDecoder::QuickTimeAudioTrack::readAudioChunk(uint chu
}

void QuickTimeAudioDecoder::QuickTimeAudioTrack::skipSamples(const Timestamp &length, AudioStream *stream) {
uint32 sampleCount = length.convertToFramerate(getRate()).totalNumberOfFrames();
int32 sampleCount = length.convertToFramerate(getRate()).totalNumberOfFrames();

if (sampleCount == 0)
if (sampleCount <= 0)
return;

if (isStereo())
Expand Down Expand Up @@ -461,7 +426,7 @@ void QuickTimeAudioDecoder::QuickTimeAudioTrack::enterNewEdit(const Timestamp &p
// If we're at the end of the edit list, there's nothing else for us to do here
if (allDataRead())
return;

// For an empty edit, we may need to adjust the start time
if (_parentTrack->editList[_curEdit].mediaTime == -1) {
// Just invalidate the current media position (and make sure the scale
Expand Down
1 change: 1 addition & 0 deletions audio/decoders/quicktime.h
Expand Up @@ -25,6 +25,7 @@
* Sound decoder used in engines:
* - groovie
* - mohawk
* - pegasus
* - sci
*/

Expand Down
4 changes: 2 additions & 2 deletions audio/decoders/quicktime_intern.h
Expand Up @@ -88,7 +88,7 @@ class QuickTimeAudioDecoder : public Common::QuickTimeParser {

private:
QuickTimeAudioDecoder *_decoder;
Track *_parentTrack;
Track *_parentTrack;
QueuingAudioStream *_queue;
uint _curChunk;
Timestamp _curMediaPos, _skipSamples;
Expand All @@ -115,7 +115,7 @@ class QuickTimeAudioDecoder : public Common::QuickTimeParser {
~AudioSampleDesc();

bool isAudioCodecSupported() const;

AudioStream *createAudioStream(Common::SeekableReadStream *stream) const;
void initCodec();

Expand Down
2 changes: 1 addition & 1 deletion audio/mididrv.cpp
Expand Up @@ -240,7 +240,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
devStr = ConfMan.hasKey("gm_device") ? ConfMan.get("gm_device") : Common::String("null");
else
devStr = "auto";

// Default to Null device here, since we also register a default null setting for
// the MT32 or GM device in the config manager.
hdl = getDeviceHandle(devStr.empty() ? Common::String("null") : devStr);
Expand Down

0 comments on commit 151b7be

Please sign in to comment.