diff options
author | Max Horn | 2003-06-21 21:17:08 +0000 |
---|---|---|
committer | Max Horn | 2003-06-21 21:17:08 +0000 |
commit | 7c332d7fdb8ae0356ab21368c4903aea4b9b8640 (patch) | |
tree | 2276c452371b804477d3d2083e4d9d80accfca47 /sound | |
parent | 1733bafbda15665dad525eb1d0be8ae4a71efd21 (diff) | |
download | scummvm-rg350-7c332d7fdb8ae0356ab21368c4903aea4b9b8640.tar.gz scummvm-rg350-7c332d7fdb8ae0356ab21368c4903aea4b9b8640.tar.bz2 scummvm-rg350-7c332d7fdb8ae0356ab21368c4903aea4b9b8640.zip |
modified & cleaned up the playStream/append code a bit; but this API really could stand some refinement
svn-id: r8592
Diffstat (limited to 'sound')
-rw-r--r-- | sound/mixer.cpp | 20 | ||||
-rw-r--r-- | sound/mixer.h | 6 |
2 files changed, 7 insertions, 19 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index 27cdd7bca1..fffb623257 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -157,18 +157,14 @@ void SoundMixer::unInsert(Channel *chan) { error("SoundMixer::channel_deleted chan not found"); } -int SoundMixer::append(int index, void *sound, uint32 size, uint rate, byte flags) { +int SoundMixer::append(int index, void *sound, uint32 size) { _syst->lock_mutex(_mutex); Channel *chan = _channels[index]; if (!chan) { - debug(2, "Trying to stream to an unexistant streamer : %d", index); - playStream(NULL, index, sound, size, rate, flags); - chan = _channels[index]; + error("Trying to stream to a nonexistant streamer : %d", index); } else { - chan->append(sound, size); - if (flags & FLAG_AUTOFREE) - free(sound); + dynamic_cast<ChannelStream *>(chan)->append(sound, size); } _syst->unlock_mutex(_mutex); @@ -205,9 +201,9 @@ int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, ui return -1; } -int SoundMixer::playStream(PlayingSoundHandle *handle, int idx, void *sound, uint32 size, +int SoundMixer::playStream(int idx, void *sound, uint32 size, uint rate, byte flags, int32 timeout, int32 buffer_size) { - return insertAt(handle, idx, new ChannelStream(this, sound, size, rate, flags, timeout, buffer_size)); + return insertAt(NULL, idx, new ChannelStream(this, sound, size, rate, flags, timeout, buffer_size)); } void SoundMixer::beginSlots(int index) { @@ -648,10 +644,6 @@ bool Channel::soundFinished() { return false; } -void Channel::append(void *sound, uint32 size) { - error("append method should never be called on something else than a _STREAM mixer "); -} - /* RAW mixer */ ChannelRaw::ChannelRaw(SoundMixer *mixer, void *sound, uint32 size, uint rate, byte flags, int id) { _id = id; @@ -734,8 +726,6 @@ ChannelStream::ChannelStream(SoundMixer *mixer, void *sound, uint32 size, uint r memcpy(_ptr, sound, size); _endOfData = _ptr + size; _endOfBuffer = _ptr + _bufferSize; - if (_flags & SoundMixer::FLAG_AUTOFREE) - free(sound); _pos = _ptr; _fpPos = 0; _fpSpeed = (1 << 16) * rate / mixer->_outputRate; diff --git a/sound/mixer.h b/sound/mixer.h index cb5a4f220c..1abfcc4935 100644 --- a/sound/mixer.h +++ b/sound/mixer.h @@ -54,7 +54,6 @@ public: _toBeDestroyed = true; } virtual void realDestroy() = 0; - virtual void append(void *sound, uint32 size); virtual bool soundFinished(); }; @@ -94,7 +93,6 @@ public: ~SoundMixer(); int insertAt(PlayingSoundHandle *handle, int index, Channel *chan); - void append(void *data, uint32 len); void unInsert(Channel *chan); void beginSlots(int index); @@ -109,7 +107,7 @@ public: FLAG_LOOP = 1 << 5 // loop the audio }; int playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id = -1); - int playStream(PlayingSoundHandle *handle, int index, void *sound, uint32 size, uint rate, + int playStream(int index, void *sound, uint32 size, uint rate, byte flags, int32 timeout = 3, int32 buffer_size = 2000000); #ifdef USE_MAD int playMP3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags); @@ -135,7 +133,7 @@ public: void stopID(int id); /** append to existing sound */ - int append(int index, void * sound, uint32 size, uint rate, byte flags); + int append(int index, void * sound, uint32 size); /** is any channel active? */ bool hasActiveChannel(); |