aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2010-01-08 22:04:30 +0000
committerMax Horn2010-01-08 22:04:30 +0000
commit95726dfe50eae85d0e7675f8891339fb0abb43fd (patch)
treebf4f9ebb29ce8f74e2f3eee786931859b76fcc1f /engines
parentf263393ef00517143876d26da2d35541307cb51c (diff)
downloadscummvm-rg350-95726dfe50eae85d0e7675f8891339fb0abb43fd.tar.gz
scummvm-rg350-95726dfe50eae85d0e7675f8891339fb0abb43fd.tar.bz2
scummvm-rg350-95726dfe50eae85d0e7675f8891339fb0abb43fd.zip
Move Mohawk's QueuedAudioStream to sound/ (with some tweaks)
svn-id: r47177
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/video/qt_player.cpp47
-rw-r--r--engines/mohawk/video/qt_player.h27
2 files changed, 4 insertions, 70 deletions
diff --git a/engines/mohawk/video/qt_player.cpp b/engines/mohawk/video/qt_player.cpp
index 8c6e9b1a95..d9d4a68dac 100644
--- a/engines/mohawk/video/qt_player.cpp
+++ b/engines/mohawk/video/qt_player.cpp
@@ -51,47 +51,6 @@
namespace Mohawk {
////////////////////////////////////////////
-// QueuedAudioStream
-////////////////////////////////////////////
-
-QueuedAudioStream::QueuedAudioStream(int rate, int channels, bool autofree) {
- _rate = rate;
- _channels = channels;
- _autofree = autofree;
- _finished = false;
-}
-
-QueuedAudioStream::~QueuedAudioStream() {
- if (_autofree)
- while (!_queue.empty())
- delete _queue.pop();
- _queue.clear();
-}
-
-void QueuedAudioStream::queueAudioStream(Audio::AudioStream *audStream) {
- if (audStream->getRate() != getRate() && audStream->isStereo() && isStereo())
- error("QueuedAudioStream::queueAudioStream: audStream has mismatched parameters");
-
- _queue.push(audStream);
-}
-
-int QueuedAudioStream::readBuffer(int16 *buffer, const int numSamples) {
- int samplesDecoded = 0;
-
- while (samplesDecoded < numSamples && !_queue.empty()) {
- samplesDecoded += _queue.front()->readBuffer(buffer + samplesDecoded, numSamples - samplesDecoded);
-
- if (_queue.front()->endOfData()) {
- Audio::AudioStream *temp = _queue.pop();
- if (_autofree)
- delete temp;
- }
- }
-
- return samplesDecoded;
-}
-
-////////////////////////////////////////////
// QTPlayer
////////////////////////////////////////////
@@ -189,7 +148,7 @@ void QTPlayer::reset() {
stopAudio();
if (_audioStreamIndex >= 0) {
_curAudioChunk = 0;
- _audStream = new QueuedAudioStream(_streams[_audioStreamIndex]->sample_rate, _streams[_audioStreamIndex]->channels);
+ _audStream = Audio::makeQueuedAudioStream(_streams[_audioStreamIndex]->sample_rate, _streams[_audioStreamIndex]->channels == 2);
}
startAudio();
}
@@ -345,7 +304,7 @@ bool QTPlayer::loadFile(Common::SeekableReadStream *stream) {
}
if (_audioStreamIndex >= 0 && checkAudioCodecSupport(_streams[_audioStreamIndex]->codec_tag)) {
- _audStream = new QueuedAudioStream(_streams[_audioStreamIndex]->sample_rate, _streams[_audioStreamIndex]->channels);
+ _audStream = Audio::makeQueuedAudioStream(_streams[_audioStreamIndex]->sample_rate, _streams[_audioStreamIndex]->channels == 2);
_curAudioChunk = 0;
// Make sure the bits per sample transfers to the sample size
@@ -1229,7 +1188,7 @@ void QTPlayer::updateAudioBuffer() {
return;
// Keep two streams in buffer so that when the first ends, it goes right into the next
- for (; _audStream->streamsInQueue() < 2 && _curAudioChunk < _streams[_audioStreamIndex]->chunk_count; _curAudioChunk++) {
+ for (; _audStream->numQueuedStreams() < 2 && _curAudioChunk < _streams[_audioStreamIndex]->chunk_count; _curAudioChunk++) {
Common::MemoryWriteStreamDynamic *wStream = new Common::MemoryWriteStreamDynamic();
_fd->seek(_streams[_audioStreamIndex]->chunk_offsets[_curAudioChunk]);
diff --git a/engines/mohawk/video/qt_player.h b/engines/mohawk/video/qt_player.h
index 4bdf5b869b..5ff27a57c5 100644
--- a/engines/mohawk/video/qt_player.h
+++ b/engines/mohawk/video/qt_player.h
@@ -46,31 +46,6 @@ namespace Common {
namespace Mohawk {
-class QueuedAudioStream : public Audio::AudioStream {
-public:
- QueuedAudioStream(int rate, int channels, bool autofree = true);
- ~QueuedAudioStream();
-
- int readBuffer(int16 *buffer, const int numSamples);
- bool isStereo() const { return _channels == 2; }
- int getRate() const { return _rate; }
- bool endOfData() const { return _queue.empty(); }
- bool endOfStream() const { return _finished; }
-
- void queueAudioStream(Audio::AudioStream *audStream);
- void finish() { _finished = true; }
-
- uint32 streamsInQueue() { return _queue.size(); }
-
-private:
- bool _autofree;
- bool _finished;
- int _rate;
- int _channels;
-
- Common::Queue<Audio::AudioStream*> _queue;
-};
-
enum ScaleMode {
kScaleNormal = 1,
kScaleHalf = 2,
@@ -271,7 +246,7 @@ protected:
void resetInternal();
uint32 getFrameDuration();
- QueuedAudioStream *_audStream;
+ Audio::QueuedAudioStream *_audStream;
int8 _videoStreamIndex;
int8 _audioStreamIndex;
uint _curAudioChunk;