aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sound/mixer.cpp17
-rw-r--r--sound/mixer.h3
2 files changed, 18 insertions, 2 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index e176e93431..9222198c6f 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -293,6 +293,11 @@ SoundMixer::ChannelRaw::ChannelRaw(SoundMixer * mixer, void * sound, uint32 size
_size = _size >> 1;
if (_flags & FLAG_STEREO)
_size = _size >> 1;
+
+ if (flags & FLAG_LOOP) {
+ _loop_ptr = sound;
+ _loop_size = size;
+ }
}
@@ -623,8 +628,16 @@ void SoundMixer::ChannelRaw::mix(int16 * data, uint len) {
free(s_org);
}
- if (_size < 1)
- realDestroy();
+ if (_size < 1) {
+ if (_flags & FLAG_LOOP) {
+ _ptr = _loop_ptr;
+ _size = _loop_size;
+ _pos = 0;
+ _fpPos = 0;
+ } else {
+ realDestroy();
+ }
+ }
}
diff --git a/sound/mixer.h b/sound/mixer.h
index 14897b5834..599ce2e21f 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -64,6 +64,8 @@ private:
uint32 _fpPos;
uint32 _realSize, _rate;
byte _flags;
+ void *_loop_ptr;
+ uint32 _loop_size;
public:
ChannelRaw(SoundMixer * mixer, void * sound, uint32 size, uint rate, byte flags, int id);
@@ -200,6 +202,7 @@ public:
FLAG_AUTOFREE = 8, /* sound buffer is freed automagically at the end of playing */
FLAG_FILE = 16, /* sound is a FILE * that's read from */
FLAG_REVERSE_STEREO = 32, /* sound should be reverse stereo */
+ FLAG_LOOP = 64, /* loop the audio */
};
int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags);
int playRaw(PlayingSoundHandle * handle, void * sound, uint32 size, uint rate, byte flags, int id);