aboutsummaryrefslogtreecommitdiff
path: root/sound/mixer.cpp
diff options
context:
space:
mode:
authorMax Horn2003-12-17 01:50:50 +0000
committerMax Horn2003-12-17 01:50:50 +0000
commit4343567458cefe5de8f3493040c79af9f4cdd50a (patch)
tree9f7e4575e8e97e2b23613336a3298feee609788d /sound/mixer.cpp
parent34d1751fe402936455fc8b57b28cb6c3eda11285 (diff)
downloadscummvm-rg350-4343567458cefe5de8f3493040c79af9f4cdd50a.tar.gz
scummvm-rg350-4343567458cefe5de8f3493040c79af9f4cdd50a.tar.bz2
scummvm-rg350-4343567458cefe5de8f3493040c79af9f4cdd50a.zip
changed the way 'streams' are handled: the finalization logic is now in the WrappedAudioInputStream; this allows further streamlining of the channel/mixer code (can you already guess what I am working towards? :-)
svn-id: r11696
Diffstat (limited to 'sound/mixer.cpp')
-rw-r--r--sound/mixer.cpp36
1 files changed, 9 insertions, 27 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index b47c598bad..76c7d19cf0 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -88,13 +88,12 @@ public:
};
class ChannelStream : public Channel {
- bool _finished;
public:
ChannelStream(SoundMixer *mixer, PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan);
- void mix(int16 *data, uint len);
void append(void *sound, uint32 size);
bool isMusicChannel() const { return true; }
- void finish() { _finished = true; }
+
+ void finish();
};
#ifdef USE_MAD
@@ -523,11 +522,11 @@ ChannelRaw::ChannelRaw(SoundMixer *mixer, PlayingSoundHandle *handle, void *soun
_input = makeLinearInputStream(flags, _ptr, size, 0, 0);
}
- // Get a rate converter instance
- _converter = makeRateConverter(rate, mixer->getOutputRate(), _input->isStereo(), (flags & SoundMixer::FLAG_REVERSE_STEREO) != 0);
-
if (!(flags & SoundMixer::FLAG_AUTOFREE))
_ptr = 0;
+
+ // Get a rate converter instance
+ _converter = makeRateConverter(rate, mixer->getOutputRate(), _input->isStereo(), (flags & SoundMixer::FLAG_REVERSE_STEREO) != 0);
}
ChannelRaw::~ChannelRaw() {
@@ -544,37 +543,20 @@ ChannelStream::ChannelStream(SoundMixer *mixer, PlayingSoundHandle *handle,
_input = makeWrappedInputStream(flags, buffer_size);
// Append the initial data
- ((WrappedAudioInputStream *)_input)->append((const byte *)sound, size);
+ append(sound, size);
// Get a rate converter instance
_converter = makeRateConverter(rate, mixer->getOutputRate(), _input->isStereo(), (flags & SoundMixer::FLAG_REVERSE_STEREO) != 0);
+}
- _finished = false;
+void ChannelStream::finish() {
+ ((WrappedAudioInputStream *)_input)->finish();
}
void ChannelStream::append(void *data, uint32 len) {
((WrappedAudioInputStream *)_input)->append((const byte *)data, len);
}
-void ChannelStream::mix(int16 *data, uint len) {
- assert(_input);
- if (_input->eos()) {
- // TODO: call drain method
-
- // Normally, the stream stays around even if all its data is used up.
- // This is in case more data is streamed into it. To make the stream
- // go away, one can either stop() it (which takes effect immediately,
- // ignoring any remaining sound data), or finish() it, which means
- // it will finish playing before it terminates itself.
- if (_finished) {
- destroy();
- }
- } else {
- // Invoke the parent implementation.
- Channel::mix(data, len);
- }
-}
-
#ifdef USE_MAD
ChannelMP3::ChannelMP3(SoundMixer *mixer, PlayingSoundHandle *handle, File *file, uint size, byte volume, int8 pan)
: Channel(mixer, handle, volume, pan), _isMusic(false) {