aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorOliver Kiehl2002-11-10 16:23:02 +0000
committerOliver Kiehl2002-11-10 16:23:02 +0000
commitfb8f8c6105893ccc2e4fa2cc39deaadb561ccfe5 (patch)
treea0a20577fa586078429606b6b49b00d4b3d7593c /sound
parent0eb3a9017dc5381fa06ec3dd5284d0f46dd240cf (diff)
downloadscummvm-rg350-fb8f8c6105893ccc2e4fa2cc39deaadb561ccfe5.tar.gz
scummvm-rg350-fb8f8c6105893ccc2e4fa2cc39deaadb561ccfe5.tar.bz2
scummvm-rg350-fb8f8c6105893ccc2e4fa2cc39deaadb561ccfe5.zip
added looping support to playRaw
svn-id: r5501
Diffstat (limited to 'sound')
-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);