From 2b5fac58d5323847042e53f114ad94ce2d526f3b Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 11 Jul 2009 06:53:39 +0000 Subject: Applied patch 2818733 - "SCI: Timer iterator for audio resources played via doSound" svn-id: r42375 --- engines/sci/sfx/iterator.cpp | 35 +++++++++++++++++++++++++++++++++++ engines/sci/sfx/iterator.h | 6 ++++++ engines/sci/sfx/iterator_internal.h | 22 ++++++++++++++++++++++ 3 files changed, 63 insertions(+) (limited to 'engines/sci/sfx') diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index ebba4bceac..6c5706a8c1 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -1164,6 +1164,41 @@ int CleanupSongIterator::nextCommand(byte *buf, int *result) { return SI_FINISHED; } +/**********************/ +/*-- Timer iterator --*/ +/**********************/ +TimerSongIterator::TimerSongIterator(int delta) + : _delta(delta) { +} + +int TimerSongIterator::nextCommand(byte *buf, int *result) { + if (_delta) { + return _delta; + } + return SI_FINISHED; +} + +SongIterator *TimerSongIterator::handleMessage(Message msg) { + return NULL; +} + +int TimerSongIterator::getTimepos() { + return 0; +} + +Audio::AudioStream *TimerSongIterator::getAudioStream() { + return NULL; +} + +SongIterator *TimerSongIterator::clone(int delta) { + TimerSongIterator *newit = new TimerSongIterator(*this); + return newit; +} + +SongIterator *new_timer_iterator(int delta) { + return new TimerSongIterator(delta); +} + /**********************************/ /*-- Fast-forward song iterator --*/ /**********************************/ diff --git a/engines/sci/sfx/iterator.h b/engines/sci/sfx/iterator.h index 547c479bbf..4e6df367c9 100644 --- a/engines/sci/sfx/iterator.h +++ b/engines/sci/sfx/iterator.h @@ -281,6 +281,12 @@ 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 timer iterator object +** Parameters: (int) delta: The delta after which to fire SI_FINISHED +** Returns : (SongIterator *) A newly allocated but uninitialized song +** iterator +*/ +SongIterator *new_timer_iterator(int delta); /* Handles a message to the song iterator ** Parameters: (SongIterator **): A reference to the variable storing the song iterator diff --git a/engines/sci/sfx/iterator_internal.h b/engines/sci/sfx/iterator_internal.h index 7d5a17fd25..00044b8ab7 100644 --- a/engines/sci/sfx/iterator_internal.h +++ b/engines/sci/sfx/iterator_internal.h @@ -181,6 +181,28 @@ private: #define PLAYMASK_NONE 0x0 +/***************************/ +/*--------- Timer ---------*/ +/***************************/ + +/** + * A song iterator which waits a specified time and then fires + * SI_FINISHED. Used by DoSound, where audio resources are played (SCI1) + */ +class TimerSongIterator : public SongIterator { +protected: + int _delta; /**!< Remaining time */ + +public: + TimerSongIterator(int delta); + + int nextCommand(byte *buf, int *result); + Audio::AudioStream *getAudioStream(); + SongIterator *handleMessage(Message msg); + int getTimepos(); + SongIterator *clone(int delta); +}; + /**********************************/ /*--------- Fast Forward ---------*/ /**********************************/ -- cgit v1.2.3