[Scummvm-cvs-logs] SF.net SVN: scummvm:[39273] scummvm/trunk/engines/sci/sfx

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Mar 9 20:55:18 CET 2009


Revision: 39273
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39273&view=rev
Author:   fingolfin
Date:     2009-03-09 19:55:18 +0000 (Mon, 09 Mar 2009)

Log Message:
-----------
SCI: Added BaseSongIterator copy constructor which invokey sci_refcount_incref

Modified Paths:
--------------
    scummvm/trunk/engines/sci/sfx/iterator.cpp
    scummvm/trunk/engines/sci/sfx/iterator.h
    scummvm/trunk/engines/sci/sfx/iterator_internal.h
    scummvm/trunk/engines/sci/sfx/player/realtime.cpp

Modified: scummvm/trunk/engines/sci/sfx/iterator.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator.cpp	2009-03-09 19:44:10 UTC (rev 39272)
+++ scummvm/trunk/engines/sci/sfx/iterator.cpp	2009-03-09 19:55:18 UTC (rev 39273)
@@ -69,6 +69,26 @@
 	_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 @@
 
 		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 @@
 			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 */

Modified: scummvm/trunk/engines/sci/sfx/iterator.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator.h	2009-03-09 19:44:10 UTC (rev 39272)
+++ scummvm/trunk/engines/sci/sfx/iterator.h	2009-03-09 19:55:18 UTC (rev 39273)
@@ -212,6 +212,10 @@
 	 */
 	virtual int getTimepos() = 0;
 
+
+private:
+	// Make the assignment operator unreachable, just in case...
+	SongIterator& operator=(const SongIterator&);
 };
 
 

Modified: scummvm/trunk/engines/sci/sfx/iterator_internal.h
===================================================================
--- scummvm/trunk/engines/sci/sfx/iterator_internal.h	2009-03-09 19:44:10 UTC (rev 39272)
+++ scummvm/trunk/engines/sci/sfx/iterator_internal.h	2009-03-09 19:55:18 UTC (rev 39273)
@@ -98,6 +98,10 @@
 
 public:
 	BaseSongIterator(byte *data, uint size, songit_id_t id);
+
+	// Copy constructor taking care of memory handling
+	BaseSongIterator(const BaseSongIterator&);
+
 	~BaseSongIterator();
 };
 

Modified: scummvm/trunk/engines/sci/sfx/player/realtime.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/player/realtime.cpp	2009-03-09 19:44:10 UTC (rev 39272)
+++ scummvm/trunk/engines/sci/sfx/player/realtime.cpp	2009-03-09 19:55:18 UTC (rev 39273)
@@ -121,7 +121,8 @@
 			} 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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list