diff options
Diffstat (limited to 'sound')
-rw-r--r-- | sound/mixer.cpp | 7 | ||||
-rw-r--r-- | sound/mixer.h | 4 |
2 files changed, 9 insertions, 2 deletions
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: |