aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoost Peters2003-10-24 23:09:01 +0000
committerJoost Peters2003-10-24 23:09:01 +0000
commit3ad14b06f507d056da5c8e1506d95e607029f75e (patch)
tree3c96bd8a3e8555b522a85df4d327f3837ebaa410
parent87e1963cffd79cbd5aed472f58a91a9ae973c13d (diff)
downloadscummvm-rg350-3ad14b06f507d056da5c8e1506d95e607029f75e.tar.gz
scummvm-rg350-3ad14b06f507d056da5c8e1506d95e607029f75e.tar.bz2
scummvm-rg350-3ad14b06f507d056da5c8e1506d95e607029f75e.zip
added extra flag to mixer so we don't use free() on new'd pointers
svn-id: r10958
-rw-r--r--queen/sound.cpp2
-rw-r--r--sound/mixer.cpp7
-rw-r--r--sound/mixer.h4
3 files changed, 10 insertions, 3 deletions
diff --git a/queen/sound.cpp b/queen/sound.cpp
index 15a831b89e..50768ed804 100644
--- a/queen/sound.cpp
+++ b/queen/sound.cpp
@@ -62,7 +62,7 @@ bool Sound::isPlaying() {
}
int SBSound::playSound(byte *sound, uint32 size) {
- byte flags = 0 | SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE;
+ byte flags = 0 | SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTODELETE;
return _mixer->playRaw(&_sfxHandle, sound, size, 11025, flags);
}
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index a46ad18db7..21439a648e 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -44,6 +44,7 @@ protected:
RateConverter *_converter;
AudioInputStream *_input;
byte _volume;
+ byte _flags;
int8 _pan;
bool _paused;
@@ -510,6 +511,7 @@ ChannelRaw::ChannelRaw(SoundMixer *mixer, PlayingSoundHandle *handle, void *soun
: Channel(mixer, handle) {
_id = id;
_ptr = (byte *)sound;
+ _flags = flags;
_volume = volume;
_pan = pan;
@@ -533,7 +535,10 @@ ChannelRaw::ChannelRaw(SoundMixer *mixer, PlayingSoundHandle *handle, void *soun
}
ChannelRaw::~ChannelRaw() {
- free(_ptr);
+ if (_flags & SoundMixer::FLAG_AUTOFREE)
+ free(_ptr);
+ else if (_flags & SoundMixer::FLAG_AUTODELETE)
+ delete _ptr;
}
ChannelStream::ChannelStream(SoundMixer *mixer, PlayingSoundHandle *handle,
diff --git a/sound/mixer.h b/sound/mixer.h
index 03e8b46385..12b51b705c 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -55,7 +55,9 @@ public:
FLAG_16BITS = 1 << 2, // sound is 16 bits wide (default: 8bit)
FLAG_AUTOFREE = 1 << 3, // sound buffer is freed automagically at the end of playing
FLAG_REVERSE_STEREO = 1 << 4, // reverse the left and right stereo channel
- FLAG_LOOP = 1 << 5 // loop the audio
+ FLAG_LOOP = 1 << 5, // loop the audio
+ FLAG_AUTODELETE = 1 << 6 // same as AUTOFREE, but uses delete instead of free()
+
};
private: