VIDEO: Don't fill empty sound slices at the end

svn-id: r55502
This commit is contained in:
Sven Hesse 2011-01-24 14:09:47 +00:00
parent 6dc0999c6d
commit 6ca13f926d
2 changed files with 30 additions and 13 deletions

View File

@ -220,6 +220,14 @@ void CoktelDecoder::disableSound() {
_audioStream = 0;
}
void CoktelDecoder::finishSound() {
if (!_audioStream)
return;
_audioStream->finish();
_soundStage = kSoundFinished;
}
void CoktelDecoder::colorModeChanged() {
}
@ -1531,9 +1539,10 @@ VMDDecoder::VMDDecoder(Audio::Mixer *mixer, Audio::Mixer::SoundType soundType) :
_stream(0), _version(0), _flags(0), _frameInfoOffset(0), _partsPerFrame(0), _frames(0),
_soundFlags(0), _soundFreq(0), _soundSliceSize(0), _soundSlicesCount(0),
_soundBytesPerSample(0), _soundStereo(0), _soundHeaderSize(0), _soundDataSize(0),
_audioFormat(kAudioFormat8bitRaw), _hasVideo(false), _videoCodec(0),
_blitMode(0), _bytesPerPixel(0), _firstFramePos(0), _videoBufferSize(0),
_externalCodec(false), _codec(0), _subtitle(-1), _isPaletted(true) {
_soundLastFilledFrame(0), _audioFormat(kAudioFormat8bitRaw),
_hasVideo(false), _videoCodec(0), _blitMode(0), _bytesPerPixel(0),
_firstFramePos(0), _videoBufferSize(0), _externalCodec(false), _codec(0),
_subtitle(-1), _isPaletted(true) {
_videoBuffer [0] = 0;
_videoBuffer [1] = 0;
@ -1896,6 +1905,7 @@ bool VMDDecoder::readFrameTable(int &numFiles) {
_frames[i].offset = _stream->readUint32LE();
}
_soundLastFilledFrame = 0;
for (uint16 i = 0; i < _frameCount; i++) {
bool separator = false;
@ -1910,6 +1920,9 @@ bool VMDDecoder::readFrameTable(int &numFiles) {
_frames[i].parts[j].flags = _stream->readByte();
_stream->skip(9); // Unknown
if (_frames[i].parts[j].flags != 3)
_soundLastFilledFrame = i;
} else if (_frames[i].parts[j].type == kPartTypeVideo) {
_frames[i].parts[j].left = _stream->readUint16LE();
@ -2006,15 +2019,16 @@ void VMDDecoder::close() {
_partsPerFrame = 0;
_frames = 0;
_soundFlags = 0;
_soundFreq = 0;
_soundSliceSize = 0;
_soundSlicesCount = 0;
_soundBytesPerSample = 0;
_soundStereo = 0;
_soundHeaderSize = 0;
_soundDataSize = 0;
_audioFormat = kAudioFormat8bitRaw;
_soundFlags = 0;
_soundFreq = 0;
_soundSliceSize = 0;
_soundSlicesCount = 0;
_soundBytesPerSample = 0;
_soundStereo = 0;
_soundHeaderSize = 0;
_soundDataSize = 0;
_soundLastFilledFrame = 0;
_audioFormat = kAudioFormat8bitRaw;
_hasVideo = false;
_videoCodec = 0;
@ -2101,7 +2115,8 @@ void VMDDecoder::processFrame() {
// Empty sound slice
if (_soundEnabled) {
emptySoundSlice(_soundDataSize * _soundBytesPerSample);
if ((uint32)_curFrame < _soundLastFilledFrame)
emptySoundSlice(_soundDataSize * _soundBytesPerSample);
if (_soundStage == kSoundLoaded)
startSound = true;

View File

@ -105,6 +105,7 @@ public:
void enableSound();
void disableSound();
void finishSound();
virtual void colorModeChanged();
@ -453,6 +454,7 @@ private:
byte _soundStereo; // (0: mono, 1: old-style stereo, 2: new-style stereo)
uint32 _soundHeaderSize;
uint32 _soundDataSize;
uint32 _soundLastFilledFrame;
AudioFormat _audioFormat;
// Video properties