diff options
author | Max Horn | 2009-03-09 19:55:18 +0000 |
---|---|---|
committer | Max Horn | 2009-03-09 19:55:18 +0000 |
commit | 7ec2a981776d2935deff007f2566255fcafda00f (patch) | |
tree | 54a794819e43eb2e488f38f198a1464029dddc77 | |
parent | d2514d20b97c43402835574ef9b5d2258ac3c4a7 (diff) | |
download | scummvm-rg350-7ec2a981776d2935deff007f2566255fcafda00f.tar.gz scummvm-rg350-7ec2a981776d2935deff007f2566255fcafda00f.tar.bz2 scummvm-rg350-7ec2a981776d2935deff007f2566255fcafda00f.zip |
SCI: Added BaseSongIterator copy constructor which invokey sci_refcount_incref
svn-id: r39273
-rw-r--r-- | engines/sci/sfx/iterator.cpp | 25 | ||||
-rw-r--r-- | engines/sci/sfx/iterator.h | 4 | ||||
-rw-r--r-- | engines/sci/sfx/iterator_internal.h | 4 | ||||
-rw-r--r-- | engines/sci/sfx/player/realtime.cpp | 3 |
4 files changed, 30 insertions, 6 deletions
diff --git a/engines/sci/sfx/iterator.cpp b/engines/sci/sfx/iterator.cpp index 735d9b0625..d8705ce8dc 100644 --- a/engines/sci/sfx/iterator.cpp +++ b/engines/sci/sfx/iterator.cpp @@ -69,6 +69,26 @@ BaseSongIterator::BaseSongIterator(byte *data, uint size, songit_id_t id) { _size = size; } +BaseSongIterator::BaseSongIterator(const BaseSongIterator& bsi) : SongIterator(bsi) { + memcpy(polyphony, bsi.polyphony, sizeof(polyphony)); + memcpy(importance, bsi.importance, sizeof(importance)); + ccc = bsi.ccc; + resetflag = bsi.resetflag; + _deviceId = bsi._deviceId; + active_channels = bsi.active_channels; + _size = bsi._size; + _data = bsi._data; + loops = bsi.loops; + recover_delay = bsi.recover_delay; + + if (_data) { +#ifdef DEBUG_VERBOSE + fprintf(stderr, "** CLONE INCREF for new %p from %p at %p\n", mem, this, mem->_data); +#endif + sci_refcount_incref(_data); + } +} + BaseSongIterator::~BaseSongIterator() { #ifdef DEBUG_VERBOSE fprintf(stderr, "** FREEING it %p: data at %p\n", this, _data); @@ -584,10 +604,6 @@ SongIterator *Sci0SongIterator::handleMessage(SongIteratorMessage msg) { case _SIMSG_BASEMSG_CLONE: { BaseSongIterator *mem = new Sci0SongIterator(*this); - sci_refcount_incref(mem->_data); -#ifdef DEBUG_VERBOSE - fprintf(stderr, "** CLONE INCREF for new %p from %p at %p\n", mem, this, mem->_data); -#endif return mem; /* Assume caller has another copy of this */ } @@ -1080,7 +1096,6 @@ SongIterator *Sci1SongIterator::handleMessage(SongIteratorMessage msg) { Sci1SongIterator *mem = new Sci1SongIterator(*this); int delta = msg.args[0].i; /* Delay until next step */ - sci_refcount_incref(mem->_data); mem->_delayRemaining += delta; return mem; /* Assume caller has another copy of this */ diff --git a/engines/sci/sfx/iterator.h b/engines/sci/sfx/iterator.h index 24f438f6b6..e37491e2ef 100644 --- a/engines/sci/sfx/iterator.h +++ b/engines/sci/sfx/iterator.h @@ -212,6 +212,10 @@ public: */ virtual int getTimepos() = 0; + +private: + // Make the assignment operator unreachable, just in case... + SongIterator& operator=(const SongIterator&); }; diff --git a/engines/sci/sfx/iterator_internal.h b/engines/sci/sfx/iterator_internal.h index 5dc80ab12b..1bfe8d2286 100644 --- a/engines/sci/sfx/iterator_internal.h +++ b/engines/sci/sfx/iterator_internal.h @@ -98,6 +98,10 @@ public: public: BaseSongIterator(byte *data, uint size, songit_id_t id); + + // Copy constructor taking care of memory handling + BaseSongIterator(const BaseSongIterator&); + ~BaseSongIterator(); }; diff --git a/engines/sci/sfx/player/realtime.cpp b/engines/sci/sfx/player/realtime.cpp index 60053c57ae..ed688176c7 100644 --- a/engines/sci/sfx/player/realtime.cpp +++ b/engines/sci/sfx/player/realtime.cpp @@ -121,7 +121,8 @@ static void rt_timer_callback(void) { } else if (delta > 15) { play_writeahead -= 3; /* Adjust downwards */ } - } else --play_moredelay; + } else + --play_moredelay; if (play_writeahead < seq->min_write_ahead_ms) play_writeahead = seq->min_write_ahead_ms; |