aboutsummaryrefslogtreecommitdiff
path: root/video/smk_decoder.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2014-01-09 21:28:58 -0500
committerMatthew Hoops2014-01-11 18:43:42 -0500
commit1e95a49892e43a26c6a056b0583753728c4c7616 (patch)
tree67d9a1bda34b1a486a850c9c7b515b9fc38372c2 /video/smk_decoder.cpp
parentce82977ea152ea617b2e6c005b2bcfedb2a0e85c (diff)
downloadscummvm-rg350-1e95a49892e43a26c6a056b0583753728c4c7616.tar.gz
scummvm-rg350-1e95a49892e43a26c6a056b0583753728c4c7616.tar.bz2
scummvm-rg350-1e95a49892e43a26c6a056b0583753728c4c7616.zip
VIDEO: Add support for multiple Smacker audio tracks
Diffstat (limited to 'video/smk_decoder.cpp')
-rw-r--r--video/smk_decoder.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp
index 0247fe5dc9..b31ad109ad 100644
--- a/video/smk_decoder.cpp
+++ b/video/smk_decoder.cpp
@@ -369,8 +369,7 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) {
if (_header.audioInfo[i].compression == kCompressionRDFT || _header.audioInfo[i].compression == kCompressionDCT)
warning("Unhandled Smacker v2 audio compression");
- if (i == 0)
- addTrack(new SmackerAudioTrack(_header.audioInfo[i], _soundType));
+ addTrack(new SmackerAudioTrack(_header.audioInfo[i], _soundType));
}
}
@@ -477,7 +476,10 @@ void SmackerDecoder::readNextPacket() {
}
void SmackerDecoder::handleAudioTrack(byte track, uint32 chunkSize, uint32 unpackedSize) {
- if (_header.audioInfo[track].hasAudio && chunkSize > 0 && track == 0) {
+ if (chunkSize == 0)
+ return;
+
+ if (_header.audioInfo[track].hasAudio) {
// Get the audio track, which start at offset 1 (first track is video)
SmackerAudioTrack *audioTrack = (SmackerAudioTrack *)getTrack(track + 1);
@@ -501,14 +503,21 @@ void SmackerDecoder::handleAudioTrack(byte track, uint32 chunkSize, uint32 unpac
audioTrack->queuePCM(soundBuffer, chunkSize);
}
} else {
- // Ignore the rest of the audio tracks, if they exist
- // TODO: Are there any Smacker videos with more than one audio stream?
- // If yes, we should play the rest of the audio streams as well
- if (chunkSize > 0)
- _fileStream->skip(chunkSize);
+ // Ignore possibly unused data
+ _fileStream->skip(chunkSize);
}
}
+VideoDecoder::AudioTrack *SmackerDecoder::getAudioTrack(int index) {
+ // Smacker audio track indexes are relative to the first audio track
+ Track *track = getTrack(index + 1);
+
+ if (!track || track->getTrackType() != Track::kTrackTypeAudio)
+ return 0;
+
+ return (AudioTrack *)track;
+}
+
SmackerDecoder::SmackerVideoTrack::SmackerVideoTrack(uint32 width, uint32 height, uint32 frameCount, const Common::Rational &frameRate, uint32 flags, uint32 signature) {
_surface = new Graphics::Surface();
_surface->create(width, height * (flags ? 2 : 1), Graphics::PixelFormat::createFormatCLUT8());