SCI: Objectified Song struct 'a bit'
svn-id: r41344
This commit is contained in:
parent
d07e9dfb13
commit
62f596821e
3 changed files with 52 additions and 36 deletions
|
@ -824,7 +824,7 @@ void SfxState::sfx_add_song(SongIterator *it, int priority, SongHandle handle, i
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
song = song_new(handle, it, priority);
|
song = new Song(handle, it, priority);
|
||||||
song->_resourceNum = number;
|
song->_resourceNum = number;
|
||||||
song->_hold = 0;
|
song->_hold = 0;
|
||||||
song->_loops = 0;
|
song->_loops = 0;
|
||||||
|
|
|
@ -31,27 +31,42 @@ namespace Sci {
|
||||||
|
|
||||||
#define debug_stream stderr
|
#define debug_stream stderr
|
||||||
|
|
||||||
Song *song_new(SongHandle handle, SongIterator *it, int priority) {
|
Song::Song() {
|
||||||
Song *retval;
|
_handle = 0;
|
||||||
retval = (Song *)malloc(sizeof(Song));
|
_priority = 0;
|
||||||
|
_status = SOUND_STATUS_STOPPED;
|
||||||
|
|
||||||
#ifdef SATISFY_PURIFY
|
_restoreBehavior = RESTORE_BEHAVIOR_CONTINUE;
|
||||||
memset(retval, 0, sizeof(Song));
|
_restoreTime = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
retval->_handle = handle;
|
_loops = 0;
|
||||||
retval->_priority = priority;
|
_hold = 0;
|
||||||
retval->_next = NULL;
|
|
||||||
retval->_delay = 0;
|
|
||||||
retval->_wakeupTime = Audio::Timestamp();
|
|
||||||
retval->_it = it;
|
|
||||||
retval->_status = SOUND_STATUS_STOPPED;
|
|
||||||
retval->_nextPlaying = NULL;
|
|
||||||
retval->_nextStopping = NULL;
|
|
||||||
retval->_restoreBehavior = RESTORE_BEHAVIOR_CONTINUE;
|
|
||||||
retval->_restoreTime = 0;
|
|
||||||
|
|
||||||
return retval;
|
_it = 0;
|
||||||
|
_delay = 0;
|
||||||
|
|
||||||
|
_next = NULL;
|
||||||
|
_nextPlaying = NULL;
|
||||||
|
_nextStopping = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Song::Song(SongHandle handle, SongIterator *it, int priority) {
|
||||||
|
_handle = handle;
|
||||||
|
_priority = priority;
|
||||||
|
_status = SOUND_STATUS_STOPPED;
|
||||||
|
|
||||||
|
_restoreBehavior = RESTORE_BEHAVIOR_CONTINUE;
|
||||||
|
_restoreTime = 0;
|
||||||
|
|
||||||
|
_loops = 0;
|
||||||
|
_hold = 0;
|
||||||
|
|
||||||
|
_it = it;
|
||||||
|
_delay = 0;
|
||||||
|
|
||||||
|
_next = NULL;
|
||||||
|
_nextPlaying = NULL;
|
||||||
|
_nextStopping = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongLibrary::addSong(Song *song) {
|
void SongLibrary::addSong(Song *song) {
|
||||||
|
@ -90,7 +105,7 @@ void SongLibrary::freeSounds() {
|
||||||
delete song->_it;
|
delete song->_it;
|
||||||
song->_it = NULL;
|
song->_it = NULL;
|
||||||
next = song->_next;
|
next = song->_next;
|
||||||
free(song);
|
delete song;
|
||||||
}
|
}
|
||||||
*_lib = NULL;
|
*_lib = NULL;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +169,7 @@ int SongLibrary::removeSong(SongHandle handle) {
|
||||||
retval = goner->_status;
|
retval = goner->_status;
|
||||||
|
|
||||||
delete goner->_it;
|
delete goner->_it;
|
||||||
free(goner);
|
delete goner;
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ enum RESTORE_BEHAVIOR {
|
||||||
RESTORE_BEHAVIOR_RESTART /* continue it from where it was */
|
RESTORE_BEHAVIOR_RESTART /* continue it from where it was */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Song {
|
class Song {
|
||||||
|
public:
|
||||||
SongHandle _handle;
|
SongHandle _handle;
|
||||||
int _resourceNum; /**<! Resource number */
|
int _resourceNum; /**<! Resource number */
|
||||||
int _priority; /**!< Song priority (more important if priority is higher) */
|
int _priority; /**!< Song priority (more important if priority is higher) */
|
||||||
|
@ -80,26 +81,26 @@ struct Song {
|
||||||
* _update_multi_song()
|
* _update_multi_song()
|
||||||
*/
|
*/
|
||||||
Song *_nextStopping;
|
Song *_nextStopping;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Song();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a new song.
|
||||||
|
* @param handle the sound handle
|
||||||
|
* @param it the song
|
||||||
|
* @param priority the song's priority
|
||||||
|
* @return a freshly allocated song
|
||||||
|
*/
|
||||||
|
Song(SongHandle handle, SongIterator *it, int priority);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**************************/
|
|
||||||
/* Song library commands: */
|
|
||||||
/**************************/
|
|
||||||
|
|
||||||
/* Initializes a new song
|
|
||||||
** Parameters: (SongHandle) handle: The sound handle
|
|
||||||
** (SongIterator *) it: The song
|
|
||||||
** (int) priority: The song's priority
|
|
||||||
** Returns : (Song *) A freshly allocated song
|
|
||||||
** Other values are set to predefined defaults.
|
|
||||||
*/
|
|
||||||
Song *song_new(SongHandle handle, SongIterator *it, int priority);
|
|
||||||
|
|
||||||
|
|
||||||
class SongLibrary {
|
class SongLibrary {
|
||||||
public:
|
public:
|
||||||
Song **_lib;
|
Song **_lib;
|
||||||
|
protected:
|
||||||
Song *_s;
|
Song *_s;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue