[Scummvm-cvs-logs] SF.net SVN: scummvm:[47032] scummvm/trunk/sound/mixer.cpp

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Tue Jan 5 20:52:13 CET 2010


Revision: 47032
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47032&view=rev
Author:   lordhoto
Date:     2010-01-05 19:52:12 +0000 (Tue, 05 Jan 2010)

Log Message:
-----------
Get rid of public variables in Channel.

Modified Paths:
--------------
    scummvm/trunk/sound/mixer.cpp

Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp	2010-01-05 19:51:48 UTC (rev 47031)
+++ scummvm/trunk/sound/mixer.cpp	2010-01-05 19:52:12 UTC (rev 47032)
@@ -63,11 +63,14 @@
 
 	uint32 getElapsedTime();
 
-public:
+	Mixer::SoundType getType() const { return _type; }
+
+	void setHandle(const SoundHandle handle) { _handle = handle; }
+	SoundHandle getHandle() const { return _handle; }
+
+private:
 	const Mixer::SoundType _type;
 	SoundHandle _handle;
-
-private:
 	bool _permanent;
 	int _pauseLevel;
 	int _id;
@@ -153,11 +156,14 @@
 	}
 
 	_channels[index] = chan;
-	 chan->_handle._val = index + (_handleSeed * NUM_CHANNELS);
+
+	SoundHandle chanHandle;
+	chanHandle._val = index + (_handleSeed * NUM_CHANNELS);
+
+	chan->setHandle(chanHandle);
 	_handleSeed++;
-	if (handle) {
-		*handle = chan->_handle;
-	}
+	if (handle)
+		*handle = chanHandle;
 }
 
 void MixerImpl::playRaw(
@@ -257,7 +263,7 @@
 
 	// Simply ignore stop requests for handles of sounds that already terminated
 	const int index = handle._val % NUM_CHANNELS;
-	if (!_channels[index] || _channels[index]->_handle._val != handle._val)
+	if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
 		return;
 
 	delete _channels[index];
@@ -268,7 +274,7 @@
 	Common::StackLock lock(_mutex);
 
 	const int index = handle._val % NUM_CHANNELS;
-	if (!_channels[index] || _channels[index]->_handle._val != handle._val)
+	if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
 		return;
 
 	_channels[index]->setVolume(volume);
@@ -278,7 +284,7 @@
 	Common::StackLock lock(_mutex);
 
 	const int index = handle._val % NUM_CHANNELS;
-	if (!_channels[index] || _channels[index]->_handle._val != handle._val)
+	if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
 		return;
 
 	_channels[index]->setBalance(balance);
@@ -288,7 +294,7 @@
 	Common::StackLock lock(_mutex);
 
 	const int index = handle._val % NUM_CHANNELS;
-	if (!_channels[index] || _channels[index]->_handle._val != handle._val)
+	if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
 		return 0;
 
 	return _channels[index]->getElapsedTime();
@@ -318,7 +324,7 @@
 
 	// Simply ignore (un)pause requests for sounds that already terminated
 	const int index = handle._val % NUM_CHANNELS;
-	if (!_channels[index] || _channels[index]->_handle._val != handle._val)
+	if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
 		return;
 
 	_channels[index]->pause(paused);
@@ -335,7 +341,7 @@
 int MixerImpl::getSoundID(SoundHandle handle) {
 	Common::StackLock lock(_mutex);
 	const int index = handle._val % NUM_CHANNELS;
-	if (_channels[index] && _channels[index]->_handle._val == handle._val)
+	if (_channels[index] && _channels[index]->getHandle()._val == handle._val)
 		return _channels[index]->getId();
 	return 0;
 }
@@ -343,13 +349,13 @@
 bool MixerImpl::isSoundHandleActive(SoundHandle handle) {
 	Common::StackLock lock(_mutex);
 	const int index = handle._val % NUM_CHANNELS;
-	return _channels[index] && _channels[index]->_handle._val == handle._val;
+	return _channels[index] && _channels[index]->getHandle()._val == handle._val;
 }
 
 bool MixerImpl::hasActiveChannelOfType(SoundType type) {
 	Common::StackLock lock(_mutex);
 	for (int i = 0; i != NUM_CHANNELS; i++)
-		if (_channels[i] && _channels[i]->_type == type)
+		if (_channels[i] && _channels[i]->getType() == type)
 			return true;
 	return false;
 }
@@ -469,7 +475,7 @@
 		// volume is in the range 0 - kMaxMixerVolume.
 		// Hence, the vol_l/vol_r values will be in that range, too
 
-		int vol = _mixer->getVolumeForSoundType(_type) * _volume;
+		int vol = _mixer->getVolumeForSoundType(getType()) * _volume;
 		st_volume_t vol_l, vol_r;
 
 		if (_balance == 0) {


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