[Scummvm-cvs-logs] scummvm master -> 3e47203d645b24b8d94cb2ac742072764e49ef04
clone2727
clone2727 at gmail.com
Tue Apr 10 22:46:28 CEST 2012
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3e47203d64 AUDIO: Force QuickTime stereo samples to mono if needed
Commit: 3e47203d645b24b8d94cb2ac742072764e49ef04
https://github.com/scummvm/scummvm/commit/3e47203d645b24b8d94cb2ac742072764e49ef04
Author: Matthew Hoops (clone2727 at gmail.com)
Date: 2012-04-10T13:44:41-07:00
Commit Message:
AUDIO: Force QuickTime stereo samples to mono if needed
The number of channels in AAC can differ from the actual number of channels needed making us require this. The channel count inside the container is always the correct one.
Changed paths:
audio/decoders/quicktime.cpp
diff --git a/audio/decoders/quicktime.cpp b/audio/decoders/quicktime.cpp
index 762e869..48e76a9 100644
--- a/audio/decoders/quicktime.cpp
+++ b/audio/decoders/quicktime.cpp
@@ -96,6 +96,45 @@ private:
uint32 _totalSamples, _samplesRead;
};
+/**
+ * An AudioStream wrapper that forces audio to be played in mono.
+ * It currently just ignores the right channel if stereo.
+ */
+class ForcedMonoAudioStream : public AudioStream {
+public:
+ ForcedMonoAudioStream(AudioStream *parentStream, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES) :
+ _parentStream(parentStream), _disposeAfterUse(disposeAfterUse) {}
+
+ ~ForcedMonoAudioStream() {
+ if (_disposeAfterUse == DisposeAfterUse::YES)
+ delete _parentStream;
+ }
+
+ int readBuffer(int16 *buffer, const int numSamples) {
+ if (!_parentStream->isStereo())
+ return _parentStream->readBuffer(buffer, numSamples);
+
+ int16 temp[2];
+ int samples = 0;
+
+ while (samples < numSamples && !endOfData()) {
+ _parentStream->readBuffer(temp, 2);
+ *buffer++ = temp[0];
+ samples++;
+ }
+
+ return samples;
+ }
+
+ bool endOfData() const { return _parentStream->endOfData(); }
+ bool isStereo() const { return false; }
+ int getRate() const { return _parentStream->getRate(); }
+
+private:
+ AudioStream *_parentStream;
+ DisposeAfterUse::Flag _disposeAfterUse;
+};
+
QuickTimeAudioDecoder::QuickTimeAudioDecoder() : Common::QuickTimeParser() {
}
@@ -495,7 +534,13 @@ void QuickTimeAudioDecoder::QuickTimeAudioTrack::enterNewEdit(const Timestamp &p
}
void QuickTimeAudioDecoder::QuickTimeAudioTrack::queueStream(AudioStream *stream, const Timestamp &length) {
- _queue->queueAudioStream(stream, DisposeAfterUse::YES);
+ // If the samples are stereo and the container is mono, force the samples
+ // to be mono.
+ if (stream->isStereo() && !isStereo())
+ _queue->queueAudioStream(new ForcedMonoAudioStream(stream, DisposeAfterUse::YES), DisposeAfterUse::YES);
+ else
+ _queue->queueAudioStream(stream, DisposeAfterUse::YES);
+
_samplesQueued += length.convertToFramerate(getRate()).totalNumberOfFrames();
}
More information about the Scummvm-git-logs
mailing list