aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2009-03-06 07:25:06 +0000
committerMax Horn2009-03-06 07:25:06 +0000
commit5e2ee01b39392eecd966624e1d0efc75ee41bc10 (patch)
tree11bc9449bf493223a13d78739bb6702bb56728fc
parent0c681f85a4035d44948e53584cc4d5c8ca324ba9 (diff)
downloadscummvm-rg350-5e2ee01b39392eecd966624e1d0efc75ee41bc10.tar.gz
scummvm-rg350-5e2ee01b39392eecd966624e1d0efc75ee41bc10.tar.bz2
scummvm-rg350-5e2ee01b39392eecd966624e1d0efc75ee41bc10.zip
SCI: Renamed lots of classes related to song iterators; allocate song iterators via new/delete instead of malloc/free
svn-id: r39148
-rw-r--r--engines/sci/engine/ksound.cpp2
-rw-r--r--engines/sci/engine/savegame.cfsml12
-rw-r--r--engines/sci/engine/savegame.cpp10
-rw-r--r--engines/sci/engine/scriptdebug.cpp2
-rw-r--r--engines/sci/sfx/core.cpp12
-rw-r--r--engines/sci/sfx/core.h8
-rw-r--r--engines/sci/sfx/iterator.cpp349
-rw-r--r--engines/sci/sfx/iterator.h80
-rw-r--r--engines/sci/sfx/iterator_internal.h38
-rw-r--r--engines/sci/sfx/player.h8
-rw-r--r--engines/sci/sfx/player/polled.cpp10
-rw-r--r--engines/sci/sfx/player/realtime.cpp10
-rw-r--r--engines/sci/sfx/songlib.cpp2
-rw-r--r--engines/sci/sfx/songlib.h6
-rw-r--r--engines/sci/sfx/test-iterator.cpp32
15 files changed, 292 insertions, 289 deletions
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 5a1b07ed07..fbedf79504 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -109,7 +109,7 @@ static void script_set_priority(EngineState *s, reg_t obj, int priority) {
PUT_SEL32V(obj, flags, flags);
}
-song_iterator_t *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id) {
+SongIterator *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id) {
Resource *song = s->resmgr->findResource(kResourceTypeSound, song_nr, 0);
if (!song)
diff --git a/engines/sci/engine/savegame.cfsml b/engines/sci/engine/savegame.cfsml
index 8e29a4b98f..bd62cd9924 100644
--- a/engines/sci/engine/savegame.cfsml
+++ b/engines/sci/engine/savegame.cfsml
@@ -241,7 +241,7 @@ TYPE IntMapperPtr "IntMapper *" USING write_IntMapperPtr read_IntMapperPtr;
TYPE IntMapperNodePtr "IntMapper::Node *" USING write_IntMapperNodePtr read_IntMapperNodePtr;
TYPE songlib_t "songlib_t" USING write_songlib_t read_songlib_t;
TYPE song_tp "song_t *" USING write_song_tp read_song_tp;
-TYPE song_iterator_t "song_iterator_t" USING write_song_iterator_t read_song_iterator_t;
+TYPE SongIterator "SongIterator" USING write_song_iterator_t read_song_iterator_t;
TYPE song_handle_t "song_handle_t" LIKE int;
TYPE SegManagerPtr "SegManager *" USING write_SegManagerPtr read_SegManagerPtr;
@@ -495,7 +495,7 @@ void write_song_tp(Common::WriteStream *fh, const song_t * const *foo) {
%CFSMLWRITE song_t *foo INTO fh;
}
-song_iterator_t *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id);
+SongIterator *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id);
int read_song_tp(Common::SeekableReadStream *fh, song_t **foo, const char *lastval, int *line, int *hiteof) {
char *token;
@@ -1003,7 +1003,7 @@ void reconstruct_clones(EngineState *s, SegManager *self) {
int _reset_graphics_input(EngineState *s);
-song_iterator_t *new_fast_forward_iterator(song_iterator_t *it, int delta);
+SongIterator *new_fast_forward_iterator(SongIterator *it, int delta);
static void reconstruct_sounds(EngineState *s) {
song_t *seeker;
@@ -1017,13 +1017,13 @@ static void reconstruct_sounds(EngineState *s) {
}
while (seeker) {
- song_iterator_t *base, *ff;
+ SongIterator *base, *ff;
int oldstatus;
- song_iterator_message_t msg;
+ SongIteratorMessage msg;
base = ff = build_iterator(s, seeker->resource_num, it_type, seeker->handle);
if (seeker->restore_behavior == RESTORE_BEHAVIOR_CONTINUE)
- ff = (song_iterator_t *)new_fast_forward_iterator(base, seeker->restore_time);
+ ff = (SongIterator *)new_fast_forward_iterator(base, seeker->restore_time);
ff->init(ff);
msg = songit_make_message(seeker->handle, SIMSG_SET_LOOPS(seeker->loops));
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 8444dc25f0..085655b57f 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -4095,7 +4095,7 @@ void write_song_tp(Common::WriteStream *fh, const song_t * const *foo) {
#line 496 "engines/sci/engine/savegame.cfsml"
}
-song_iterator_t *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id);
+SongIterator *build_iterator(EngineState *s, int song_nr, int type, songit_id_t id);
int read_song_tp(Common::SeekableReadStream *fh, song_t **foo, const char *lastval, int *line, int *hiteof) {
char *token;
@@ -5099,7 +5099,7 @@ void reconstruct_clones(EngineState *s, SegManager *self) {
int _reset_graphics_input(EngineState *s);
-song_iterator_t *new_fast_forward_iterator(song_iterator_t *it, int delta);
+SongIterator *new_fast_forward_iterator(SongIterator *it, int delta);
static void reconstruct_sounds(EngineState *s) {
song_t *seeker;
@@ -5113,13 +5113,13 @@ static void reconstruct_sounds(EngineState *s) {
}
while (seeker) {
- song_iterator_t *base, *ff;
+ SongIterator *base, *ff;
int oldstatus;
- song_iterator_message_t msg;
+ SongIteratorMessage msg;
base = ff = build_iterator(s, seeker->resource_num, it_type, seeker->handle);
if (seeker->restore_behavior == RESTORE_BEHAVIOR_CONTINUE)
- ff = (song_iterator_t *)new_fast_forward_iterator(base, seeker->restore_time);
+ ff = (SongIterator *)new_fast_forward_iterator(base, seeker->restore_time);
ff->init(ff);
msg = songit_make_message(seeker->handle, SIMSG_SET_LOOPS(seeker->loops));
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 965712ab68..e50573fa72 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -2412,7 +2412,7 @@ int c_simkey(EngineState *s) {
static int c_is_sample(EngineState *s) {
Resource *song = s->resmgr->findResource(kResourceTypeSound, cmd_params[0].val, 0);
- song_iterator_t *songit;
+ SongIterator *songit;
Audio::AudioStream *data;
if (!song) {
diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp
index dc70af6231..fb83472af2 100644
--- a/engines/sci/sfx/core.cpp
+++ b/engines/sci/sfx/core.cpp
@@ -244,7 +244,7 @@ static void _update_single_song(sfx_state_t *self) {
_thaw_time(self); /* Recover song delay time */
if (newsong && player) {
- song_iterator_t *clonesong
+ SongIterator *clonesong
= songit_clone(newsong->it, newsong->delay);
player->add_iterator(clonesong, newsong->wakeup_time);
@@ -337,7 +337,7 @@ static void _update(sfx_state_t *self) {
_update_single_song(self);
}
-int sfx_play_iterator_pcm(song_iterator_t *it, song_handle_t handle) {
+int sfx_play_iterator_pcm(SongIterator *it, song_handle_t handle) {
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Playing PCM: %08lx\n", handle);
#endif
@@ -548,7 +548,7 @@ int sfx_poll_specific(sfx_state_t *self, song_handle_t handle, int *cue) {
/* Song basics */
/*****************/
-int sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t handle, int number) {
+int sfx_add_song(sfx_state_t *self, SongIterator *it, int priority, song_handle_t handle, int number) {
song_t *song = song_lib_find(self->songlib, handle);
#ifdef DEBUG_SONG_API
@@ -663,7 +663,7 @@ void sfx_song_renice(sfx_state_t *self, song_handle_t handle, int priority) {
void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) {
song_t *song = song_lib_find(self->songlib, handle);
- song_iterator_message_t msg
+ SongIteratorMessage msg
= songit_make_message(handle, SIMSG_SET_LOOPS(loops));
ASSERT_SONG(song);
@@ -672,7 +672,7 @@ void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) {
handle, loops);
#endif
songit_handle_message(&(song->it), msg);
- song->loops = ((base_song_iterator_t *) song->it)->loops;
+ song->loops = ((BaseSongIterator *) song->it)->loops;
if (player/* && player->send_iterator_message*/)
/* FIXME: The above should be optional! */
@@ -681,7 +681,7 @@ void sfx_song_set_loops(sfx_state_t *self, song_handle_t handle, int loops) {
void sfx_song_set_hold(sfx_state_t *self, song_handle_t handle, int hold) {
song_t *song = song_lib_find(self->songlib, handle);
- song_iterator_message_t msg
+ SongIteratorMessage msg
= songit_make_message(handle, SIMSG_SET_HOLD(hold));
ASSERT_SONG(song);
diff --git a/engines/sci/sfx/core.h b/engines/sci/sfx/core.h
index 569f006968..d839f496bf 100644
--- a/engines/sci/sfx/core.h
+++ b/engines/sci/sfx/core.h
@@ -34,7 +34,7 @@
namespace Sci {
-struct song_iterator_t;
+struct SongIterator;
#define SOUND_TICK 1000 / 60
@@ -51,7 +51,7 @@ struct song_iterator_t;
** song completions */
struct sfx_state_t {
- song_iterator_t *it; /* The song iterator at the heart of things */
+ SongIterator *it; /* The song iterator at the heart of things */
unsigned int flags; /* SFX_STATE_FLAG_* */
songlib_t songlib; /* Song library */
song_t *song; /* Active song, or start of active song chain */
@@ -112,9 +112,9 @@ void sfx_all_stop(sfx_state_t *self);
/* Song basics */
/*****************/
-int sfx_add_song(sfx_state_t *self, song_iterator_t *it, int priority, song_handle_t handle, int resnum);
+int sfx_add_song(sfx_state_t *self, SongIterator *it, int priority, song_handle_t handle, int resnum);
/* Adds a song to the internal sound library
-** Parameters: (song_iterator_t *) it: The iterator describing the song
+** Parameters: (SongIterator *) it: The iterator describing the song
** (int) priority: Initial song priority (higher <-> more important)
** (song_handle_t) handle: The handle to associate with the song
** Returns : (int) 0 on success, nonzero on error
diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp
index 5ced70260e..eb0b5d533d 100644
--- a/engines/sci/sfx/iterator.cpp
+++ b/engines/sci/sfx/iterator.cpp
@@ -64,7 +64,7 @@ static unsigned char *sci_memchr(void *_data, int c, int n) {
return NULL;
}
-static void _common_init(base_song_iterator_t *self) {
+static void _common_init(BaseSongIterator *self) {
self->fade.action = FADE_ACTION_NONE;
self->resetflag = 0;
self->loops = 0;
@@ -116,18 +116,18 @@ static inline int _parse_ticks(byte *data, int *offset_p, int size) {
}
-static int _sci0_read_next_command(sci0_song_iterator_t *self,
+static int _sci0_read_next_command(Sci0SongIterator *self,
unsigned char *buf, int *result);
-static int _sci0_get_pcm_data(sci0_song_iterator_t *self,
+static int _sci0_get_pcm_data(Sci0SongIterator *self,
sfx_pcm_config_t *format, int *xoffset, unsigned int *xsize);
#define PARSE_FLAG_LOOPS_UNLIMITED (1 << 0) /* Unlimited # of loops? */
#define PARSE_FLAG_PARAMETRIC_CUE (1 << 1) /* Assume that cues take an additional "cue value" argument */
/* This implements a difference between SCI0 and SCI1 cues. */
-void _reset_synth_channels(base_song_iterator_t *self, song_iterator_channel_t *channel) {
+void _reset_synth_channels(BaseSongIterator *self, SongIteratorChannel *channel) {
int i;
byte buf[5];
tell_synth_func *tell = sfx_get_player_tell_func();
@@ -144,8 +144,8 @@ void _reset_synth_channels(base_song_iterator_t *self, song_iterator_channel_t *
}
}
-static int _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *buf,
- int *result, song_iterator_channel_t *channel, int flags) {
+static int _parse_sci_midi_command(BaseSongIterator *self, unsigned char *buf,
+ int *result, SongIteratorChannel *channel, int flags) {
unsigned char cmd;
int paramsleft;
int midi_op;
@@ -207,7 +207,7 @@ static int _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *bu
/* Next, check if the channel is allowed */
&& (!((1 << midi_channel) & channel->playmask)))
return /* Execute next command */
- self->next((song_iterator_t *) self, buf, result);
+ self->next((SongIterator *) self, buf, result);
if (cmd == SCI_MIDI_EOT) {
@@ -252,7 +252,7 @@ static int _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *bu
channel->loop_timepos = channel->total_timepos;
return /* Execute next command */
- self->next((song_iterator_t *) self, buf, result);
+ self->next((SongIterator *) self, buf, result);
} else {
/* Used to be conditional <= 127 */
*result = buf[1]; /* Absolute cue */
@@ -282,17 +282,17 @@ static int _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *bu
{
int i;
int voices = 0;
- for (i = 0; i < ((sci1_song_iterator_t *) self)->channels_nr; i++) {
+ for (i = 0; i < ((Sci1SongIterator *) self)->channels_nr; i++) {
voices += self->polyphony[i];
}
sciprintf("SET_POLYPHONY(%d, %d) for a total of %d voices\n", midi_channel, buf[2], voices);
sciprintf("[iterator-1] DEBUG: Polyphony = [ ");
- for (i = 0; i < ((sci1_song_iterator_t *) self)->channels_nr; i++)
+ for (i = 0; i < ((Sci1SongIterator *) self)->channels_nr; i++)
sciprintf("%d ", self->polyphony[i]);
sciprintf("]\n");
sciprintf("[iterator-1] DEBUG: Importance = [ ");
- for (i = 0; i < ((sci1_song_iterator_t *) self)->channels_nr; i++)
+ for (i = 0; i < ((Sci1SongIterator *) self)->channels_nr; i++)
sciprintf("%d ", self->importance[i]);
sciprintf("]\n");
}
@@ -308,7 +308,7 @@ static int _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *bu
case SCI_MIDI_HOLD: {
// Safe cast: This controller is only used in SCI1
- sci1_song_iterator_t *self1 = (sci1_song_iterator_t *) self;
+ Sci1SongIterator *self1 = (Sci1SongIterator *) self;
if (buf[2] == self1->hold) {
channel->offset = channel->initial_offset;
@@ -329,7 +329,7 @@ static int _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *bu
case 0x73: /* UNKNOWN NYI (happens in Hoyle) */
case 0xd1: /* UNKNOWN NYI (happens in KQ4 when riding the unicorn) */
return /* Execute next command */
- self->next((song_iterator_t *) self, buf, result);
+ self->next((SongIterator *) self, buf, result);
case 0x01: /* modulation */
case 0x07: /* volume */
@@ -352,8 +352,8 @@ static int _parse_sci_midi_command(base_song_iterator_t *self, unsigned char *bu
}
}
-static int _sci_midi_process_state(base_song_iterator_t *self, unsigned char *buf, int *result,
- song_iterator_channel_t *channel, int flags) {
+static int _sci_midi_process_state(BaseSongIterator *self, unsigned char *buf, int *result,
+ SongIteratorChannel *channel, int flags) {
CHECK_FOR_END(0);
switch (channel->state) {
@@ -373,7 +373,7 @@ static int _sci_midi_process_state(base_song_iterator_t *self, unsigned char *bu
int offset;
unsigned int size;
int delay;
- if (_sci0_get_pcm_data((sci0_song_iterator_t *) self, &format, &offset, &size))
+ if (_sci0_get_pcm_data((Sci0SongIterator *) self, &format, &offset, &size))
return SI_FINISHED; /* 'tis broken */
channel->state = SI_STATE_FINISHED;
delay = (size * 50 + format.rate - 1) / format.rate; /* number of ticks to completion*/
@@ -384,8 +384,8 @@ static int _sci_midi_process_state(base_song_iterator_t *self, unsigned char *bu
case SI_STATE_UNINITIALISED:
warning(SIPFX "Attempt to read command from uninitialized iterator!");
- self->init((song_iterator_t *) self);
- return self->next((song_iterator_t *) self, buf, result);
+ self->init((SongIterator *) self);
+ return self->next((SongIterator *) self, buf, result);
case SI_STATE_FINISHED:
return SI_FINISHED;
@@ -428,7 +428,7 @@ static int _sci_midi_process_state(base_song_iterator_t *self, unsigned char *bu
#endif
/* If we still have channels left... */
if (self->active_channels) {
- return self->next((song_iterator_t *) self, buf, result);
+ return self->next((SongIterator *) self, buf, result);
}
/* Otherwise, we have reached the end */
@@ -445,15 +445,15 @@ static int _sci_midi_process_state(base_song_iterator_t *self, unsigned char *bu
}
}
-static inline int _sci_midi_process(base_song_iterator_t *self, unsigned char *buf, int *result,
- song_iterator_channel_t *channel, int flags) {
+static inline int _sci_midi_process(BaseSongIterator *self, unsigned char *buf, int *result,
+ SongIteratorChannel *channel, int flags) {
return _sci_midi_process_state(self, buf, result,
channel,
flags);
}
-static int _sci0_read_next_command(sci0_song_iterator_t *self, unsigned char *buf, int *result) {
- return _sci_midi_process((base_song_iterator_t *) self, buf, result,
+static int _sci0_read_next_command(Sci0SongIterator *self, unsigned char *buf, int *result) {
+ return _sci_midi_process((BaseSongIterator *) self, buf, result,
&(self->channel),
PARSE_FLAG_PARAMETRIC_CUE);
}
@@ -469,7 +469,7 @@ static inline int _sci0_header_magic_p(unsigned char *data, int offset, int size
}
-static int _sci0_get_pcm_data(sci0_song_iterator_t *self,
+static int _sci0_get_pcm_data(Sci0SongIterator *self,
sfx_pcm_config_t *format, int *xoffset, unsigned int *xsize) {
int tries = 2;
int found_it = 0;
@@ -556,7 +556,7 @@ static Audio::AudioStream *makeStream(byte *data, int size, sfx_pcm_config_t con
return Audio::makeLinearInputStream(sound, size, conf.rate, flags, 0, 0);
}
-static Audio::AudioStream *_sci0_check_pcm(sci0_song_iterator_t *self) {
+static Audio::AudioStream *_sci0_check_pcm(Sci0SongIterator *self) {
sfx_pcm_config_t conf;
int offset;
unsigned int size;
@@ -568,7 +568,7 @@ static Audio::AudioStream *_sci0_check_pcm(sci0_song_iterator_t *self) {
return makeStream(self->data + offset + SCI0_PCM_DATA_OFFSET, size, conf);
}
-static song_iterator_t *_sci0_handle_message(sci0_song_iterator_t *self, song_iterator_message_t msg) {
+static SongIterator *_sci0_handle_message(Sci0SongIterator *self, SongIteratorMessage msg) {
if (msg.recipient == _SIMSG_BASE) {
switch (msg.type) {
@@ -584,14 +584,14 @@ static song_iterator_t *_sci0_handle_message(sci0_song_iterator_t *self, song_it
break;
case _SIMSG_BASEMSG_CLONE: {
- int tsize = sizeof(sci0_song_iterator_t);
- base_song_iterator_t *mem = (base_song_iterator_t*)sci_malloc(tsize);
- memcpy(mem, self, tsize);
+ // FIXME: Implement cloning for C++ objects properly
+ BaseSongIterator *mem = new Sci0SongIterator();
+ memcpy(mem, self, sizeof(Sci0SongIterator));
sci_refcount_incref(mem->data);
#ifdef DEBUG_VERBOSE
fprintf(stderr, "** CLONE INCREF for new %p from %p at %p\n", mem, self, mem->data);
#endif
- return (song_iterator_t *) mem; /* Assume caller has another copy of this */
+ return (SongIterator *)mem; /* Assume caller has another copy of this */
}
case _SIMSG_BASEMSG_STOP: {
@@ -635,16 +635,16 @@ static song_iterator_t *_sci0_handle_message(sci0_song_iterator_t *self, song_it
return NULL;
}
- return (song_iterator_t *)self;
+ return (SongIterator *)self;
}
return NULL;
}
-static int _sci0_get_timepos(sci0_song_iterator_t *self) {
+static int _sci0_get_timepos(Sci0SongIterator *self) {
return self->channel.total_timepos;
}
-static void _base_init_channel(song_iterator_channel_t *channel, int id, int offset,
+static void _base_init_channel(SongIteratorChannel *channel, int id, int offset,
int end) {
channel->playmask = PLAYMASK_NONE; /* Disable all channels */
channel->id = id;
@@ -664,13 +664,13 @@ static void _base_init_channel(song_iterator_channel_t *channel, int id, int off
channel->saw_notes = 0;
}
-static void _sci0_init(sci0_song_iterator_t *self) {
- _common_init((base_song_iterator_t *) self);
+static void _sci0_init(Sci0SongIterator *self) {
+ _common_init((BaseSongIterator *) self);
self->ccc = 0; /* Reset cumulative cue counter */
self->active_channels = 1;
_base_init_channel(&(self->channel), 0, SCI0_MIDI_OFFSET, self->size);
- _reset_synth_channels((base_song_iterator_t *) self,
+ _reset_synth_channels((BaseSongIterator *) self,
&(self->channel));
self->delay_remaining = 0;
@@ -679,7 +679,7 @@ static void _sci0_init(sci0_song_iterator_t *self) {
}
-static void _sci0_cleanup(sci0_song_iterator_t *self) {
+static void _sci0_cleanup(Sci0SongIterator *self) {
#ifdef DEBUG_VERBOSE
fprintf(stderr, "** FREEING it %p: data at %p\n", self, self->data);
#endif
@@ -709,8 +709,8 @@ static int sci0_to_sci1_device_map[][2] = {
#define SONGDATA(x) self->data[offset + (x)]
#define SCI1_CHANDATA(off) self->data[channel->offset + (off)]
-static int _sci1_sample_init(sci1_song_iterator_t *self, int offset) {
- sci1_sample_t *sample, **seekerp;
+static int _sci1_sample_init(Sci1SongIterator *self, int offset) {
+ Sci1Sample *sample, **seekerp;
int rate;
int length;
int begin;
@@ -728,7 +728,7 @@ static int _sci1_sample_init(sci1_song_iterator_t *self, int offset) {
CHECK_FOR_END_ABSOLUTE((unsigned int)(offset + 10 + length));
- sample = (sci1_sample_t*)sci_malloc(sizeof(sci1_sample_t));
+ sample = new Sci1Sample();
sample->delta = begin;
sample->size = length;
sample->data = self->data + offset + 10;
@@ -756,8 +756,8 @@ static int _sci1_sample_init(sci1_song_iterator_t *self, int offset) {
return 0; /* Everything's fine */
}
-static int _sci1_song_init(sci1_song_iterator_t *self) {
- sci1_sample_t *seeker;
+static int _sci1_song_init(Sci1SongIterator *self) {
+ Sci1Sample *seeker;
int last_time;
unsigned int offset = 0;
self->channels_nr = 0;
@@ -814,7 +814,7 @@ static int _sci1_song_init(sci1_song_iterator_t *self) {
} else {
int channel_nr
= self->data[track_offset] & 0xf;
- song_iterator_channel_t *channel =
+ SongIteratorChannel *channel =
&(self->channels[self->channels_nr++]);
if (self->data[track_offset] & 0xf0)
@@ -826,7 +826,7 @@ static int _sci1_song_init(sci1_song_iterator_t *self) {
/* Skip over header bytes: */
track_offset + 2,
track_offset + end);
- _reset_synth_channels((base_song_iterator_t *) self,
+ _reset_synth_channels((BaseSongIterator *) self,
channel);
self->polyphony[self->channels_nr - 1]
@@ -865,7 +865,7 @@ static int _sci1_song_init(sci1_song_iterator_t *self) {
#undef SONGDATA
-static inline int _sci1_get_smallest_delta(sci1_song_iterator_t *self) {
+static inline int _sci1_get_smallest_delta(Sci1SongIterator *self) {
int i, d = -1;
for (i = 0; i < self->channels_nr; i++)
if (self->channels[i].state == SI_STATE_COMMAND
@@ -878,7 +878,7 @@ static inline int _sci1_get_smallest_delta(sci1_song_iterator_t *self) {
return d;
}
-static inline void _sci1_update_delta(sci1_song_iterator_t *self, int delta) {
+static inline void _sci1_update_delta(Sci1SongIterator *self, int delta) {
int i;
if (self->next_sample)
@@ -889,7 +889,7 @@ static inline void _sci1_update_delta(sci1_song_iterator_t *self, int delta) {
self->channels[i].delay -= delta;
}
-static inline int _sci1_no_delta_time(sci1_song_iterator_t *self) { /* Checks that none of the channels is waiting for its delta to be read */
+static inline int _sci1_no_delta_time(Sci1SongIterator *self) { /* Checks that none of the channels is waiting for its delta to be read */
int i;
for (i = 0; i < self->channels_nr; i++)
@@ -901,7 +901,7 @@ static inline int _sci1_no_delta_time(sci1_song_iterator_t *self) { /* Checks th
#if 0
// Unreferenced - removed
-static void _sci1_dump_state(sci1_song_iterator_t *self) {
+static void _sci1_dump_state(Sci1SongIterator *self) {
int i;
sciprintf("-- [%p] ------------------------\n", self);
@@ -939,7 +939,7 @@ static void _sci1_dump_state(sci1_song_iterator_t *self) {
#define COMMAND_INDEX_NONE -1
#define COMMAND_INDEX_PCM -2
-static inline int _sci1_command_index(sci1_song_iterator_t *self) {
+static inline int _sci1_command_index(Sci1SongIterator *self) {
/* Determine the channel # of the next active event, or -1 */
int i;
int base_delay = 0x7ffffff;
@@ -967,23 +967,23 @@ static inline int _sci1_command_index(sci1_song_iterator_t *self) {
}
-static Audio::AudioStream *_sci1_get_pcm(sci1_song_iterator_t *self) {
+static Audio::AudioStream *_sci1_get_pcm(Sci1SongIterator *self) {
if (self->next_sample
&& self->next_sample->delta <= 0) {
- sci1_sample_t *sample = self->next_sample;
+ Sci1Sample *sample = self->next_sample;
Audio::AudioStream *feed = makeStream(sample->data, sample->size, sample->format);
self->next_sample = self->next_sample->next;
- free(sample);
+ delete sample;
return feed;
} else
return NULL;
}
-static int _sci1_process_next_command(sci1_song_iterator_t *self,
+static int _sci1_process_next_command(Sci1SongIterator *self,
unsigned char *buf, int *result) {
int retval = -42; /* Shouldn't happen, but gcc doesn't agree */
int chan;
@@ -1029,7 +1029,7 @@ static int _sci1_process_next_command(sci1_song_iterator_t *self,
}
} else { /* Not a PCM */
- retval = _sci_midi_process((base_song_iterator_t *) self,
+ retval = _sci_midi_process((BaseSongIterator *) self,
buf, result,
&(self->channels[chan]),
PARSE_FLAG_LOOPS_UNLIMITED);
@@ -1076,8 +1076,8 @@ static int _sci1_process_next_command(sci1_song_iterator_t *self,
return retval;
}
-static song_iterator_t *_sci1_handle_message(sci1_song_iterator_t *self,
- song_iterator_message_t msg) {
+static SongIterator *_sci1_handle_message(Sci1SongIterator *self,
+ SongIteratorMessage msg) {
if (msg.recipient == _SIMSG_BASE) { /* May extend this in the future */
switch (msg.type) {
@@ -1095,12 +1095,12 @@ static song_iterator_t *_sci1_handle_message(sci1_song_iterator_t *self,
break;
case _SIMSG_BASEMSG_CLONE: {
- int tsize = sizeof(sci1_song_iterator_t);
- sci1_song_iterator_t *mem = (sci1_song_iterator_t*)sci_malloc(tsize);
- sci1_sample_t **samplep;
+ // FIXME: Implement cloning for C++ objects properly
+ Sci1SongIterator *mem = new Sci1SongIterator();
+ Sci1Sample **samplep;
int delta = msg.args[0].i; /* Delay until next step */
- memcpy(mem, self, tsize);
+ memcpy(mem, self, sizeof(Sci1SongIterator)); // FIXME
samplep = &(mem->next_sample);
sci_refcount_incref(mem->data);
@@ -1109,15 +1109,13 @@ static song_iterator_t *_sci1_handle_message(sci1_song_iterator_t *self,
/* Clone chain of samples */
while (*samplep) {
- sci1_sample_t *newsample
- = (sci1_sample_t*)sci_malloc(sizeof(sci1_sample_t));
- memcpy(newsample, *samplep,
- sizeof(sci1_sample_t));
+ Sci1Sample *newsample = new Sci1Sample;
+ memcpy(newsample, *samplep, sizeof(Sci1Sample));
*samplep = newsample;
samplep = &(newsample->next);
}
- return (song_iterator_t *) mem; /* Assume caller has another copy of this */
+ return (SongIterator *) mem; /* Assume caller has another copy of this */
}
case _SIMSG_BASEMSG_STOP: {
@@ -1168,7 +1166,7 @@ static song_iterator_t *_sci1_handle_message(sci1_song_iterator_t *self,
self->delay_remaining = 0;
if (toffset > 0)
- return new_fast_forward_iterator((song_iterator_t *) self,
+ return new_fast_forward_iterator((SongIterator *) self,
toffset);
} else {
_sci1_song_init(self);
@@ -1205,17 +1203,17 @@ static song_iterator_t *_sci1_handle_message(sci1_song_iterator_t *self,
default:
warning(SIPFX "Unsupported command %d to SCI1 iterator", msg.type);
}
- return (song_iterator_t *) self;
+ return (SongIterator *) self;
}
return NULL;
}
-static int _sci1_read_next_command(sci1_song_iterator_t *self, unsigned char *buf, int *result) {
+static int _sci1_read_next_command(Sci1SongIterator *self, unsigned char *buf, int *result) {
return _sci1_process_next_command(self, buf, result);
}
-static void _sci1_init(sci1_song_iterator_t *self) {
- _common_init((base_song_iterator_t *) self);
+static void _sci1_init(Sci1SongIterator *self) {
+ _common_init((BaseSongIterator *) self);
self->ccc = 127;
self->device_id = 0x00; /* Default to Sound Blaster/Adlib for purposes
** of cue computation */
@@ -1229,18 +1227,18 @@ static void _sci1_init(sci1_song_iterator_t *self) {
memset(self->importance, 0, sizeof(self->importance));
}
-static void _sci1_cleanup(sci1_song_iterator_t *it) {
- sci1_sample_t *sample_seeker = it->next_sample;
+static void _sci1_cleanup(Sci1SongIterator *it) {
+ Sci1Sample *sample_seeker = it->next_sample;
while (sample_seeker) {
- sci1_sample_t *old_sample = sample_seeker;
+ Sci1Sample *old_sample = sample_seeker;
sample_seeker = sample_seeker->next;
- free(old_sample);
+ delete old_sample;
}
- _sci0_cleanup((sci0_song_iterator_t *)it);
+ _sci0_cleanup((Sci0SongIterator *)it);
}
-static int _sci1_get_timepos(sci1_song_iterator_t *self) {
+static int _sci1_get_timepos(Sci1SongIterator *self) {
int max = 0;
int i;
@@ -1256,10 +1254,10 @@ static int _sci1_get_timepos(sci1_song_iterator_t *self) {
/*****************************/
-static void _cleanup_iterator_init(song_iterator_t *it) {
+static void _cleanup_iterator_init(SongIterator *it) {
}
-static song_iterator_t *_cleanup_iterator_handle_message(song_iterator_t *i, song_iterator_message_t msg) {
+static SongIterator *_cleanup_iterator_handle_message(SongIterator *i, SongIteratorMessage msg) {
if (msg.recipient == _SIMSG_BASEMSG_PRINT
&& msg.type == _SIMSG_BASEMSG_PRINT) {
print_tabs_id(msg.args[0].i, i->ID);
@@ -1269,7 +1267,7 @@ static song_iterator_t *_cleanup_iterator_handle_message(song_iterator_t *i, son
return NULL;
}
-static int _cleanup_iterator_next(song_iterator_t *self, unsigned char *buf, int *result) {
+static int _cleanup_iterator_next(SongIterator *self, unsigned char *buf, int *result) {
/* Task: Return channel-notes-off for each channel */
if (self->channel_mask) {
int bs = sci_ffs(self->channel_mask) - 1;
@@ -1284,19 +1282,25 @@ static int _cleanup_iterator_next(song_iterator_t *self, unsigned char *buf, int
return SI_FINISHED;
}
-song_iterator_t *new_cleanup_iterator(unsigned int channels) {
- song_iterator_t *it = (song_iterator_t*)sci_malloc(sizeof(song_iterator_t));
- it->channel_mask = channels;
- it->ID = 17;
- it->flags = 0;
- it->death_listeners_nr = 0;
+class CleanupSongIterator : public SongIterator {
+public:
+ CleanupSongIterator(unsigned int channels) {
+ channel_mask = channels;
+ ID = 17;
+ flags = 0;
+ death_listeners_nr = 0;
+
+ cleanup = NULL;
+ get_pcm_feed = NULL;
+ init = _cleanup_iterator_init;
+ handle_message = _cleanup_iterator_handle_message;
+ get_timepos = NULL;
+ next = _cleanup_iterator_next;
+ }
+};
- it->cleanup = NULL;
- it->get_pcm_feed = NULL;
- it->init = _cleanup_iterator_init;
- it->handle_message = _cleanup_iterator_handle_message;
- it->get_timepos = NULL;
- it->next = _cleanup_iterator_next;
+SongIterator *new_cleanup_iterator(unsigned int channels) {
+ CleanupSongIterator *it = new CleanupSongIterator(channels);
return it;
}
@@ -1304,7 +1308,7 @@ song_iterator_t *new_cleanup_iterator(unsigned int channels) {
/*-- Fast-forward song iterator --*/
/**********************************/
-static int _ff_read_next_command(fast_forward_song_iterator_t *self,
+static int _ff_read_next_command(FastForwardSongIterator *self,
byte *buf, int *result) {
int rv;
@@ -1328,19 +1332,19 @@ static int _ff_read_next_command(fast_forward_song_iterator_t *self,
}
}
-static Audio::AudioStream *_ff_check_pcm(fast_forward_song_iterator_t *self) {
+static Audio::AudioStream *_ff_check_pcm(FastForwardSongIterator *self) {
return self->delegate->get_pcm_feed(self->delegate);
}
-static song_iterator_t *_ff_handle_message(fast_forward_song_iterator_t *self,
- song_iterator_message_t msg) {
+static SongIterator *_ff_handle_message(FastForwardSongIterator *self,
+ SongIteratorMessage msg) {
if (msg.recipient == _SIMSG_PLASTICWRAP)
switch (msg.type) {
case _SIMSG_PLASTICWRAP_ACK_MORPH:
if (self->delta <= 0) {
- song_iterator_t *it = self->delegate;
- free(self);
+ SongIterator *it = self->delegate;
+ delete self;
return it;
}
break;
@@ -1352,11 +1356,11 @@ static song_iterator_t *_ff_handle_message(fast_forward_song_iterator_t *self,
switch (msg.type) {
case _SIMSG_BASEMSG_CLONE: {
- int tsize = sizeof(fast_forward_song_iterator_t);
- fast_forward_song_iterator_t *clone = (fast_forward_song_iterator_t *)sci_malloc(tsize);
- memcpy(clone, self, tsize);
+ // FIXME: Implement cloning for C++ objects properly
+ FastForwardSongIterator *clone = new FastForwardSongIterator();
+ memcpy(clone, self, sizeof(FastForwardSongIterator));
songit_handle_message(&clone->delegate, msg);
- return (song_iterator_t *) clone;
+ return (SongIterator *) clone;
}
case _SIMSG_BASEMSG_PRINT:
@@ -1376,20 +1380,19 @@ static song_iterator_t *_ff_handle_message(fast_forward_song_iterator_t *self,
}
-static void _ff_init(fast_forward_song_iterator_t *self) {
+static void _ff_init(FastForwardSongIterator *self) {
return;
}
-static int _ff_get_timepos(fast_forward_song_iterator_t *self) {
+static int _ff_get_timepos(FastForwardSongIterator *self) {
return self->delegate->get_timepos(self->delegate);
}
-song_iterator_t *new_fast_forward_iterator(song_iterator_t *capsit, int delta) {
- fast_forward_song_iterator_t *it =
- (fast_forward_song_iterator_t*)sci_malloc(sizeof(fast_forward_song_iterator_t));
+SongIterator *new_fast_forward_iterator(SongIterator *capsit, int delta) {
+ FastForwardSongIterator *it = new FastForwardSongIterator();
if (capsit == NULL) {
- free(it);
+ delete it;
return NULL;
}
it->ID = 0;
@@ -1398,21 +1401,21 @@ song_iterator_t *new_fast_forward_iterator(song_iterator_t *capsit, int delta) {
it->delta = delta;
it->death_listeners_nr = 0;
- it->next = (int(*)(song_iterator_t *, unsigned char *, int *))
+ it->next = (int(*)(SongIterator *, unsigned char *, int *))
_ff_read_next_command;
- it->get_pcm_feed = (Audio::AudioStream * (*)(song_iterator_t *))
+ it->get_pcm_feed = (Audio::AudioStream * (*)(SongIterator *))
_ff_check_pcm;
- it->handle_message = (song_iterator_t * (*)(song_iterator_t *,
- song_iterator_message_t))
+ it->handle_message = (SongIterator * (*)(SongIterator *,
+ SongIteratorMessage))
_ff_handle_message;
- it->get_timepos = (int(*)(song_iterator_t *))_ff_get_timepos;
- it->init = (void(*)(song_iterator_t *))
+ it->get_timepos = (int(*)(SongIterator *))_ff_get_timepos;
+ it->init = (void(*)(SongIterator *))
_ff_init;
it->cleanup = NULL;
it->channel_mask = capsit->channel_mask;
- return (song_iterator_t *) it;
+ return (SongIterator *) it;
}
@@ -1421,7 +1424,7 @@ song_iterator_t *new_fast_forward_iterator(song_iterator_t *capsit, int delta) {
/********************/
-static int _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf,
+static int _tee_read_next_command(TeeSongIterator *it, unsigned char *buf,
int *result) {
static int ready_masks[2] = {TEE_LEFT_READY, TEE_RIGHT_READY};
static int active_masks[2] = {TEE_LEFT_ACTIVE, TEE_RIGHT_ACTIVE};
@@ -1552,7 +1555,7 @@ static int _tee_read_next_command(tee_song_iterator_t *it, unsigned char *buf,
return it->children[retid].retval;
}
-static Audio::AudioStream *_tee_check_pcm(tee_song_iterator_t *it) {
+static Audio::AudioStream *_tee_check_pcm(TeeSongIterator *it) {
static int pcm_masks[2] = {TEE_LEFT_PCM, TEE_RIGHT_PCM};
int i;
@@ -1567,7 +1570,7 @@ static Audio::AudioStream *_tee_check_pcm(tee_song_iterator_t *it) {
return NULL; /* No iterator */
}
-static song_iterator_t *_tee_handle_message(tee_song_iterator_t *self, song_iterator_message_t msg) {
+static SongIterator *_tee_handle_message(TeeSongIterator *self, SongIteratorMessage msg) {
if (msg.recipient == _SIMSG_BASE) {
switch (msg.type) {
@@ -1578,9 +1581,9 @@ static song_iterator_t *_tee_handle_message(tee_song_iterator_t *self, song_iter
break; /* And continue with our children */
case _SIMSG_BASEMSG_CLONE: {
- tee_song_iterator_t *newit
- = (tee_song_iterator_t*)sci_malloc(sizeof(tee_song_iterator_t));
- memcpy(newit, self, sizeof(tee_song_iterator_t));
+ // FIXME: Implement cloning for C++ objects properly
+ TeeSongIterator *newit = new TeeSongIterator();
+ memcpy(newit, self, sizeof(TeeSongIterator));
if (newit->children[TEE_LEFT].it)
newit->children[TEE_LEFT].it =
@@ -1589,7 +1592,7 @@ static song_iterator_t *_tee_handle_message(tee_song_iterator_t *self, song_iter
newit->children[TEE_RIGHT].it =
songit_clone(newit->children[TEE_RIGHT].it, msg.args[0].i);
- return (song_iterator_t *) newit;
+ return (SongIterator *) newit;
}
default:
@@ -1598,29 +1601,29 @@ static song_iterator_t *_tee_handle_message(tee_song_iterator_t *self, song_iter
}
if (msg.recipient == _SIMSG_PLASTICWRAP) {
- song_iterator_t *old_it;
+ SongIterator *old_it;
switch (msg.type) {
case _SIMSG_PLASTICWRAP_ACK_MORPH:
if (!(self->status & (TEE_LEFT_ACTIVE | TEE_RIGHT_ACTIVE))) {
- songit_free((song_iterator_t *) self);
+ songit_free((SongIterator *) self);
return NULL;
} else if (!(self->status & TEE_LEFT_ACTIVE)) {
if (self->may_destroy)
songit_free(self->children[TEE_LEFT].it);
old_it = self->children[TEE_RIGHT].it;
- free(self);
+ delete self;
return old_it;
} else if (!(self->status & TEE_RIGHT_ACTIVE)) {
if (self->may_destroy)
songit_free(self->children[TEE_RIGHT].it);
old_it = self->children[TEE_LEFT].it;
- free(self);
+ delete self;
return old_it;
} else {
sciprintf("[tee-iterator] WARNING:"
" Morphing without need\n");
- return (song_iterator_t *) self;
+ return (SongIterator *) self;
}
default:
@@ -1636,7 +1639,7 @@ static song_iterator_t *_tee_handle_message(tee_song_iterator_t *self, song_iter
return NULL;
}
-static void _tee_init(tee_song_iterator_t *it) {
+static void _tee_init(TeeSongIterator *it) {
it->status = TEE_LEFT_ACTIVE | TEE_RIGHT_ACTIVE;
it->children[TEE_LEFT].it->init(it->children[TEE_LEFT].it);
it->children[TEE_RIGHT].it->init(it->children[TEE_RIGHT].it);
@@ -1644,7 +1647,7 @@ static void _tee_init(tee_song_iterator_t *it) {
#if 0
// Unreferenced - removed
-static void _tee_free(tee_song_iterator_t *it) {
+static void _tee_free(TeeSongIterator *it) {
int i;
for (i = TEE_LEFT; i <= TEE_RIGHT; i++)
if (it->children[i].it && it->may_destroy)
@@ -1652,8 +1655,8 @@ static void _tee_free(tee_song_iterator_t *it) {
}
#endif
-static void songit_tee_death_notification(tee_song_iterator_t *self,
- song_iterator_t *corpse) {
+static void songit_tee_death_notification(TeeSongIterator *self,
+ SongIterator *corpse) {
if (corpse == self->children[TEE_LEFT].it) {
self->status &= ~TEE_LEFT_ACTIVE;
self->children[TEE_LEFT].it = NULL;
@@ -1666,11 +1669,11 @@ static void songit_tee_death_notification(tee_song_iterator_t *self,
}
-song_iterator_t *songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy) {
+SongIterator *songit_new_tee(SongIterator *left, SongIterator *right, int may_destroy) {
int i;
int firstfree = 1; /* First free channel */
int incomplete_map = 0;
- tee_song_iterator_t *it = (tee_song_iterator_t*)sci_malloc(sizeof(tee_song_iterator_t));
+ TeeSongIterator *it = new TeeSongIterator();
it->ID = 0;
@@ -1727,31 +1730,31 @@ song_iterator_t *songit_new_tee(song_iterator_t *left, song_iterator_t *right, i
#endif
- it->next = (int(*)(song_iterator_t *, unsigned char *, int *))
+ it->next = (int(*)(SongIterator *, unsigned char *, int *))
_tee_read_next_command;
- it->get_pcm_feed = (Audio::AudioStream * (*)(song_iterator_t *))
+ it->get_pcm_feed = (Audio::AudioStream * (*)(SongIterator *))
_tee_check_pcm;
- it->handle_message = (song_iterator_t * (*)(song_iterator_t *,
- song_iterator_message_t))
+ it->handle_message = (SongIterator * (*)(SongIterator *,
+ SongIteratorMessage))
_tee_handle_message;
- it->init = (void(*)(song_iterator_t *))
+ it->init = (void(*)(SongIterator *))
_tee_init;
it->get_timepos = NULL;
- song_iterator_add_death_listener((song_iterator_t *)it,
+ song_iterator_add_death_listener((SongIterator *)it,
left, (void (*)(void *, void*))
songit_tee_death_notification);
- song_iterator_add_death_listener((song_iterator_t *)it,
+ song_iterator_add_death_listener((SongIterator *)it,
right, (void (*)(void *, void*))
songit_tee_death_notification);
it->cleanup = NULL;
- return (song_iterator_t *) it;
+ return (SongIterator *) it;
}
@@ -1759,7 +1762,7 @@ song_iterator_t *songit_new_tee(song_iterator_t *left, song_iterator_t *right, i
/*-- General purpose functionality --*/
/*************************************/
-int songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask) {
+int songit_next(SongIterator **it, unsigned char *buf, int *result, int mask) {
int retval;
if (!*it)
@@ -1810,8 +1813,8 @@ int songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask)
return retval;
}
-song_iterator_t *songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id) {
- base_song_iterator_t *it;
+SongIterator *songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id) {
+ BaseSongIterator *it;
int i;
if (!data || size < 22) {
@@ -1824,42 +1827,42 @@ song_iterator_t *songit_new(unsigned char *data, unsigned int size, int type, so
case SCI_SONG_ITERATOR_TYPE_SCI0:
/**-- Playing SCI0 sound resources --**/
- it = (base_song_iterator_t*)sci_malloc(sizeof(sci0_song_iterator_t));
+ it = new Sci0SongIterator();
it->channel_mask = 0xffff; /* Allocate all channels by default */
for (i = 0; i < MIDI_CHANNELS; i++)
it->polyphony[i] = data[1 + (i << 1)];
- it->next = (int(*)(song_iterator_t *, unsigned char *, int *))
+ it->next = (int(*)(SongIterator *, unsigned char *, int *))
_sci0_read_next_command;
- it->get_pcm_feed = (Audio::AudioStream * (*)(song_iterator_t *))
+ it->get_pcm_feed = (Audio::AudioStream * (*)(SongIterator *))
_sci0_check_pcm;
- it->handle_message = (song_iterator_t * (*)(song_iterator_t *, song_iterator_message_t))
+ it->handle_message = (SongIterator * (*)(SongIterator *, SongIteratorMessage))
_sci0_handle_message;
- it->init = (void(*)(song_iterator_t *))_sci0_init;
- it->cleanup = (void(*)(song_iterator_t *))_sci0_cleanup;
- ((sci0_song_iterator_t *)it)->channel.state
+ it->init = (void(*)(SongIterator *))_sci0_init;
+ it->cleanup = (void(*)(SongIterator *))_sci0_cleanup;
+ ((Sci0SongIterator *)it)->channel.state
= SI_STATE_UNINITIALISED;
- it->get_timepos = (int(*)(song_iterator_t *))_sci0_get_timepos;
+ it->get_timepos = (int(*)(SongIterator *))_sci0_get_timepos;
break;
case SCI_SONG_ITERATOR_TYPE_SCI1:
/**-- SCI01 or later sound resource --**/
- it = (base_song_iterator_t*)sci_malloc(sizeof(sci1_song_iterator_t));
+ it = new Sci1SongIterator();
it->channel_mask = 0; /* Defer channel allocation */
for (i = 0; i < MIDI_CHANNELS; i++)
it->polyphony[i] = 0; /* Unknown */
- it->next = (int(*)(song_iterator_t *, unsigned char *, int *))
+ it->next = (int(*)(SongIterator *, unsigned char *, int *))
_sci1_read_next_command;
- it->get_pcm_feed = (Audio::AudioStream * (*)(song_iterator_t *))
+ it->get_pcm_feed = (Audio::AudioStream * (*)(SongIterator *))
_sci1_get_pcm;
- it->handle_message = (song_iterator_t * (*)(song_iterator_t *, song_iterator_message_t))
+ it->handle_message = (SongIterator * (*)(SongIterator *, SongIteratorMessage))
_sci1_handle_message;
- it->init = (void(*)(song_iterator_t *))_sci1_init;
- it->cleanup = (void(*)(song_iterator_t *))_sci1_cleanup;
- it->get_timepos = (int(*)(song_iterator_t *))_sci1_get_timepos;
+ it->init = (void(*)(SongIterator *))_sci1_init;
+ it->cleanup = (void(*)(SongIterator *))_sci1_cleanup;
+ it->get_timepos = (int(*)(SongIterator *))_sci1_get_timepos;
break;
default:
@@ -1875,12 +1878,12 @@ song_iterator_t *songit_new(unsigned char *data, unsigned int size, int type, so
it->data = (unsigned char*)sci_refcount_memdup(data, size);
it->size = size;
- it->init((song_iterator_t *) it);
+ it->init((SongIterator *) it);
- return (song_iterator_t *) it;
+ return (SongIterator *) it;
}
-void songit_free(song_iterator_t *it) {
+void songit_free(SongIterator *it) {
if (it) {
int i;
@@ -1890,12 +1893,12 @@ void songit_free(song_iterator_t *it) {
for (i = 0; i < it->death_listeners_nr; i++)
it->death_listeners[i].notify(it->death_listeners[i].self, it);
- free(it);
+ delete it;
}
}
-song_iterator_message_t songit_make_message(songit_id_t id, int recipient, int type, int a1, int a2) {
- song_iterator_message_t rv;
+SongIteratorMessage songit_make_message(songit_id_t id, int recipient, int type, int a1, int a2) {
+ SongIteratorMessage rv;
rv.ID = id;
rv.recipient = recipient;
rv.type = type;
@@ -1905,8 +1908,8 @@ song_iterator_message_t songit_make_message(songit_id_t id, int recipient, int t
return rv;
}
-song_iterator_message_t songit_make_ptr_message(songit_id_t id, int recipient, int type, void * a1, int a2) {
- song_iterator_message_t rv;
+SongIteratorMessage songit_make_ptr_message(songit_id_t id, int recipient, int type, void * a1, int a2) {
+ SongIteratorMessage rv;
rv.ID = id;
rv.recipient = recipient;
rv.type = type;
@@ -1916,9 +1919,9 @@ song_iterator_message_t songit_make_ptr_message(songit_id_t id, int recipient, i
return rv;
}
-int songit_handle_message(song_iterator_t **it_reg_p, song_iterator_message_t msg) {
- song_iterator_t *it = *it_reg_p;
- song_iterator_t *newit;
+int songit_handle_message(SongIterator **it_reg_p, SongIteratorMessage msg) {
+ SongIterator *it = *it_reg_p;
+ SongIterator *newit;
newit = it->handle_message(it, msg);
@@ -1929,14 +1932,14 @@ int songit_handle_message(song_iterator_t **it_reg_p, song_iterator_message_t ms
return 1;
}
-song_iterator_t *songit_clone(song_iterator_t *it, int delta) {
+SongIterator *songit_clone(SongIterator *it, int delta) {
SIMSG_SEND(it, SIMSG_CLONE(delta));
it->death_listeners_nr = 0;
it->flags |= SONGIT_FLAG_CLONE;
return it;
}
-void song_iterator_add_death_listener(song_iterator_t *it,
+void song_iterator_add_death_listener(SongIterator *it,
void *client, void (*notify)(void *self, void *notifier)) {
if (it->death_listeners_nr >= SONGIT_MAX_LISTENERS) {
error("FATAL: Too many death listeners for song iterator");
@@ -1948,7 +1951,7 @@ void song_iterator_add_death_listener(song_iterator_t *it,
it->death_listeners_nr++;
}
-void song_iterator_remove_death_listener(song_iterator_t *it, void *client) {
+void song_iterator_remove_death_listener(SongIterator *it, void *client) {
int i;
for (i = 0; i < it->death_listeners_nr; i++) {
if (it->death_listeners[i].self == client) {
@@ -1967,7 +1970,7 @@ void song_iterator_remove_death_listener(song_iterator_t *it, void *client) {
}
-song_iterator_t *sfx_iterator_combine(song_iterator_t *it1, song_iterator_t *it2) {
+SongIterator *sfx_iterator_combine(SongIterator *it1, SongIterator *it2) {
if (it1 == NULL)
return it2;
if (it2 == NULL)
diff --git a/engines/sci/sfx/iterator.h b/engines/sci/sfx/iterator.h
index e954f1397c..4818afe37e 100644
--- a/engines/sci/sfx/iterator.h
+++ b/engines/sci/sfx/iterator.h
@@ -100,7 +100,7 @@ struct listener_t {
typedef unsigned long songit_id_t;
-struct song_iterator_message_t {
+struct SongIteratorMessage {
songit_id_t ID;
unsigned int recipient; /* Type of iterator supposed to receive this */
unsigned int type;
@@ -112,7 +112,7 @@ struct song_iterator_message_t {
#define SONGIT_MAX_LISTENERS 2
-struct song_iterator_t {
+struct SongIterator {
songit_id_t ID;
uint16 channel_mask; /* Bitmask of all channels this iterator will use */
@@ -120,10 +120,8 @@ struct song_iterator_t {
unsigned int flags;
int priority;
- int (*next)(song_iterator_t *self,
- unsigned char *buf, int *result);
/* Reads the next MIDI operation _or_ delta time
- ** Parameters: (song_iterator_t *) self
+ ** Parameters: (SongIterator *) self
** (byte *) buf: The buffer to write to (needs to be able to
** store at least 4 bytes)
** Returns : (int) zero if a MIDI operation was written, SI_FINISHED
@@ -138,21 +136,21 @@ struct song_iterator_t {
** If SI_PCM is returned, get_pcm() may be used to retrieve the associated
** PCM, but this must be done before any subsequent calls to next().
*/
+ int (*next)(SongIterator *self,
+ unsigned char *buf, int *result);
- Audio::AudioStream * (*get_pcm_feed)(song_iterator_t *self);
/* Checks for the presence of a pcm sample
- ** Parameters: (song_iterator_t *) self
+ ** Parameters: (SongIterator *) self
** Returns : (Audio::AudioStream *) NULL if no PCM data was found, a
** PCM feed otherwise
*/
+ Audio::AudioStream * (*get_pcm_feed)(SongIterator *self);
- song_iterator_t *
- (* handle_message)(song_iterator_t *self, song_iterator_message_t msg);
/* Handles a message to the song iterator
- ** Parameters: (song_iterator_t *) self
+ ** Parameters: (SongIterator *) self
** (song_iterator_messag_t) msg: The message to handle
- ** Returns : (song_iterator_t *) NULL if the message was not understood,
+ ** Returns : (SongIterator *) NULL if the message was not understood,
** self if the message could be handled, or a new song iterator
** if the current iterator had to be morphed (but the message could
** still be handled)
@@ -161,25 +159,27 @@ struct song_iterator_t {
** takes care of that and makes sure that its delegate received the message (and
** was morphed) before self.
*/
+ SongIterator *
+ (* handle_message)(SongIterator *self, SongIteratorMessage msg);
- void (*init)(song_iterator_t *self);
/* Resets/initializes the sound iterator
- ** Parameters: (song_iterator_t *) self
+ ** Parameters: (SongIterator *) self
** Returns : (void)
*/
+ void (*init)(SongIterator *self);
- void (*cleanup)(song_iterator_t *self);
/* Frees any content of the iterator structure
- ** Parameters: (song_iterator_t *) self
+ ** Parameters: (SongIterator *) self
** Does not physically free(self) yet. May be NULL if nothing needs to be done.
** Must not recurse on its delegate.
*/
+ void (*cleanup)(SongIterator *self);
- int (*get_timepos)(song_iterator_t *self);
/* Gets the song position to store in a savegame
- ** Parameters: (song_iterator_t *) self
+ ** Parameters: (SongIterator *) self
*/
+ int (*get_timepos)(SongIterator *self);
/* Death listeners */
/* These are not reset during initialisation */
@@ -196,10 +196,10 @@ struct song_iterator_t {
** Thus, this flag distinguishes song iterators in the main thread from those
** in the song-player thread. */
-void song_iterator_add_death_listener(song_iterator_t *it,
+void song_iterator_add_death_listener(SongIterator *it,
void *client, void (*notify)(void *self, void *notifier));
/* Adds a death listener to a song iterator
-** Parameters: (song_iterator_t *) it: The iterator to add to
+** Parameters: (SongIterator *) it: The iterator to add to
** (void *) client: The object wanting to be notified
** (void* x void* -> void) notify: The notification function
** to invoke
@@ -208,9 +208,9 @@ void song_iterator_add_death_listener(song_iterator_t *it,
** Death listeners are NOT cloned.
*/
-void song_iterator_remove_death_listener(song_iterator_t *it, void *client);
+void song_iterator_remove_death_listener(SongIterator *it, void *client);
/* Removes a death listener from a song iterator
-** Parameters: (song_iterator_t *) it: The iterator to modify
+** Parameters: (SongIterator *) it: The iterator to modify
** (void *) client: The object no longer wanting to be notified
** Effects: Fatally terminates the program if the listener was not
** found
@@ -240,9 +240,9 @@ void song_iterator_remove_death_listener(song_iterator_t *it, void *client);
| IT_READER_MASK_CUE \
| IT_READER_MASK_PCM )
-int songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask);
+int songit_next(SongIterator **it, unsigned char *buf, int *result, int mask);
/* Convenience wrapper around it->next
-** Parameters: (song_iterator_t **it) Reference to the iterator to access
+** Parameters: (SongIterator **it) Reference to the iterator to access
** (byte *) buf: The buffer to write to (needs to be able to
** store at least 4 bytes)
** (int) mask: IT_READER_MASK options specifying the events to
@@ -258,33 +258,33 @@ int songit_next(song_iterator_t **it, unsigned char *buf, int *result, int mask)
** or the number of loops remaining for SI_LOOP.
*/
-song_iterator_t *songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id);
+SongIterator *songit_new(unsigned char *data, unsigned int size, int type, songit_id_t id);
/* Constructs a new song iterator object
** Parameters: (byte *) data: The song data to iterate over
** (unsigned int) size: Number of bytes in the song
** (int) type: One of the SCI_SONG_ITERATOR_TYPEs
** (songit_id_t) id: An ID for addressing the song iterator
-** Returns : (song_iterator_t *) A newly allocated but uninitialized song
+** Returns : (SongIterator *) A newly allocated but uninitialized song
** iterator, or NULL if 'type' was invalid or unsupported
*/
-song_iterator_t *songit_new_tee(song_iterator_t *left, song_iterator_t *right, int may_destroy);
+SongIterator *songit_new_tee(SongIterator *left, SongIterator *right, int may_destroy);
/* Combines two iterators, returns the next event available from either
-** Parameters: (song_iterator_t *) left: One of the iterators
-** (song_iterator_t *) right: The other iterator
+** Parameters: (SongIterator *) left: One of the iterators
+** (SongIterator *) right: The other iterator
** (int) may_destroy: Whether completed song iterators may be
** destroyed
-** Returns : (song_iterator_t *) A combined iterator, as suggested above
+** Returns : (SongIterator *) A combined iterator, as suggested above
*/
-void songit_free(song_iterator_t *it);
+void songit_free(SongIterator *it);
/* Frees a song iterator and the song it wraps
-** Parameters: (song_iterator_t *) it: The song iterator to free
+** Parameters: (SongIterator *) it: The song iterator to free
** Returns : (void)
*/
-song_iterator_message_t songit_make_message(songit_id_t id,
+SongIteratorMessage songit_make_message(songit_id_t id,
int recipient_class, int type, int a1, int a2);
/* Create a song iterator message
** Parameters: (songit_id_t) id: song ID the message is targetted to
@@ -294,7 +294,7 @@ song_iterator_message_t songit_make_message(songit_id_t id,
** You should only use this with the SIMSG_* macros
*/
-song_iterator_message_t songit_make_ptr_message(songit_id_t id,
+SongIteratorMessage songit_make_ptr_message(songit_id_t id,
int recipient_class, int type, void * a1, int a2);
/* Create a song iterator message, wherein the first parameter is a pointer
** Parameters: (songit_id_t) id: song ID the message is targetted to
@@ -304,29 +304,29 @@ song_iterator_message_t songit_make_ptr_message(songit_id_t id,
** You should only use this with the SIMSG_* macros
*/
-int songit_handle_message(song_iterator_t **it_reg, song_iterator_message_t msg);
+int songit_handle_message(SongIterator **it_reg, SongIteratorMessage msg);
/* Handles a message to the song iterator
-** Parameters: (song_iterator_t **): A reference to the variable storing the song iterator
+** Parameters: (SongIterator **): A reference to the variable storing the song iterator
** Returns : (int) Non-zero if the message was understood
** The song iterator may polymorph as result of msg, so a writeable reference is required.
*/
-song_iterator_t *songit_clone(song_iterator_t *it, int delta);
+SongIterator *songit_clone(SongIterator *it, int delta);
/* Clones a song iterator
-** Parameters: (song_iterator_t *) it: The iterator to clone
+** Parameters: (SongIterator *) it: The iterator to clone
** (int) delta: Number of ticks that still need to elapse until
** the next item should be read from the song iterator
-** Returns : (song_iterator_t *) A shallow clone of 'it'.
+** Returns : (SongIterator *) A shallow clone of 'it'.
** This performs a clone on the bottom-most part (containing the actual song data) _only_.
** The justification for requiring 'delta' to be passed in here is that this
** is typically maintained outside of the song iterator.
*/
-int sfx_play_iterator_pcm(song_iterator_t *it, unsigned long handle);
+int sfx_play_iterator_pcm(SongIterator *it, unsigned long handle);
/* Plays a song iterator that found a PCM through a PCM device, if possible
-** Parameters: (song_iterator_t *) it: The iterator to play
+** Parameters: (SongIterator *) it: The iterator to play
** (song_handle_t) handle: Debug handle
** Returns : (int) 0 if the effect will not be played, nonzero if it will
** This assumes that the last call to 'it->next()' returned SI_PCM.
diff --git a/engines/sci/sfx/iterator_internal.h b/engines/sci/sfx/iterator_internal.h
index 74a881e046..c06f41e113 100644
--- a/engines/sci/sfx/iterator_internal.h
+++ b/engines/sci/sfx/iterator_internal.h
@@ -50,7 +50,7 @@ namespace Sci {
#define SIPFX __FILE__" : "
-struct song_iterator_channel_t {
+struct SongIteratorChannel {
int state; /* SI_STATE_* */
int offset; /* Offset into the data chunk */
int end; /* Last allowed byte in track */
@@ -75,7 +75,7 @@ struct song_iterator_channel_t {
byte last_cmd; /* Last operation executed, for running status */
};
-struct base_song_iterator_t : public song_iterator_t {
+struct BaseSongIterator : public SongIterator {
int polyphony[MIDI_CHANNELS]; /* # of simultaneous notes on each */
int importance[MIDI_CHANNELS]; /* priority rating for each channel, 0 means unrated. */
@@ -95,8 +95,8 @@ struct base_song_iterator_t : public song_iterator_t {
/*--------- SCI 0 --------------*/
/********************************/
-struct sci0_song_iterator_t : public base_song_iterator_t {
- song_iterator_channel_t channel;
+struct Sci0SongIterator : public BaseSongIterator {
+ SongIteratorChannel channel;
int delay_remaining; /* Number of ticks that haven't been polled yet */
};
@@ -106,25 +106,25 @@ struct sci0_song_iterator_t : public base_song_iterator_t {
/********************************/
-struct sci1_sample_t {
+struct Sci1Sample {
int delta; /* Time left-- initially, this is 'Sample point 1'.
** After initialisation, it is 'sample point 1 minus the sample point of the previous sample' */
int size;
int announced; /* Announced for download (SI_PCM) */
sfx_pcm_config_t format;
byte *data;
- sci1_sample_t *next;
+ Sci1Sample *next;
};
-struct sci1_song_iterator_t : public base_song_iterator_t {
- song_iterator_channel_t channels[MIDI_CHANNELS];
+struct Sci1SongIterator : public BaseSongIterator {
+ SongIteratorChannel channels[MIDI_CHANNELS];
/* Invariant: Whenever channels[i].delay == CHANNEL_DELAY_MISSING,
** channel_offset[i] points to a delta time object. */
int initialised; /* Whether the MIDI channel setup has been initialised */
int channels_nr; /* Number of channels actually used */
- sci1_sample_t *next_sample;
+ Sci1Sample *next_sample;
int channels_looped; /* Number of channels that are ready to loop */
int delay_remaining; /* Number of ticks that haven't been polled yet */
@@ -138,15 +138,15 @@ struct sci1_song_iterator_t : public base_song_iterator_t {
/*********************************/
-song_iterator_t *new_cleanup_iterator(unsigned int channels);
+SongIterator *new_cleanup_iterator(unsigned int channels);
/* Creates a new song iterator with the purpose of sending notes-off channel commands
** Parameters: (unsigned int) channels: Channel mask to send these commands for
** Returns : A song iterator with the aforementioned purpose
*/
-int is_cleanup_iterator(song_iterator_t *it);
+int is_cleanup_iterator(SongIterator *it);
/* Determines whether a given song iterator is a cleanup song iterator
-** Parameters: (song_iterator_t *) it: The iterator to check
+** Parameters: (SongIterator *) it: The iterator to check
** Returns : (int) 1 iff 'it' is a cleanup song iterator
** No deep recursion/delegation is considered.
*/
@@ -156,17 +156,17 @@ int is_cleanup_iterator(song_iterator_t *it);
/*--------- Fast Forward ---------*/
/**********************************/
-struct fast_forward_song_iterator_t : public song_iterator_t {
- song_iterator_t *delegate;
+struct FastForwardSongIterator : public SongIterator {
+ SongIterator *delegate;
int delta; /* Remaining time */
};
-song_iterator_t *new_fast_forward_iterator(song_iterator_t *it, int delta);
+SongIterator *new_fast_forward_iterator(SongIterator *it, int delta);
/* Creates a new song iterator which fast-forwards
-** Parameters: (song_iterator_t *) it: The iterator to wrap
+** Parameters: (SongIterator *) it: The iterator to wrap
** (int) delta: The number of ticks to skip
-** Returns : (song_iterator_t) A newly created song iterator
+** Returns : (SongIterator) A newly created song iterator
** which skips all delta times
** until 'delta' has been used up
*/
@@ -189,7 +189,7 @@ song_iterator_t *new_fast_forward_iterator(song_iterator_t *it, int delta);
#define TEE_MORPH_NONE 0 /* Not waiting to self-morph */
#define TEE_MORPH_READY 1 /* Ready to self-morph */
-struct tee_song_iterator_t : public song_iterator_t {
+struct TeeSongIterator : public SongIterator {
int status;
int may_destroy; /* May destroy song iterators */
@@ -197,7 +197,7 @@ struct tee_song_iterator_t : public song_iterator_t {
int morph_deferred; /* One of TEE_MORPH_* above */
struct {
- song_iterator_t *it;
+ SongIterator *it;
byte buf[MAX_BUF_SIZE];
int result;
int retval;
diff --git a/engines/sci/sfx/player.h b/engines/sci/sfx/player.h
index 1d4ed9cd4f..bbb893c91e 100644
--- a/engines/sci/sfx/player.h
+++ b/engines/sci/sfx/player.h
@@ -57,7 +57,7 @@ struct sfx_player_t {
** Returns : (int) SFX_OK on success, SFX_ERROR on failure
*/
- int (*add_iterator)(song_iterator_t *it, uint32 start_time);
+ int (*add_iterator)(SongIterator *it, uint32 start_time);
/* Adds an iterator to the song player
** Parameters: (songx_iterator_t *) it: The iterator to play
** (uint32) start_time: The time to assume as the
@@ -79,9 +79,9 @@ struct sfx_player_t {
** Returns : (int) SFX_OK on success, SFX_ERROR on failure
*/
- int (*iterator_message)(song_iterator_message_t msg);
+ int (*iterator_message)(SongIteratorMessage msg);
/* Transmits a song iterator message to the active song
- ** Parameters: (song_iterator_message_t) msg: The message to transmit
+ ** Parameters: (SongIteratorMessage) msg: The message to transmit
** Returns : (int) SFX_OK on success, SFX_ERROR on failure
** OPTIONAL -- may be NULL
** If this method is not present, sending messages will stop
@@ -141,7 +141,7 @@ void sfx_reset_player();
** Returns: Nothing.
*/
-song_iterator_t *sfx_iterator_combine(song_iterator_t *it1, song_iterator_t *it2);
+SongIterator *sfx_iterator_combine(SongIterator *it1, SongIterator *it2);
/* Combines two song iterators into one
** Parameters: (sfx_iterator_t *) it1: One of the two iterators, or NULL
** (sfx_iterator_t *) it2: The other iterator, or NULL
diff --git a/engines/sci/sfx/player/polled.cpp b/engines/sci/sfx/player/polled.cpp
index 4d01e3fcfb..f11315bfe8 100644
--- a/engines/sci/sfx/player/polled.cpp
+++ b/engines/sci/sfx/player/polled.cpp
@@ -35,7 +35,7 @@
namespace Sci {
-static song_iterator_t *play_it;
+static SongIterator *play_it;
static int play_paused = 0;
static sfx_softseq_t *seq;
static int volume = 100;
@@ -326,8 +326,8 @@ static int pp_init(ResourceManager *resmgr, int expected_latency) {
return SFX_OK;
}
-static int pp_add_iterator(song_iterator_t *it, uint32 start_time) {
- song_iterator_t *old = play_it;
+static int pp_add_iterator(SongIterator *it, uint32 start_time) {
+ SongIterator *old = play_it;
SIMSG_SEND(it, SIMSG_SET_PLAYMASK(seq->playmask));
SIMSG_SEND(it, SIMSG_SET_RHYTHM(seq->play_rhythm));
@@ -357,7 +357,7 @@ static int pp_fade_out() {
}
static int pp_stop() {
- song_iterator_t *it = play_it;
+ SongIterator *it = play_it;
play_it = NULL;
warning("[play] Now stopping it %p", (void *)it);
@@ -369,7 +369,7 @@ static int pp_stop() {
return SFX_OK;
}
-static int pp_send_iterator_message(song_iterator_message_t msg) {
+static int pp_send_iterator_message(SongIteratorMessage msg) {
if (!play_it)
return SFX_ERROR;
diff --git a/engines/sci/sfx/player/realtime.cpp b/engines/sci/sfx/player/realtime.cpp
index 69a8759b80..60968c809f 100644
--- a/engines/sci/sfx/player/realtime.cpp
+++ b/engines/sci/sfx/player/realtime.cpp
@@ -45,7 +45,7 @@ static inline int delta_time(const uint32 comp, const uint32 base) {
return long(comp) - long(base);
}
-static song_iterator_t *play_it = NULL;
+static SongIterator *play_it = NULL;
static uint32 play_last_time;
static uint32 play_pause_started; /* Beginning of the last pause */
static uint32 play_pause_counter; /* Last point in time to mark a
@@ -55,7 +55,7 @@ static int play_it_done = 0;
static int play_writeahead = 0;
static int play_moredelay = 0;
-static void play_song(song_iterator_t *it, uint32 *wakeup_time, int writeahead_time) {
+static void play_song(SongIterator *it, uint32 *wakeup_time, int writeahead_time) {
unsigned char buf[8];
int result;
@@ -188,7 +188,7 @@ static int rt_init(ResourceManager *resmgr, int expected_latency) {
return SFX_OK;
}
-static int rt_add_iterator(song_iterator_t *it, uint32 start_time) {
+static int rt_add_iterator(SongIterator *it, uint32 start_time) {
if (seq->reset_timer) /* Restart timer counting if possible */
seq->reset_timer(start_time);
@@ -209,7 +209,7 @@ static int rt_fade_out(void) {
}
static int rt_stop(void) {
- song_iterator_t *it = play_it;
+ SongIterator *it = play_it;
play_it = NULL;
@@ -221,7 +221,7 @@ static int rt_stop(void) {
return SFX_OK;
}
-static int rt_send_iterator_message(song_iterator_message_t msg) {
+static int rt_send_iterator_message(SongIteratorMessage msg) {
if (!play_it)
return SFX_ERROR;
diff --git a/engines/sci/sfx/songlib.cpp b/engines/sci/sfx/songlib.cpp
index 93dabdffe5..7c424b5d98 100644
--- a/engines/sci/sfx/songlib.cpp
+++ b/engines/sci/sfx/songlib.cpp
@@ -31,7 +31,7 @@ namespace Sci {
#define debug_stream stderr
-song_t *song_new(song_handle_t handle, song_iterator_t *it, int priority) {
+song_t *song_new(song_handle_t handle, SongIterator *it, int priority) {
song_t *retval;
retval = (song_t*) sci_malloc(sizeof(song_t));
diff --git a/engines/sci/sfx/songlib.h b/engines/sci/sfx/songlib.h
index 3011283a72..8ce63c7eb8 100644
--- a/engines/sci/sfx/songlib.h
+++ b/engines/sci/sfx/songlib.h
@@ -62,7 +62,7 @@ struct song_t {
int loops;
int hold;
- song_iterator_t *it;
+ SongIterator *it;
long delay; /* Delay before accessing the iterator, in microseconds */
uint32 wakeup_time; /* Used by the sound core:
@@ -86,10 +86,10 @@ struct songlib_t {
/* Song library commands: */
/**************************/
-song_t *song_new(song_handle_t handle, song_iterator_t *it, int priority);
+song_t *song_new(song_handle_t handle, SongIterator *it, int priority);
/* Initializes a new song
** Parameters: (song_handle_t) handle: The sound handle
-** (song_iterator_t *) it: The song
+** (SongIterator *) it: The song
** (int) priority: The song's priority
** Returns : (song_t *) A freshly allocated song
** Other values are set to predefined defaults.
diff --git a/engines/sci/sfx/test-iterator.cpp b/engines/sci/sfx/test-iterator.cpp
index 32d7f8007f..73af09be6e 100644
--- a/engines/sci/sfx/test-iterator.cpp
+++ b/engines/sci/sfx/test-iterator.cpp
@@ -51,7 +51,7 @@ void error(char *fmt, ...) {
/* The simple iterator will finish after a fixed amount of time. Before that,
** it emits (absolute) cues in ascending order. */
-struct simple_iterator : public song_iterator_t {
+struct simple_iterator : public SongIterator {
int lifetime_remaining;
char *cues;
int cue_counter;
@@ -59,7 +59,7 @@ struct simple_iterator : public song_iterator_t {
int cues_nr;
};
-int simple_it_next(song_iterator_t *_self, unsigned char *buf, int *result) {
+int simple_it_next(SongIterator *_self, unsigned char *buf, int *result) {
simple_iterator *self = (simple_iterator *)_self;
if (self->lifetime_remaining == -1) {
@@ -103,19 +103,19 @@ int simple_it_next(song_iterator_t *_self, unsigned char *buf, int *result) {
}
}
-Audio::AudioStream *simple_it_pcm_feed(song_iterator_t *_self) {
+Audio::AudioStream *simple_it_pcm_feed(SongIterator *_self) {
error("No PCM feed!\n");
return NULL;
}
-void simple_it_init(song_iterator_t *_self) {
+void simple_it_init(SongIterator *_self) {
}
-song_iterator_t *simple_it_handle_message(song_iterator_t *_self, song_iterator_message_t msg) {
+SongIterator *simple_it_handle_message(SongIterator *_self, SongIteratorMessage msg) {
return NULL;
}
-void simple_it_cleanup(song_iterator_t *_self) {
+void simple_it_cleanup(SongIterator *_self) {
}
/* Initialises the simple iterator.
@@ -124,7 +124,7 @@ void simple_it_cleanup(song_iterator_t *_self) {
** (int) cues_nr: Number of cues in ``cues''
** The first cue is emitted after cues[0] ticks, and it is 1. After cues[1] additional ticks
** the next cue is emitted, and so on. */
-song_iterator_t *setup_simple_iterator(int delay, char *cues, int cues_nr) {
+SongIterator *setup_simple_iterator(int delay, char *cues, int cues_nr) {
simple_iterator.lifetime_remaining = delay;
simple_iterator.cues = cues;
simple_iterator.cue_counter = 0;
@@ -144,7 +144,7 @@ song_iterator_t *setup_simple_iterator(int delay, char *cues, int cues_nr) {
simple_iterator.get_pcm_feed = simple_it_pcm_feed;
simple_iterator.next = simple_it_next;
- return (song_iterator_t *) &simple_iterator;
+ return (SongIterator *) &simple_iterator;
}
#define ASSERT_SIT ASSERT(it == simple_it)
@@ -154,8 +154,8 @@ song_iterator_t *setup_simple_iterator(int delay, char *cues, int cues_nr) {
#define ASSERT_CUE(n) ASSERT_NEXT(SI_ABSOLUTE_CUE); ASSERT_RESULT(n)
void test_simple_it() {
- song_iterator_t *it;
- song_iterator_t *simple_it = (song_iterator_t *) & simple_iterator;
+ SongIterator *it;
+ SongIterator *simple_it = (SongIterator *) & simple_iterator;
unsigned char data[4];
int result;
puts("[TEST] simple iterator (test artifact)");
@@ -185,9 +185,9 @@ void test_simple_it() {
}
void test_fastforward() {
- song_iterator_t *it;
- song_iterator_t *simple_it = (song_iterator_t *) & simple_iterator;
- song_iterator_t *ff_it;
+ SongIterator *it;
+ SongIterator *simple_it = (SongIterator *) & simple_iterator;
+ SongIterator *ff_it;
unsigned char data[4];
int result;
puts("[TEST] fast-forward iterator");
@@ -288,7 +288,7 @@ static unsigned char simple_song[SIMPLE_SONG_SIZE] = {
ASSERT(data[2] == arg1);
void test_iterator_sci0() {
- song_iterator_t *it = songit_new(simple_song, SIMPLE_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
+ SongIterator *it = songit_new(simple_song, SIMPLE_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
unsigned char data[4];
int result;
SIMSG_SEND(it, SIMSG_SET_PLAYMASK(0x0001)); /* Initialise song, enabling channel 0 */
@@ -312,7 +312,7 @@ void test_iterator_sci0() {
void test_iterator_sci0_loop() {
- song_iterator_t *it = songit_new(simple_song, SIMPLE_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
+ SongIterator *it = songit_new(simple_song, SIMPLE_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
unsigned char data[4];
int result;
SIMSG_SEND(it, SIMSG_SET_PLAYMASK(0x0001)); /* Initialise song, enabling channel 0 */
@@ -368,7 +368,7 @@ unsigned char loop_song[LOOP_SONG_SIZE] = {
void test_iterator_sci0_mark_loop() {
- song_iterator_t *it = songit_new(loop_song, LOOP_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
+ SongIterator *it = songit_new(loop_song, LOOP_SONG_SIZE, SCI_SONG_ITERATOR_TYPE_SCI0, 0l);
unsigned char data[4];
int result;
SIMSG_SEND(it, SIMSG_SET_PLAYMASK(0x0001)); /* Initialise song, enabling channel 0 */