aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sfx
diff options
context:
space:
mode:
authorMax Horn2009-06-07 17:06:32 +0000
committerMax Horn2009-06-07 17:06:32 +0000
commitf2ca788004a86d7f1eb1a8ec27c26b552906fce4 (patch)
tree614ced3ef5eed8bb8b5988dd63ebd320bcfed95a /engines/sci/sfx
parent42555118bac45df0a14d2928b89ef44c3a606cd2 (diff)
downloadscummvm-rg350-f2ca788004a86d7f1eb1a8ec27c26b552906fce4.tar.gz
scummvm-rg350-f2ca788004a86d7f1eb1a8ec27c26b552906fce4.tar.bz2
scummvm-rg350-f2ca788004a86d7f1eb1a8ec27c26b552906fce4.zip
SCI: Renamed various song/songlib related structs and members
svn-id: r41342
Diffstat (limited to 'engines/sci/sfx')
-rw-r--r--engines/sci/sfx/core.cpp181
-rw-r--r--engines/sci/sfx/core.h46
-rw-r--r--engines/sci/sfx/iterator.h17
-rw-r--r--engines/sci/sfx/songlib.cpp136
-rw-r--r--engines/sci/sfx/songlib.h115
5 files changed, 251 insertions, 244 deletions
diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp
index 7e3395b7d3..5b3f7b1caf 100644
--- a/engines/sci/sfx/core.cpp
+++ b/engines/sci/sfx/core.cpp
@@ -47,6 +47,15 @@ class SfxPlayer;
SfxPlayer *player = NULL; // FIXME: Avoid non-const global vars
+/* Plays a song iterator that found a PCM through a PCM device, if possible
+** Parameters: (SongIterator *) it: The iterator to play
+** (SongHandle) 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.
+*/
+static int sfx_play_iterator_pcm(SongIterator *it, SongHandle handle);
+
+
#pragma mark -
@@ -351,39 +360,39 @@ SfxState::~SfxState() {
void SfxState::freezeTime() {
/* Freezes the top song delay time */
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
- song_t *song = _song;
+ Song *song = _song;
while (song) {
song->_delay = song->_wakeupTime.frameDiff(ctime);
if (song->_delay < 0)
song->_delay = 0;
- song = song->next_playing;
+ song = song->_nextPlaying;
}
}
void SfxState::thawTime() {
/* inverse of freezeTime() */
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
- song_t *song = _song;
+ Song *song = _song;
while (song) {
song->_wakeupTime = ctime.addFrames(song->_delay);
- song = song->next_playing;
+ song = song->_nextPlaying;
}
}
#if 0
// Unreferenced - removed
static void _dump_playing_list(SfxState *self, char *msg) {
- song_t *song = self->_song;
+ Song *song = self->_song;
fprintf(stderr, "[] Song list : [ ");
song = *(self->_songlib.lib);
while (song) {
- fprintf(stderr, "%08lx:%d ", song->handle, song->status);
- song = song->next_playing;
+ fprintf(stderr, "%08lx:%d ", song->handle, song->_status);
+ song = song->_nextPlaying;
}
fprintf(stderr, "]\n");
@@ -391,7 +400,7 @@ static void _dump_playing_list(SfxState *self, char *msg) {
while (song) {
fprintf(stderr, "%08lx ", song->handle);
- song = song->next_playing;
+ song = song->_nextPlaying;
}
fprintf(stderr, "]\n");
@@ -400,15 +409,15 @@ static void _dump_playing_list(SfxState *self, char *msg) {
#if 0
static void _dump_songs(SfxState *self) {
- song_t *song = self->_song;
+ Song *song = self->_song;
fprintf(stderr, "Cue iterators:\n");
song = *(self->_songlib.lib);
while (song) {
fprintf(stderr, " **\tHandle %08x (p%d): status %d\n",
- song->handle, song->priority, song->status);
- SIMSG_SEND(song->it, SIMSG_PRINT(1));
- song = song->next;
+ song->handle, song->_priority, song->_status);
+ SIMSG_SEND(song->_it, SIMSG_PRINT(1));
+ song = song->_next;
}
if (player) {
@@ -418,32 +427,32 @@ static void _dump_songs(SfxState *self) {
}
#endif
-bool SfxState::isPlaying(song_t *song) {
- song_t *playing_song = _song;
+bool SfxState::isPlaying(Song *song) {
+ Song *playing_song = _song;
/* _dump_playing_list(this, "is-playing");*/
while (playing_song) {
if (playing_song == song)
return true;
- playing_song = playing_song->next_playing;
+ playing_song = playing_song->_nextPlaying;
}
return false;
}
-void SfxState::setSongStatus(song_t *song, int status) {
+void SfxState::setSongStatus(Song *song, int status) {
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
switch (status) {
case SOUND_STATUS_STOPPED:
// Reset
- song->it->init();
+ song->_it->init();
break;
case SOUND_STATUS_SUSPENDED:
case SOUND_STATUS_WAITING:
- if (song->status == SOUND_STATUS_PLAYING) {
+ if (song->_status == SOUND_STATUS_PLAYING) {
// Update delay, set wakeup_time
song->_delay += song->_wakeupTime.frameDiff(ctime);
song->_wakeupTime = ctime;
@@ -454,7 +463,7 @@ void SfxState::setSongStatus(song_t *song, int status) {
/* otherwise... */
case SOUND_STATUS_PLAYING:
- if (song->status == SOUND_STATUS_STOPPED) {
+ if (song->_status == SOUND_STATUS_STOPPED) {
// Starting anew
song->_wakeupTime = ctime;
}
@@ -471,12 +480,12 @@ void SfxState::setSongStatus(song_t *song, int status) {
return;
}
- song->status = status;
+ song->_status = status;
}
/* Update internal state iff only one song may be played */
void SfxState::updateSingleSong() {
- song_t *newsong = song_lib_find_active(_songlib);
+ Song *newsong = song_lib_find_active(_songlib);
if (newsong != _song) {
freezeTime(); /* Store song delay time */
@@ -485,11 +494,11 @@ void SfxState::updateSingleSong() {
player->stop();
if (newsong) {
- if (!newsong->it)
+ if (!newsong->_it)
return; /* Restore in progress and not ready for this yet */
/* Change song */
- if (newsong->status == SOUND_STATUS_WAITING)
+ if (newsong->_status == SOUND_STATUS_WAITING)
setSongStatus(newsong, SOUND_STATUS_PLAYING);
/* Change instrument mappings */
@@ -497,7 +506,7 @@ void SfxState::updateSingleSong() {
/* Turn off sound */
}
if (_song) {
- if (_song->status == SOUND_STATUS_PLAYING)
+ if (_song->_status == SOUND_STATUS_PLAYING)
setSongStatus(newsong, SOUND_STATUS_WAITING);
}
@@ -506,13 +515,13 @@ void SfxState::updateSingleSong() {
debugMessage += " New song:";
} else {
char tmp[50];
- sprintf(tmp, " pausing %08lx, now playing ", _song->handle);
+ sprintf(tmp, " pausing %08lx, now playing ", _song->_handle);
debugMessage += tmp;
}
if (newsong) {
char tmp[20];
- sprintf(tmp, "%08lx\n", newsong->handle);
+ sprintf(tmp, "%08lx\n", newsong->_handle);
debugMessage += tmp;
} else {
debugMessage += " none\n";
@@ -524,7 +533,7 @@ void SfxState::updateSingleSong() {
thawTime(); /* Recover song delay time */
if (newsong && player) {
- SongIterator *clonesong = newsong->it->clone(newsong->_delay);
+ SongIterator *clonesong = newsong->_it->clone(newsong->_delay);
player->add_iterator(clonesong, newsong->_wakeupTime.msecs());
}
@@ -533,11 +542,11 @@ void SfxState::updateSingleSong() {
void SfxState::updateMultiSong() {
- song_t *oldfirst = _song;
- song_t *oldseeker;
- song_t *newsong = song_lib_find_active(_songlib);
- song_t *newseeker;
- song_t not_playing_anymore; /* Dummy object, referenced by
+ Song *oldfirst = _song;
+ Song *oldseeker;
+ Song *newsong = song_lib_find_active(_songlib);
+ Song *newseeker;
+ Song not_playing_anymore; /* Dummy object, referenced by
** songs which are no longer
** active. */
@@ -548,30 +557,30 @@ void SfxState::updateMultiSong() {
return;
for (newseeker = newsong; newseeker;
- newseeker = newseeker->next_playing) {
- if (!newseeker || !newseeker->it)
+ newseeker = newseeker->_nextPlaying) {
+ if (!newseeker || !newseeker->_it)
return; /* Restore in progress and not ready for this yet */
}
/* First, put all old songs into the 'stopping' list and
** mark their 'next-playing' as not_playing_anymore. */
for (oldseeker = oldfirst; oldseeker;
- oldseeker = oldseeker->next_stopping) {
- oldseeker->next_stopping = oldseeker->next_playing;
- oldseeker->next_playing = &not_playing_anymore;
+ oldseeker = oldseeker->_nextStopping) {
+ oldseeker->_nextStopping = oldseeker->_nextPlaying;
+ oldseeker->_nextPlaying = &not_playing_anymore;
- if (oldseeker == oldseeker->next_playing) {
+ if (oldseeker == oldseeker->_nextPlaying) {
error("updateMultiSong() failed. Breakpoint in %s, line %d", __FILE__, __LINE__);
}
}
/* Second, re-generate the new song queue. */
for (newseeker = newsong; newseeker;
- newseeker = newseeker->next_playing) {
- newseeker->next_playing
+ newseeker = newseeker->_nextPlaying) {
+ newseeker->_nextPlaying
= song_lib_find_next_active(_songlib, newseeker);
- if (newseeker == newseeker->next_playing) {
+ if (newseeker == newseeker->_nextPlaying) {
error("updateMultiSong() failed. Breakpoint in %s, line %d", __FILE__, __LINE__);
}
}
@@ -582,21 +591,21 @@ void SfxState::updateMultiSong() {
/* Third, stop all old songs */
for (oldseeker = oldfirst; oldseeker;
- oldseeker = oldseeker->next_stopping)
- if (oldseeker->next_playing == &not_playing_anymore) {
+ oldseeker = oldseeker->_nextStopping)
+ if (oldseeker->_nextPlaying == &not_playing_anymore) {
setSongStatus(oldseeker, SOUND_STATUS_SUSPENDED);
- debugC(2, kDebugLevelSound, "[SFX] Stopping song %lx\n", oldseeker->handle);
+ debugC(2, kDebugLevelSound, "[SFX] Stopping song %lx\n", oldseeker->_handle);
- if (player && oldseeker->it)
- player->iterator_message(SongIterator::Message(oldseeker->it->ID, SIMSG_STOP));
- oldseeker->next_playing = NULL; /* Clear this pointer; we don't need the tag anymore */
+ if (player && oldseeker->_it)
+ player->iterator_message(SongIterator::Message(oldseeker->_it->ID, SIMSG_STOP));
+ oldseeker->_nextPlaying = NULL; /* Clear this pointer; we don't need the tag anymore */
}
- for (newseeker = newsong; newseeker; newseeker = newseeker->next_playing) {
- if (newseeker->status != SOUND_STATUS_PLAYING && player) {
- debugC(2, kDebugLevelSound, "[SFX] Adding song %lx\n", newseeker->it->ID);
+ for (newseeker = newsong; newseeker; newseeker = newseeker->_nextPlaying) {
+ if (newseeker->_status != SOUND_STATUS_PLAYING && player) {
+ debugC(2, kDebugLevelSound, "[SFX] Adding song %lx\n", newseeker->_it->ID);
- SongIterator *clonesong = newseeker->it->clone(newseeker->_delay);
+ SongIterator *clonesong = newseeker->_it->clone(newseeker->_delay);
player->add_iterator(clonesong, g_system->getMillis());
}
setSongStatus(newseeker, SOUND_STATUS_PLAYING);
@@ -615,7 +624,7 @@ void SfxState::update() {
updateSingleSong();
}
-int sfx_play_iterator_pcm(SongIterator *it, song_handle_t handle) {
+static int sfx_play_iterator_pcm(SongIterator *it, SongHandle handle) {
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Playing PCM: %08lx\n", handle);
#endif
@@ -716,11 +725,11 @@ void SfxState::sfx_suspend(bool suspend) {
_suspended = suspend;
}
-int SfxState::sfx_poll(song_handle_t *handle, int *cue) {
+int SfxState::sfx_poll(SongHandle *handle, int *cue) {
if (!_song)
return 0; /* No milk today */
- *handle = _song->handle;
+ *handle = _song->_handle;
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Polling any (%08lx)\n", *handle);
@@ -728,12 +737,12 @@ int SfxState::sfx_poll(song_handle_t *handle, int *cue) {
return sfx_poll_specific(*handle, cue);
}
-int SfxState::sfx_poll_specific(song_handle_t handle, int *cue) {
+int SfxState::sfx_poll_specific(SongHandle handle, int *cue) {
const Audio::Timestamp ctime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
- song_t *song = _song;
+ Song *song = _song;
- while (song && song->handle != handle)
- song = song->next_playing;
+ while (song && song->_handle != handle)
+ song = song->_nextPlaying;
if (!song)
return 0; /* Song not playing */
@@ -745,7 +754,7 @@ int SfxState::sfx_poll_specific(song_handle_t handle, int *cue) {
return 0; /* Patience, young hacker! */
byte buf[8];
- int result = songit_next(&(song->it), buf, cue, IT_READER_MASK_ALL);
+ int result = songit_next(&(song->_it), buf, cue, IT_READER_MASK_ALL);
switch (result) {
@@ -783,8 +792,8 @@ int SfxState::sfx_poll_specific(song_handle_t handle, int *cue) {
/* Song basics */
/*****************/
-void SfxState::sfx_add_song(SongIterator *it, int priority, song_handle_t handle, int number) {
- song_t *song = song_lib_find(_songlib, handle);
+void SfxState::sfx_add_song(SongIterator *it, int priority, SongHandle handle, int number) {
+ Song *song = song_lib_find(_songlib, handle);
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Adding song: %08lx at %d, it=%p\n", handle, priority, it);
@@ -807,10 +816,10 @@ void SfxState::sfx_add_song(SongIterator *it, int priority, song_handle_t handle
setSongStatus( song, SOUND_STATUS_STOPPED);
fprintf(stderr, "Overwriting old song (%08lx) ...\n", handle);
- if (song->status == SOUND_STATUS_PLAYING || song->status == SOUND_STATUS_SUSPENDED) {
+ if (song->_status == SOUND_STATUS_PLAYING || song->_status == SOUND_STATUS_SUSPENDED) {
delete it;
error("Unexpected (error): Song %ld still playing/suspended (%d)",
- handle, song->status);
+ handle, song->_status);
return;
} else {
song_lib_remove(_songlib, handle); /* No duplicates */
@@ -819,9 +828,9 @@ void SfxState::sfx_add_song(SongIterator *it, int priority, song_handle_t handle
}
song = song_new(handle, it, priority);
- song->resource_num = number;
- song->hold = 0;
- song->loops = 0;
+ song->_resourceNum = number;
+ song->_hold = 0;
+ song->_loops = 0;
song->_wakeupTime = Audio::Timestamp(g_system->getMillis(), SFX_TICKS_PER_SEC);
song_lib_add(_songlib, song);
_song = NULL; /* As above */
@@ -830,11 +839,11 @@ void SfxState::sfx_add_song(SongIterator *it, int priority, song_handle_t handle
return;
}
-void SfxState::sfx_remove_song(song_handle_t handle) {
+void SfxState::sfx_remove_song(SongHandle handle) {
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Removing song: %08lx\n", handle);
#endif
- if (_song && _song->handle == handle)
+ if (_song && _song->_handle == handle)
_song = NULL;
song_lib_remove(_songlib, handle);
@@ -849,8 +858,8 @@ void SfxState::sfx_remove_song(song_handle_t handle) {
#define ASSERT_SONG(s) if (!(s)) { warning("Looking up song handle %08lx failed in %s, L%d", handle, __FILE__, __LINE__); return; }
-void SfxState::sfx_song_set_status(song_handle_t handle, int status) {
- song_t *song = song_lib_find(_songlib, handle);
+void SfxState::sfx_song_set_status(SongHandle handle, int status) {
+ Song *song = song_lib_find(_songlib, handle);
ASSERT_SONG(song);
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Setting song status to %d"
@@ -862,11 +871,11 @@ void SfxState::sfx_song_set_status(song_handle_t handle, int status) {
update();
}
-void SfxState::sfx_song_set_fade(song_handle_t handle, fade_params_t *params) {
+void SfxState::sfx_song_set_fade(SongHandle handle, fade_params_t *params) {
#ifdef DEBUG_SONG_API
static const char *stopmsg[] = {"??? Should not happen", "Do not stop afterwards", "Stop afterwards"};
#endif
- song_t *song = song_lib_find(_songlib, handle);
+ Song *song = song_lib_find(_songlib, handle);
ASSERT_SONG(song);
@@ -877,52 +886,52 @@ void SfxState::sfx_song_set_fade(song_handle_t handle, fade_params_t *params) {
stopmsg[fade->action]);
#endif
- SIMSG_SEND_FADE(song->it, params);
+ SIMSG_SEND_FADE(song->_it, params);
update();
}
-void SfxState::sfx_song_renice(song_handle_t handle, int priority) {
- song_t *song = song_lib_find(_songlib, handle);
+void SfxState::sfx_song_renice(SongHandle handle, int priority) {
+ Song *song = song_lib_find(_songlib, handle);
ASSERT_SONG(song);
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Renicing song %08lx to %d\n",
handle, priority);
#endif
- song->priority = priority;
+ song->_priority = priority;
update();
}
-void SfxState::sfx_song_set_loops(song_handle_t handle, int loops) {
- song_t *song = song_lib_find(_songlib, handle);
+void SfxState::sfx_song_set_loops(SongHandle handle, int loops) {
+ Song *song = song_lib_find(_songlib, handle);
SongIterator::Message msg = SongIterator::Message(handle, SIMSG_SET_LOOPS(loops));
ASSERT_SONG(song);
- song->loops = loops;
+ song->_loops = loops;
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Setting loops on %08lx to %d\n",
handle, loops);
#endif
- songit_handle_message(&(song->it), msg);
+ songit_handle_message(&(song->_it), msg);
if (player/* && player->send_iterator_message*/)
/* FIXME: The above should be optional! */
player->iterator_message(msg);
}
-void SfxState::sfx_song_set_hold(song_handle_t handle, int hold) {
- song_t *song = song_lib_find(_songlib, handle);
+void SfxState::sfx_song_set_hold(SongHandle handle, int hold) {
+ Song *song = song_lib_find(_songlib, handle);
SongIterator::Message msg = SongIterator::Message(handle, SIMSG_SET_HOLD(hold));
ASSERT_SONG(song);
- song->hold = hold;
+ song->_hold = hold;
#ifdef DEBUG_SONG_API
fprintf(stderr, "[sfx-core] Setting hold on %08lx to %d\n",
handle, hold);
#endif
- songit_handle_message(&(song->it), msg);
+ songit_handle_message(&(song->_it), msg);
if (player/* && player->send_iterator_message*/)
/* FIXME: The above should be optional! */
@@ -934,9 +943,9 @@ static const int MIDI_cmdlen[16] = {0, 0, 0, 0, 0, 0, 0, 0,
3, 3, 0, 3, 2, 0, 3, 0
};
-static const song_handle_t midi_send_base = 0xffff0000;
+static const SongHandle midi_send_base = 0xffff0000;
-Common::Error SfxState::sfx_send_midi(song_handle_t handle, int channel,
+Common::Error SfxState::sfx_send_midi(SongHandle handle, int channel,
int command, int arg1, int arg2) {
byte buffer[5];
diff --git a/engines/sci/sfx/core.h b/engines/sci/sfx/core.h
index 69e30b43d8..5db56bd864 100644
--- a/engines/sci/sfx/core.h
+++ b/engines/sci/sfx/core.h
@@ -47,8 +47,8 @@ class SfxState {
public: // FIXME, make private
SongIterator *_it; /**< The song iterator at the heart of things */
uint _flags; /**< SFX_STATE_FLAG_* */
- songlib_t _songlib; /**< Song library */
- song_t *_song; /**< Active song, or start of active song chain */
+ SongLibrary _songlib; /**< Song library */
+ Song *_song; /**< Active song, or start of active song chain */
bool _suspended; /**< Whether we are suspended */
ResourceSync *_soundSync; /**< Used by kDoSync for speech syncing in CD talkie games */
AudioResource *_audioResource; /**< Used for audio resources in CD talkie games */
@@ -77,17 +77,17 @@ public:
/* Polls the sound server for cues etc.
** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise
- ** (song_handle_t) *handle: The affected handle
+ ** (SongHandle) *handle: The affected handle
** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP)
*/
- int sfx_poll(song_handle_t *handle, int *cue);
+ int sfx_poll(SongHandle *handle, int *cue);
/* Polls the sound server for cues etc.
- ** Parameters: (song_handle_t) handle: The handle to poll
+ ** Parameters: (SongHandle) handle: The handle to poll
** Returns : (int) 0 if the cue queue is empty, SI_LOOP, SI_CUE, or SI_FINISHED otherwise
** (int) *cue: The sound cue number (if SI_CUE), or the loop number (if SI_LOOP)
*/
- int sfx_poll_specific(song_handle_t handle, int *cue);
+ int sfx_poll_specific(SongHandle handle, int *cue);
/* Determines the current global volume settings
** Returns : (int) The global volume, between 0 (silent) and 127 (max. volume)
@@ -111,15 +111,15 @@ public:
/* Adds a song to the internal sound library
** 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
+ ** (SongHandle) handle: The handle to associate with the song
*/
- void sfx_add_song(SongIterator *it, int priority, song_handle_t handle, int resnum);
+ void sfx_add_song(SongIterator *it, int priority, SongHandle handle, int resnum);
/* Deletes a song and its associated song iterator from the song queue
- ** Parameters: (song_handle_t) handle: The song to remove
+ ** Parameters: (SongHandle) handle: The song to remove
*/
- void sfx_remove_song(song_handle_t handle);
+ void sfx_remove_song(SongHandle handle);
/**********************/
@@ -128,48 +128,48 @@ public:
/* Sets the song status, i.e. whether it is playing, suspended, or stopped.
- ** Parameters: (song_handle_t) handle: Handle of the song to modify
+ ** Parameters: (SongHandle) handle: Handle of the song to modify
** (int) status: The song status the song should assume
** WAITING and PLAYING are set implicitly and essentially describe the same state
** as far as this function is concerned.
*/
- void sfx_song_set_status(song_handle_t handle, int status);
+ void sfx_song_set_status(SongHandle handle, int status);
/* Sets the new song priority
- ** Parameters: (song_handle_t) handle: The handle to modify
+ ** Parameters: (SongHandle) handle: The handle to modify
** (int) priority: The priority to set
*/
- void sfx_song_renice(song_handle_t handle, int priority);
+ void sfx_song_renice(SongHandle handle, int priority);
/* Sets the number of loops for the specified song
- ** Parameters: (song_handle_t) handle: The song handle to reference
+ ** Parameters: (SongHandle) handle: The song handle to reference
** (int) loops: Number of loops to set
*/
- void sfx_song_set_loops(song_handle_t handle, int loops);
+ void sfx_song_set_loops(SongHandle handle, int loops);
/* Sets the number of loops for the specified song
- ** Parameters: (song_handle_t) handle: The song handle to reference
+ ** Parameters: (SongHandle) handle: The song handle to reference
** (int) hold: Number of loops to setn
*/
- void sfx_song_set_hold(song_handle_t handle, int hold);
+ void sfx_song_set_hold(SongHandle handle, int hold);
/* Instructs a song to be faded out
- ** Parameters: (song_handle_t) handle: The song handle to reference
+ ** Parameters: (SongHandle) handle: The song handle to reference
** (fade_params_t *) fade_setup: The precise fade-out configuration to use
*/
- void sfx_song_set_fade(song_handle_t handle, fade_params_t *fade_setup);
+ void sfx_song_set_fade(SongHandle handle, fade_params_t *fade_setup);
// Previously undocumented:
- Common::Error sfx_send_midi(song_handle_t handle, int channel,
+ Common::Error sfx_send_midi(SongHandle handle, int channel,
int command, int arg1, int arg2);
protected:
void freezeTime();
void thawTime();
- bool isPlaying(song_t *song);
- void setSongStatus(song_t *song, int status);
+ bool isPlaying(Song *song);
+ void setSongStatus(Song *song, int status);
void updateSingleSong();
void updateMultiSong();
void update();
diff --git a/engines/sci/sfx/iterator.h b/engines/sci/sfx/iterator.h
index 1a25b4afa1..547c479bbf 100644
--- a/engines/sci/sfx/iterator.h
+++ b/engines/sci/sfx/iterator.h
@@ -253,7 +253,6 @@ enum SongIteratorType {
| IT_READER_MASK_CUE \
| IT_READER_MASK_PCM )
-int songit_next(SongIterator **it, byte *buf, int *result, int mask);
/* Convenience wrapper around it->next
** Parameters: (SongIterator **it) Reference to the iterator to access
** (byte *) buf: The buffer to write to (needs to be able to
@@ -270,8 +269,8 @@ int songit_next(SongIterator **it, byte *buf, int *result, int mask);
** to the lower layers) for 0, the cue value for SI_CUE,
** or the number of loops remaining for SI_LOOP.
*/
+int songit_next(SongIterator **it, byte *buf, int *result, int mask);
-SongIterator *songit_new(byte *data, uint size, SongIteratorType type, songit_id_t id);
/* Constructs a new song iterator object
** Parameters: (byte *) data: The song data to iterate over
** (uint) size: Number of bytes in the song
@@ -280,26 +279,17 @@ SongIterator *songit_new(byte *data, uint size, SongIteratorType type, songit_id
** Returns : (SongIterator *) A newly allocated but uninitialized song
** iterator, or NULL if 'type' was invalid or unsupported
*/
+SongIterator *songit_new(byte *data, uint size, SongIteratorType type, songit_id_t id);
-int songit_handle_message(SongIterator **it_reg, SongIterator::Message msg);
/* Handles a message to 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.
*/
+int songit_handle_message(SongIterator **it_reg, SongIterator::Message msg);
-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: (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.
-*/
-
-
-SongIterator *new_fast_forward_iterator(SongIterator *it, int delta);
/* Creates a new song iterator which fast-forwards
** Parameters: (SongIterator *) it: The iterator to wrap
** (int) delta: The number of ticks to skip
@@ -307,6 +297,7 @@ SongIterator *new_fast_forward_iterator(SongIterator *it, int delta);
** which skips all delta times
** until 'delta' has been used up
*/
+SongIterator *new_fast_forward_iterator(SongIterator *it, int delta);
diff --git a/engines/sci/sfx/songlib.cpp b/engines/sci/sfx/songlib.cpp
index e1185aa039..61d9e3a6b3 100644
--- a/engines/sci/sfx/songlib.cpp
+++ b/engines/sci/sfx/songlib.cpp
@@ -31,169 +31,169 @@ namespace Sci {
#define debug_stream stderr
-song_t *song_new(song_handle_t handle, SongIterator *it, int priority) {
- song_t *retval;
- retval = (song_t*) malloc(sizeof(song_t));
+Song *song_new(SongHandle handle, SongIterator *it, int priority) {
+ Song *retval;
+ retval = (Song *)malloc(sizeof(Song));
#ifdef SATISFY_PURIFY
- memset(retval, 0, sizeof(song_t));
+ memset(retval, 0, sizeof(Song));
#endif
- retval->handle = handle;
- retval->priority = priority;
- retval->next = NULL;
+ retval->_handle = handle;
+ retval->_priority = priority;
+ retval->_next = NULL;
retval->_delay = 0;
retval->_wakeupTime = Audio::Timestamp();
- retval->it = it;
- retval->status = SOUND_STATUS_STOPPED;
- retval->next_playing = NULL;
- retval->next_stopping = NULL;
- retval->restore_behavior = RESTORE_BEHAVIOR_CONTINUE;
- retval->restore_time = 0;
+ retval->_it = it;
+ retval->_status = SOUND_STATUS_STOPPED;
+ retval->_nextPlaying = NULL;
+ retval->_nextStopping = NULL;
+ retval->_restoreBehavior = RESTORE_BEHAVIOR_CONTINUE;
+ retval->_restoreTime = 0;
return retval;
}
-void song_lib_add(const songlib_t &songlib, song_t *song) {
- song_t **seeker = NULL;
- int pri = song->priority;
+void song_lib_add(const SongLibrary &songlib, Song *song) {
+ Song **seeker = NULL;
+ int pri = song->_priority;
if (NULL == song) {
sciprintf("song_lib_add(): NULL passed for song\n");
return;
}
- if (*(songlib.lib) == NULL) {
- *(songlib.lib) = song;
- song->next = NULL;
+ if (*(songlib._lib) == NULL) {
+ *(songlib._lib) = song;
+ song->_next = NULL;
return;
}
- seeker = (songlib.lib);
- while (*seeker && ((*seeker)->priority > pri))
- seeker = &((*seeker)->next);
+ seeker = (songlib._lib);
+ while (*seeker && ((*seeker)->_priority > pri))
+ seeker = &((*seeker)->_next);
- song->next = *seeker;
+ song->_next = *seeker;
*seeker = song;
}
-static void _songfree_chain(song_t *song) {
+static void _songfree_chain(Song *song) {
/* Recursively free a chain of songs */
if (song) {
- _songfree_chain(song->next);
- delete song->it;
- song->it = NULL;
+ _songfree_chain(song->_next);
+ delete song->_it;
+ song->_it = NULL;
free(song);
}
}
-void song_lib_init(songlib_t *songlib) {
- songlib->lib = &(songlib->_s);
+void song_lib_init(SongLibrary *songlib) {
+ songlib->_lib = &(songlib->_s);
songlib->_s = NULL;
}
-void song_lib_free(const songlib_t &songlib) {
- _songfree_chain(*(songlib.lib));
- *(songlib.lib) = NULL;
+void song_lib_free(const SongLibrary &songlib) {
+ _songfree_chain(*(songlib._lib));
+ *(songlib._lib) = NULL;
}
-song_t *song_lib_find(const songlib_t &songlib, song_handle_t handle) {
- song_t *seeker = *(songlib.lib);
+Song *song_lib_find(const SongLibrary &songlib, SongHandle handle) {
+ Song *seeker = *(songlib._lib);
while (seeker) {
- if (seeker->handle == handle)
+ if (seeker->_handle == handle)
break;
- seeker = seeker->next;
+ seeker = seeker->_next;
}
return seeker;
}
-song_t *song_lib_find_next_active(const songlib_t &songlib, song_t *other) {
- song_t *seeker = other ? other->next : *(songlib.lib);
+Song *song_lib_find_next_active(const SongLibrary &songlib, Song *other) {
+ Song *seeker = other ? other->_next : *(songlib._lib);
while (seeker) {
- if ((seeker->status == SOUND_STATUS_WAITING) ||
- (seeker->status == SOUND_STATUS_PLAYING))
+ if ((seeker->_status == SOUND_STATUS_WAITING) ||
+ (seeker->_status == SOUND_STATUS_PLAYING))
break;
- seeker = seeker->next;
+ seeker = seeker->_next;
}
/* Only return songs that have equal priority */
- if (other && seeker && other->priority > seeker->priority)
+ if (other && seeker && other->_priority > seeker->_priority)
return NULL;
return seeker;
}
-song_t *song_lib_find_active(const songlib_t &songlib) {
+Song *song_lib_find_active(const SongLibrary &songlib) {
return song_lib_find_next_active(songlib, NULL);
}
-int song_lib_remove(const songlib_t &songlib, song_handle_t handle) {
+int song_lib_remove(const SongLibrary &songlib, SongHandle handle) {
int retval;
- song_t *goner = *(songlib.lib);
+ Song *goner = *(songlib._lib);
if (!goner)
return -1;
- if (goner->handle == handle)
- *(songlib.lib) = goner->next;
+ if (goner->_handle == handle)
+ *(songlib._lib) = goner->_next;
else {
- while ((goner->next) && (goner->next->handle != handle))
- goner = goner->next;
+ while ((goner->_next) && (goner->_next->_handle != handle))
+ goner = goner->_next;
- if (goner->next) { /* Found him? */
- song_t *oldnext = goner->next;
+ if (goner->_next) { /* Found him? */
+ Song *oldnext = goner->_next;
- goner->next = goner->next->next;
+ goner->_next = goner->_next->_next;
goner = oldnext;
} else return -1; /* No. */
}
- retval = goner->status;
+ retval = goner->_status;
- delete goner->it;
+ delete goner->_it;
free(goner);
return retval;
}
-void song_lib_resort(const songlib_t &songlib, song_t *song) {
- if (*(songlib.lib) == song)
- *(songlib.lib) = song->next;
+void song_lib_resort(const SongLibrary &songlib, Song *song) {
+ if (*(songlib._lib) == song)
+ *(songlib._lib) = song->_next;
else {
- song_t *seeker = *(songlib.lib);
+ Song *seeker = *(songlib._lib);
- while (seeker->next && (seeker->next != song))
- seeker = seeker->next;
+ while (seeker->_next && (seeker->_next != song))
+ seeker = seeker->_next;
- if (seeker->next)
- seeker->next = seeker->next->next;
+ if (seeker->_next)
+ seeker->_next = seeker->_next->_next;
}
song_lib_add(songlib, song);
}
-int song_lib_count(const songlib_t &songlib) {
- song_t *seeker = *(songlib.lib);
+int song_lib_count(const SongLibrary &songlib) {
+ Song *seeker = *(songlib._lib);
int retval = 0;
while (seeker) {
retval++;
- seeker = seeker->next;
+ seeker = seeker->_next;
}
return retval;
}
-void song_lib_set_restore_behavior(const songlib_t &songlib, song_handle_t handle, RESTORE_BEHAVIOR action) {
- song_t *seeker = song_lib_find(songlib, handle);
+void song_lib_set_restore_behavior(const SongLibrary &songlib, SongHandle handle, RESTORE_BEHAVIOR action) {
+ Song *seeker = song_lib_find(songlib, handle);
- seeker->restore_behavior = action;
+ seeker->_restoreBehavior = action;
}
} // End of namespace Sci
diff --git a/engines/sci/sfx/songlib.h b/engines/sci/sfx/songlib.h
index b9849fbfe3..76cae81ab9 100644
--- a/engines/sci/sfx/songlib.h
+++ b/engines/sci/sfx/songlib.h
@@ -42,7 +42,7 @@ class SongIterator;
#define SOUND_STATUS_WAITING 3
/* "waiting" means "tagged for playing, but not active right now" */
-typedef unsigned long song_handle_t;
+typedef unsigned long SongHandle;
enum RESTORE_BEHAVIOR {
RESTORE_BEHAVIOR_CONTINUE, /* restart a song when restored from
@@ -50,123 +50,130 @@ enum RESTORE_BEHAVIOR {
RESTORE_BEHAVIOR_RESTART /* continue it from where it was */
};
-struct song_t {
- song_handle_t handle;
- int resource_num; /* Resource number */
- int priority; /* Song priority (more important if priority is higher) */
- int status; /* See above */
+struct Song {
+ SongHandle _handle;
+ int _resourceNum; /**<! Resource number */
+ int _priority; /**!< Song priority (more important if priority is higher) */
+ int _status; /* See above */
- int restore_behavior;
- int restore_time;
+ int _restoreBehavior;
+ int _restoreTime;
/* Grabbed from the sound iterator, for save/restore purposes */
- int loops;
- int hold;
+ int _loops;
+ int _hold;
- SongIterator *it;
- int _delay; /* Delay before accessing the iterator, in ticks */
+ SongIterator *_it;
+ int _delay; /**!< Delay before accessing the iterator, in ticks */
- Audio::Timestamp _wakeupTime; /**< Timestamp indicating the next MIDI event */
+ Audio::Timestamp _wakeupTime; /**!< Timestamp indicating the next MIDI event */
- song_t *next; /* Next song or NULL if this is the last one */
- song_t *next_playing; /* Next playing song; used by the
- ** core song system */
- song_t *next_stopping; /* Next song pending stopping; used exclusively by
- ** the core song system's _update_multi_song() */
+ Song *_next; /**!< Next song or NULL if this is the last one */
+
+ /**
+ * Next playing song. Used by the core song system.
+ */
+ Song *_nextPlaying;
+
+ /**
+ * Next song pending stopping. Used exclusively by the core song system's
+ * _update_multi_song()
+ */
+ Song *_nextStopping;
};
-struct songlib_t {
- song_t **lib;
- song_t *_s;
+struct SongLibrary {
+ Song **_lib;
+ Song *_s;
};
/**************************/
/* Song library commands: */
/**************************/
-song_t *song_new(song_handle_t handle, SongIterator *it, int priority);
/* Initializes a new song
-** Parameters: (song_handle_t) handle: The sound handle
+** Parameters: (SongHandle) handle: The sound handle
** (SongIterator *) it: The song
** (int) priority: The song's priority
-** Returns : (song_t *) A freshly allocated song
+** Returns : (Song *) A freshly allocated song
** Other values are set to predefined defaults.
*/
+Song *song_new(SongHandle handle, SongIterator *it, int priority);
-void song_lib_init(songlib_t *songlib);
/* Initializes a static song library
-** Parameters: (songlib_t *) songlib: Pointer to the library
+** Parameters: (SongLibrary *) songlib: Pointer to the library
** to initialize
** Returns : (void)
*/
+void song_lib_init(SongLibrary *songlib);
-void song_lib_free(const songlib_t &songlib);
/* Frees a song library
-** Parameters: (songlib_t) songlib: The library to free
+** Parameters: (SongLibrary) songlib: The library to free
** Returns : (void)
*/
+void song_lib_free(const SongLibrary &songlib);
-void song_lib_add(const songlib_t &songlib, song_t *song);
/* Adds a song to a song library.
-** Parameters: (songlib_t) songlib: An existing sound library, or NULL
-** (song_t *) song: The song to add
+** Parameters: (SongLibrary) songlib: An existing sound library, or NULL
+** (Song *) song: The song to add
** Returns : (void)
*/
+void song_lib_add(const SongLibrary &songlib, Song *song);
-song_t *song_lib_find(const songlib_t &songlib, song_handle_t handle);
/* Looks up the song with the specified handle
-** Parameters: (songlib_t) songlib: An existing sound library, may point to NULL
-** (song_handle_t) handle: The sound handle to look for
-** Returns : (song_t *) The song or NULL if it wasn't found
+** Parameters: (SongLibrary) songlib: An existing sound library, may point to NULL
+** (SongHandle) handle: The sound handle to look for
+** Returns : (Song *) The song or NULL if it wasn't found
*/
+Song *song_lib_find(const SongLibrary &songlib, SongHandle handle);
-song_t *song_lib_find_active(const songlib_t &songlib);
/* Finds the first song playing with the highest priority
-** Parameters: (songlib_t) songlib: An existing sound library
-** Returns : (song_t *) The song that should be played next, or NULL if there is none
+** Parameters: (SongLibrary) songlib: An existing sound library
+** Returns : (Song *) The song that should be played next, or NULL if there is none
*/
+Song *song_lib_find_active(const SongLibrary &songlib);
-song_t *song_lib_find_next_active(const songlib_t &songlib, song_t *song);
/* Finds the next song playing with the highest priority
-** Parameters: (songlib_t) songlib: The song library to operate on
-** (song_t *) song: A song previously returned from the song library
-** Returns : (song_t *) The next song to play relative to 'song', or
+** Parameters: (SongLibrary) songlib: The song library to operate on
+** (Song *) song: A song previously returned from the song library
+** Returns : (Song *) The next song to play relative to 'song', or
** NULL if none are left
** The functions 'song_lib_find_active' and 'song_lib_find_next_active
** allow to iterate over all songs that satisfy the requirement of
** being 'playable'.
*/
+Song *song_lib_find_next_active(const SongLibrary &songlib, Song *song);
-int song_lib_remove(const songlib_t &songlib, song_handle_t handle);
/* Removes a song from the library
-** Parameters: (songlib_t) songlib: An existing sound library
-** (song_handle_t) handle: Handle of the song to remove
+** Parameters: (SongLibrary) songlib: An existing sound library
+** (SongHandle) handle: Handle of the song to remove
** Returns : (int) The status of the song that was removed
*/
+int song_lib_remove(const SongLibrary &songlib, SongHandle handle);
-void song_lib_resort(const songlib_t &songlib, song_t *song);
/* Removes a song from the library and sorts it in again; for use after renicing
-** Parameters: (songlib_t) songlib: An existing sound library
-** (song_t *) song: The song to work on
+** Parameters: (SongLibrary) songlib: An existing sound library
+** (Song *) song: The song to work on
** Returns : (void)
*/
+void song_lib_resort(const SongLibrary &songlib, Song *song);
-int song_lib_count(const songlib_t &songlib);
/* Counts the number of songs in a song library
-** Parameters: (songlib_t) songlib: The library to count
+** Parameters: (SongLibrary) songlib: The library to count
** Returns : (int) The number of songs
*/
+int song_lib_count(const SongLibrary &songlib);
-void song_lib_set_restore_behavior(const songlib_t &songlib, song_handle_t handle,
- RESTORE_BEHAVIOR action);
/* Determines what should be done with the song "handle" when
** restoring it from a saved game.
-** Parameters: (songlib_t) songlib: The library that contains the song
-** (song_handle_t) handle: Its handle
+** Parameters: (SongLibrary) songlib: The library that contains the song
+** (SongHandle) handle: Its handle
** (RESTORE_BEHAVIOR) action: The desired action
*/
+void song_lib_set_restore_behavior(const SongLibrary &songlib, SongHandle handle,
+ RESTORE_BEHAVIOR action);
} // End of namespace Sci