Ticket #9040: scummvm-sci-timeriterator.patch
File scummvm-sci-timeriterator.patch, 4.5 KB (added by , 15 years ago) |
---|
-
engine/ksound.cpp
148 148 return songit_new(song->data, song->size, type, id); 149 149 } 150 150 151 SongIterator *build_timeriterator(EngineState *s, int delta) { 152 return new_timer_iterator(delta); 153 } 151 154 152 155 void process_sound_events(EngineState *s) { /* Get all sound events, apply their changes to the heap */ 153 156 int result; … … 798 801 int looping = GET_SEL32V(obj, loop); 799 802 //int vol = GET_SEL32V(obj, vol); 800 803 int pri = GET_SEL32V(obj, pri); 804 int sampleLen = 0; 801 805 Song *song = s->_sound._songlib.findSong(handle); 802 806 803 807 if (GET_SEL32V(obj, nodePtr) && (song && number != song->_resourceNum)) { … … 815 819 s->_version >= SCI_VERSION_1_1) { 816 820 // Found a relevant audio resource, play it 817 821 s->_sound.stopAudio(); 818 PUT_SEL32V(obj, signal, s->_sound.startAudio(65535, number)); 819 return s->r_acc; 822 warning("Initializing audio resource instead of requested sound resource %d\n", number); 823 sampleLen = s->_sound.startAudio(65535, number); 824 // Also create iterator, that will fire SI_FINISHED event, when the sound is done playing 825 s->_sound.sfx_add_song(build_timeriterator(s, sampleLen), 0, handle, number); 826 PUT_SEL32V(obj, signal, sampleLen); 820 827 } else { 821 828 if (!s->resmgr->testResource(ResourceId(kResourceTypeSound, number))) { 822 829 warning("Could not open song number %d", number); … … 825 832 PUT_SEL32V(obj, signal, -1); 826 833 return s->r_acc; 827 834 } 835 debugC(2, kDebugLevelSound, "Initializing song number %d\n", number); 836 s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1, 837 handle), 0, handle, number); 828 838 } 829 839 830 debugC(2, kDebugLevelSound, "Initializing song number %d\n", number);831 s->_sound.sfx_add_song(build_iterator(s, number, SCI_SONG_ITERATOR_TYPE_SCI1,832 handle), 0, handle, number);833 840 PUT_SEL32(obj, nodePtr, obj); 834 841 PUT_SEL32(obj, handle, obj); 835 842 } -
sfx/iterator.cpp
1164 1164 return SI_FINISHED; 1165 1165 } 1166 1166 1167 /**********************/ 1168 /*-- Timer iterator --*/ 1169 /**********************/ 1170 TimerSongIterator::TimerSongIterator(int delta) 1171 : _delta(delta) { 1172 } 1173 1174 int TimerSongIterator::nextCommand(byte *buf, int *result) { 1175 if (_delta) { 1176 return _delta; 1177 } 1178 return SI_FINISHED; 1179 } 1180 1181 SongIterator *TimerSongIterator::handleMessage(Message msg) { 1182 return NULL; 1183 } 1184 1185 int TimerSongIterator::getTimepos() { 1186 return 0; 1187 } 1188 1189 Audio::AudioStream *TimerSongIterator::getAudioStream() { 1190 return NULL; 1191 } 1192 1193 SongIterator *TimerSongIterator::clone(int delta) { 1194 TimerSongIterator *newit = new TimerSongIterator(*this); 1195 return newit; 1196 } 1197 1198 SongIterator *new_timer_iterator(int delta) { 1199 return new TimerSongIterator(delta); 1200 } 1201 1167 1202 /**********************************/ 1168 1203 /*-- Fast-forward song iterator --*/ 1169 1204 /**********************************/ -
sfx/iterator.h
281 281 */ 282 282 SongIterator *songit_new(byte *data, uint size, SongIteratorType type, songit_id_t id); 283 283 284 /* Constructs a new song timer iterator object 285 ** Parameters: (int) delta: The delta after which to fire SI_FINISHED 286 ** Returns : (SongIterator *) A newly allocated but uninitialized song 287 ** iterator 288 */ 289 SongIterator *new_timer_iterator(int delta); 284 290 285 291 /* Handles a message to the song iterator 286 292 ** Parameters: (SongIterator **): A reference to the variable storing the song iterator -
sfx/iterator_internal.h
181 181 182 182 #define PLAYMASK_NONE 0x0 183 183 184 /***************************/ 185 /*--------- Timer ---------*/ 186 /***************************/ 187 188 /** 189 * A song iterator which waits a specified time and then fires 190 * SI_FINISHED. Used by DoSound, where audio resources are played (SCI1) 191 */ 192 class TimerSongIterator : public SongIterator { 193 protected: 194 int _delta; /**!< Remaining time */ 195 196 public: 197 TimerSongIterator(int delta); 198 199 int nextCommand(byte *buf, int *result); 200 Audio::AudioStream *getAudioStream(); 201 SongIterator *handleMessage(Message msg); 202 int getTimepos(); 203 SongIterator *clone(int delta); 204 }; 205 184 206 /**********************************/ 185 207 /*--------- Fast Forward ---------*/ 186 208 /**********************************/