[Scummvm-cvs-logs] SF.net SVN: scummvm: [25356] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Feb 3 20:05:54 CET 2007


Revision: 25356
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25356&view=rev
Author:   fingolfin
Date:     2007-02-03 11:05:53 -0800 (Sat, 03 Feb 2007)

Log Message:
-----------
* Reimplemented Mixer::pauseAll to simply invoke pause on all channels
  (implying change of semantics)
* Reordered the params of Mixer::playRaw (the SoundType now comes first, not last)
* Removed Mixer::isPaused
* Removed Mixer::getSoundElapsedTimeOfSoundID
* Added some doxygen comments to the Mixer

Modified Paths:
--------------
    scummvm/trunk/engines/agos/sound.cpp
    scummvm/trunk/engines/queen/sound.cpp
    scummvm/trunk/engines/saga/sound.cpp
    scummvm/trunk/engines/scumm/he/cup_player_he.cpp
    scummvm/trunk/engines/scumm/he/sound_he.cpp
    scummvm/trunk/engines/scumm/sound.cpp
    scummvm/trunk/engines/sky/intro.cpp
    scummvm/trunk/engines/sky/sound.cpp
    scummvm/trunk/engines/sword1/sound.cpp
    scummvm/trunk/engines/sword2/animation.cpp
    scummvm/trunk/engines/sword2/sound.cpp
    scummvm/trunk/sound/mixer.cpp
    scummvm/trunk/sound/mixer.h

Modified: scummvm/trunk/engines/agos/sound.cpp
===================================================================
--- scummvm/trunk/engines/agos/sound.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/agos/sound.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -248,7 +248,7 @@
 	int size, rate;
 	byte *buffer = Audio::loadVOCFromStream(*_file, size, rate);
 	assert(buffer);
-	_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, sound);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, sound);
 }
 
 void RawSound::playSound(uint sound, uint loopSound, Audio::SoundHandle *handle, byte flags, int vol) {
@@ -261,7 +261,7 @@
 	byte *buffer = (byte *)malloc(size);
 	assert(buffer);
 	_file->read(buffer, size);
-	_mixer->playRaw(handle, buffer, size, 22050, flags | Audio::Mixer::FLAG_AUTOFREE, sound);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, 22050, flags | Audio::Mixer::FLAG_AUTOFREE, sound);
 }
 
 #ifdef USE_MAD
@@ -671,9 +671,9 @@
 	memcpy(buffer, soundData, size);
 
 	if (_vm->getPlatform() == Common::kPlatformPC)
-		_mixer->playRaw(&_effectsHandle, buffer, size, 8000, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE, sound);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_effectsHandle, buffer, size, 8000, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE, sound);
 	else
-		_mixer->playRaw(&_effectsHandle, buffer, size, 8000, Audio::Mixer::FLAG_AUTOFREE, sound);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_effectsHandle, buffer, size, 8000, Audio::Mixer::FLAG_AUTOFREE, sound);
 }
 
 // Feeble Files specific
@@ -737,7 +737,7 @@
 		memcpy(buffer, soundData + stream.pos(), size);
 	}
 
-	_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, sound, vol, pan);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE, sound, vol, pan);
 }
 
 void Sound::stopSfx5() {

Modified: scummvm/trunk/engines/queen/sound.cpp
===================================================================
--- scummvm/trunk/engines/queen/sound.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/queen/sound.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -198,7 +198,7 @@
 	if (sound) {
 		f->read(sound, size);
 		byte flags = Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE;
-		_mixer->playRaw(soundHandle, sound, size, 11025, flags);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, soundHandle, sound, size, 11025, flags);
 	}
 }
 

Modified: scummvm/trunk/engines/saga/sound.cpp
===================================================================
--- scummvm/trunk/engines/saga/sound.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/saga/sound.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -79,7 +79,7 @@
 	if (!buffer.isSigned)
 		flags |= Audio::Mixer::FLAG_UNSIGNED;
 
-	_mixer->playRaw(handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer.buffer, buffer.size, buffer.frequency, flags, -1, volume);
 }
 
 void Sound::playSound(SoundBuffer &buffer, int volume, bool loop) {

Modified: scummvm/trunk/engines/scumm/he/cup_player_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/cup_player_he.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/scumm/he/cup_player_he.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -169,7 +169,7 @@
 					flags |= Audio::Mixer::FLAG_LOOP;
 					loopEnd = soundSize - 8;
 				}
-				_mixer->playRaw(&sfxChannel->handle, soundData + 8, soundSize - 8, 11025, flags, -1, 255, 0, 0, loopEnd);
+				_mixer->playRaw(Audio::Mixer::kSFXSoundType, &sfxChannel->handle, soundData + 8, soundSize - 8, 11025, flags, -1, 255, 0, 0, loopEnd);
 			}
 		} else {
 			warning("Unable to find a free channel to play sound %d", sfx->num);

Modified: scummvm/trunk/engines/scumm/he/sound_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/sound_he.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/scumm/he/sound_he.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -535,7 +535,7 @@
 		musicFile.close();
 
 		if (_vm->_game.heversion == 70) {
-			_mixer->playRaw(&_heSoundChannels[heChannel], spoolPtr, size, 11025, flags, soundID, 255, 0, 0,0, type);
+			_mixer->playRaw(type, &_heSoundChannels[heChannel], spoolPtr, size, 11025, flags, soundID, 255, 0, 0, 0);
 			return;
 		}
 	}
@@ -586,7 +586,7 @@
 		}
 
 		_mixer->stopHandle(_heSoundChannels[heChannel]);
-		_mixer->playRaw(&_heSoundChannels[heChannel], sound, size, rate, flags, soundID, 255, 0, 0,0, type);
+		_mixer->playRaw(type, &_heSoundChannels[heChannel], sound, size, rate, flags, soundID, 255, 0, 0,0);
 	}
 	// Support for sound in Humongous Entertainment games
 	else if (READ_BE_UINT32(ptr) == MKID_BE('DIGI') || READ_BE_UINT32(ptr) == MKID_BE('TALK')) {
@@ -642,7 +642,7 @@
 		}
 
 		_mixer->stopHandle(_heSoundChannels[heChannel]);
-		_mixer->playRaw(&_heSoundChannels[heChannel], ptr + heOffset + 8, size, rate, flags, soundID, 255, 0, 0,0, type);
+		_mixer->playRaw(type, &_heSoundChannels[heChannel], ptr + heOffset + 8, size, rate, flags, soundID, 255, 0, 0,0);
 
 	}
 	// Support for PCM music in 3DO versions of Humongous Entertainment games
@@ -660,7 +660,7 @@
 
 		_mixer->stopID(_currentMusic);
 		_currentMusic = soundID;
-		_mixer->playRaw(NULL, ptr + 8, size, rate, flags, soundID, 255, 0, 0,0, Audio::Mixer::kMusicSoundType);
+		_mixer->playRaw(Audio::Mixer::kMusicSoundType, NULL, ptr + 8, size, rate, flags, soundID, 255, 0, 0,0);
 	}
 	else if (READ_BE_UINT32(ptr) == MKID_BE('MIDI')) {
 		if (_vm->_imuse) {

Modified: scummvm/trunk/engines/scumm/sound.cpp
===================================================================
--- scummvm/trunk/engines/scumm/sound.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/scumm/sound.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -188,7 +188,7 @@
 		// Allocate a sound buffer, copy the data into it, and play
 		sound = (char *)malloc(size);
 		memcpy(sound, ptr, size);
-		_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate, flags, soundID);
 	}
 	// WORKAROUND bug # 1311447
 	else if (READ_BE_UINT32(ptr) == 0x460e200d) {
@@ -210,7 +210,7 @@
 		// Allocate a sound buffer, copy the data into it, and play
 		sound = (char *)malloc(size);
 		memcpy(sound, ptr, size);
-		_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate, flags, soundID);
 	}
 	// Support for sampled sound effects in Monkey Island 1 and 2
 	else if (READ_BE_UINT32(ptr) == MKID_BE('SBL ')) {
@@ -281,7 +281,7 @@
 		// Allocate a sound buffer, copy the data into it, and play
 		sound = (char *)malloc(size);
 		memcpy(sound, ptr + 6, size);
-		_mixer->playRaw(NULL, sound, size, rate, flags, soundID);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate, flags, soundID);
 	}
 	else if ((_vm->_game.platform == Common::kPlatformFMTowns && _vm->_game.version == 3) || READ_BE_UINT32(ptr) == MKID_BE('SOUN') || READ_BE_UINT32(ptr) == MKID_BE('TOWS')) {
 
@@ -334,7 +334,7 @@
 				if (loopEnd > 0)
 					flags |= Audio::Mixer::FLAG_LOOP;
 
-				_mixer->playRaw(NULL, sound, waveSize, rate, flags, soundID, 255, 0, loopStart, loopEnd);
+				_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, waveSize, rate, flags, soundID, 255, 0, loopStart, loopEnd);
 			}
 			break;
 		case 1:
@@ -395,7 +395,7 @@
 		sound = (char *)malloc(size);
 		int vol = ptr[24] * 4;
 		memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
-		_mixer->playRaw(NULL, sound, size, rate, Audio::Mixer::FLAG_AUTOFREE, soundID, vol, 0);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, rate, Audio::Mixer::FLAG_AUTOFREE, soundID, vol, 0);
 	}
 	else {
 

Modified: scummvm/trunk/engines/sky/intro.cpp
===================================================================
--- scummvm/trunk/engines/sky/intro.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/sky/intro.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -740,7 +740,7 @@
 		// probably use _skySound instead of calling playRaw()
 		// directly, but this will have to do for now.
 		memset(vData, 127, sizeof(struct dataFileHeader));
-		_mixer->playRaw(&_voice, vData, _skyDisk->_lastLoadedFileSize, 11025,
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_voice, vData, _skyDisk->_lastLoadedFileSize, 11025,
 				Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED, SOUND_VOICE);
 		return true;
 	case WAITVOICE:
@@ -757,12 +757,12 @@
 		return true;
 	case LOOPBG:
 		_mixer->stopID(SOUND_BG);
-		_mixer->playRaw(&_bgSfx, _bgBuf + 256, _bgSize - 768, 11025,
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_bgSfx, _bgBuf + 256, _bgSize - 768, 11025,
 				Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LOOP, SOUND_BG);
 		return true;
 	case PLAYBG:
 		_mixer->stopID(SOUND_BG);
-		_mixer->playRaw(&_bgSfx, _bgBuf + 256, _bgSize - 768, 11025,
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_bgSfx, _bgBuf + 256, _bgSize - 768, 11025,
 				Audio::Mixer::FLAG_UNSIGNED, SOUND_BG);
 		return true;
 	case STOPBG:

Modified: scummvm/trunk/engines/sky/sound.cpp
===================================================================
--- scummvm/trunk/engines/sky/sound.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/sky/sound.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -1040,7 +1040,7 @@
 	memcpy(buffer, sound+sizeof(struct dataFileHeader), size);
 
 	_mixer->stopID(id);
-	_mixer->playRaw(handle, buffer, size, 11025, flags, id);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, 11025, flags, id);
 }
 
 void Sound::loadSection(uint8 pSection) {
@@ -1118,9 +1118,9 @@
 	}
 
 	if (channel == 0)
-		_mixer->playRaw(&_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH0, volume, 0, loopSta, loopEnd);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound0, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH0, volume, 0, loopSta, loopEnd);
 	else
-		_mixer->playRaw(&_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH1, volume, 0, loopSta, loopEnd);
+		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound1, _soundData + dataOfs, dataSize, sampleRate, flags, SOUND_CH1, volume, 0, loopSta, loopEnd);
 }
 
 void Sound::fnStartFx(uint32 sound, uint8 channel) {
@@ -1245,7 +1245,7 @@
 		rate = 11025;
 
 	_mixer->stopID(SOUND_SPEECH);
-	_mixer->playRaw(&_ingameSpeech, playBuffer, speechSize, rate, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE, SOUND_SPEECH);
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSpeech, playBuffer, speechSize, rate, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_AUTOFREE, SOUND_SPEECH);
 	return true;
 }
 

Modified: scummvm/trunk/engines/sword1/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sound.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/sword1/sound.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -172,7 +172,7 @@
 						flags |= Audio::Mixer::FLAG_STEREO;
 					if (_fxList[elem->id].type == FX_LOOP)
 						flags |= Audio::Mixer::FLAG_LOOP;
-					_mixer->playRaw(&elem->handle, sampleData + 0x2C, size, 11025, flags, elem->id, volume, pan);
+					_mixer->playRaw(Audio::Mixer::kSFXSoundType, &elem->handle, sampleData + 0x2C, size, 11025, flags, elem->id, volume, pan);
 			}
 		} else
 			break;
@@ -196,7 +196,7 @@
 			uint32 size;
 			int16 *data = uncompressSpeech(index + _cowHeaderSize, sampleSize, &size);
 			if (data)
-				_mixer->playRaw(&_speechHandle, data, size, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, speechVol, speechPan);
+				_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_speechHandle, data, size, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, speechVol, speechPan);
 		}
 #ifdef USE_MAD
 		else if (_cowMode == CowMp3) {

Modified: scummvm/trunk/engines/sword2/animation.cpp
===================================================================
--- scummvm/trunk/engines/sword2/animation.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/sword2/animation.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -351,7 +351,7 @@
 			}
 
 			if (startNextText && !_mixer->isSoundHandleActive(_speechHandle)) {
-				_mixer->playRaw(&_speechHandle, t->speech, t->speechBufferSize, 22050, flags);
+				_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_speechHandle, t->speech, t->speechBufferSize, 22050, flags);
 				startNextText = false;
 			}
 

Modified: scummvm/trunk/engines/sword2/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sound.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/engines/sword2/sound.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -311,7 +311,7 @@
 	if (loop)
 		flags |= Audio::Mixer::FLAG_LOOP;
 
-	_vm->_mixer->playRaw(handle, data + stream.pos(), size, rate, flags, -1, vol, pan, 0, 0, soundType);
+	_vm->_mixer->playRaw(soundType, handle, data + stream.pos(), size, rate, flags, -1, vol, pan, 0, 0);
 	return RD_OK;
 }
 

Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/sound/mixer.cpp	2007-02-03 19:05:53 UTC (rev 25356)
@@ -114,8 +114,6 @@
 	for (i = 0; i < ARRAYSIZE(_volumeForSoundType); i++)
 		_volumeForSoundType[i] = kMaxMixerVolume;
 
-	_paused = false;
-
 	for (i = 0; i != NUM_CHANNELS; i++)
 		_channels[i] = 0;
 
@@ -133,10 +131,6 @@
 	return (uint)_syst->getOutputSampleRate();
 }
 
-bool Mixer::isPaused() {
-	return _paused;
-}
-
 void Mixer::setupPremix(AudioStream *stream, SoundType type) {
 	Common::StackLock lock(_mutex);
 
@@ -173,8 +167,13 @@
 	}
 }
 
-void Mixer::playRaw(SoundHandle *handle, void *sound, uint32 size, uint rate, byte flags,
-			int id, byte volume, int8 balance, uint32 loopStart, uint32 loopEnd, SoundType type) {
+void Mixer::playRaw(
+			SoundType type,
+			SoundHandle *handle,
+			void *sound,
+			uint32 size, uint rate, byte flags,
+			int id, byte volume, int8 balance,
+			uint32 loopStart, uint32 loopEnd) {
 	Common::StackLock lock(_mutex);
 
 	// Prevent duplicate sounds
@@ -207,8 +206,13 @@
 	insertChannel(handle, chan);
 }
 
-void Mixer::playInputStream(SoundType type, SoundHandle *handle, AudioStream *input,
-			int id, byte volume, int8 balance, bool autofreeStream, bool permanent) {
+void Mixer::playInputStream(
+			SoundType type,
+			SoundHandle *handle,
+			AudioStream *input,
+			int id, byte volume, int8 balance,
+			bool autofreeStream,
+			bool permanent) {
 	Common::StackLock lock(_mutex);
 
 	if (input == 0) {
@@ -242,20 +246,18 @@
 	//  zero the buf
 	memset(buf, 0, 2 * len * sizeof(int16));
 
-	if (!_paused) {
-		if (_premixChannel)
-			_premixChannel->mix(buf, len);
+	if (_premixChannel)
+		_premixChannel->mix(buf, len);
 
-		// now mix all channels
-		for (int i = 0; i != NUM_CHANNELS; i++)
-			if (_channels[i]) {
-				if (_channels[i]->isFinished()) {
-					delete _channels[i];
-					_channels[i] = 0;
-				} else if (!_channels[i]->isPaused())
-					_channels[i]->mix(buf, len);
-			}
-	}
+	// now mix all channels
+	for (int i = 0; i != NUM_CHANNELS; i++)
+		if (_channels[i]) {
+			if (_channels[i]->isFinished()) {
+				delete _channels[i];
+				_channels[i] = 0;
+			} else if (!_channels[i]->isPaused())
+				_channels[i]->mix(buf, len);
+		}
 }
 
 void Mixer::mixCallback(void *s, byte *samples, int len) {
@@ -319,14 +321,6 @@
 	_channels[index]->setBalance(balance);
 }
 
-uint32 Mixer::getSoundElapsedTimeOfSoundID(int id) {
-	Common::StackLock lock(_mutex);
-	for (int i = 0; i != NUM_CHANNELS; i++)
-		if (_channels[i] && _channels[i]->getId() == id)
-			return _channels[i]->getElapsedTime();
-	return 0;
-}
-
 uint32 Mixer::getSoundElapsedTime(SoundHandle handle) {
 	Common::StackLock lock(_mutex);
 
@@ -338,7 +332,12 @@
 }
 
 void Mixer::pauseAll(bool paused) {
-	_paused = paused;
+	Common::StackLock lock(_mutex);
+	for (int i = 0; i != NUM_CHANNELS; i++) {
+		if (_channels[i] != 0) {
+			_channels[i]->pause(paused);
+		}
+	}
 }
 
 void Mixer::pauseID(int id, bool paused) {
@@ -354,7 +353,7 @@
 void Mixer::pauseHandle(SoundHandle handle, bool paused) {
 	Common::StackLock lock(_mutex);
 
-	// Simply ignore pause/unpause requests for handles of sound that alreayd terminated
+	// 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)
 		return;

Modified: scummvm/trunk/sound/mixer.h
===================================================================
--- scummvm/trunk/sound/mixer.h	2007-02-03 19:04:24 UTC (rev 25355)
+++ scummvm/trunk/sound/mixer.h	2007-02-03 19:05:53 UTC (rev 25356)
@@ -38,6 +38,12 @@
 class Channel;
 class Mixer;
 
+/**
+ * A SoundHandle instances corresponds to a specific sound
+ * being played via the mixer. It can be used to control that
+ * sound (pause it, stop it, etc.).
+ * @see The Mixer class
+ */
 class SoundHandle {
 	friend class Channel;
 	friend class Mixer;
@@ -46,6 +52,10 @@
 	inline SoundHandle() : _val(0xFFFFFFFF) {}
 };
 
+/**
+ * The main audio mixer handles mixing of an arbitrary number of
+ * input audio streams (in the form of AudioStream instances).
+ */
 class Mixer {
 public:
 	enum {
@@ -96,8 +106,6 @@
 
 	int _volumeForSoundType[4];
 
-	bool _paused;
-
 	uint32 _handleSeed;
 	Channel *_channels[NUM_CHANNELS];
 
@@ -136,18 +144,38 @@
 	 * (using the makeLinearInputStream factory function), which is then
 	 * passed on to playInputStream.
 	 */
-	void playRaw(SoundHandle *handle,
-				void *sound, uint32 size, uint rate, byte flags,
-				int id = -1, byte volume = 255, int8 balance = 0,
-				uint32 loopStart = 0, uint32 loopEnd = 0,
-				SoundType type = kSFXSoundType);
+	void playRaw(
+		SoundType type,
+		SoundHandle *handle,
+		void *sound, uint32 size, uint rate, byte flags,
+		int id = -1, byte volume = 255, int8 balance = 0,
+		uint32 loopStart = 0, uint32 loopEnd = 0);
 
 	/**
 	 * Start playing the given audio input stream.
+	 *
+	 * Note that the sound id assigned below is unique. At most one stream
+	 * with a given idea can play at any given time. Trying to play a sound
+	 * with an id that is already in use causes the new sound to be not played.
+	 *
+	 * @param type	the type (voice/sfx/music) of the stream
+	 * @param handle	a SoundHandle which can be used to reference and control
+	 *                  the stream via suitable mixer methods
+	 * @param input	the actual AudioStream to be played
+	 * @param id	a unique id assigned to this stream
+	 * @param volume	the volume with which to play the sound, ranging from 0 to 255
+	 * @param balance	the balance with which to play the sound, ranging from -128 to 127
+	 * @param autofreeStream	a flag indicating whether the stream should be
+	 *                          freed after playback finished
+	 * @param permanent	a flag indicating whether a plain stopAll call should
+	 *                  not stop this particular stream
 	 */
-	void playInputStream(SoundType type, SoundHandle *handle, AudioStream *input,
-				int id = -1, byte volume = 255, int8 balance = 0,
-				bool autofreeStream = true, bool permanent = false);
+	void playInputStream(
+		SoundType type,
+		SoundHandle *handle,
+		AudioStream *input,
+		int id = -1, byte volume = 255, int8 balance = 0,
+		bool autofreeStream = true, bool permanent = false);
 
 
 
@@ -173,10 +201,10 @@
 
 
 	/**
-	 * Pause/unpause the mixer (this temporarily stops all audio processing,
-	 * including all regular channels and the premix channel).
+	 * Pause/unpause all sounds, including all regular channels and the
+	 * premix channel.
 	 *
-	 * @param paused true to pause the mixer, false to unpause it
+	 * @param paused true to pause everything, false to unpause
 	 */
 	void pauseAll(bool paused);
 
@@ -215,22 +243,15 @@
 	int getSoundID(SoundHandle handle);
 
 	/**
-	 * Check if a sound with the given hANDLE is active.
+	 * Check if a sound with the given handle is active.
 	 *
 	 * @param handle sound to query
 	 * @return true if the sound is active
 	 */
 	bool isSoundHandleActive(SoundHandle handle);
 
-	/**
-	 * Check if the mixer is paused (using pauseAll).
-	 *
-	 * @return true if the mixer is paused
-	 */
-	bool isPaused();
 
 
-
 	/**
 	 * Set the channel volume for the given handle.
 	 *
@@ -249,11 +270,6 @@
 	void setChannelBalance(SoundHandle handle, int8 balance);
 
 	/**
-	 * Get approximation of for how long the Sound ID has been playing.
-	 */
-	uint32 getSoundElapsedTimeOfSoundID(int id);
-
-	/**
 	 * Get approximation of for how long the channel has been playing.
 	 */
 	uint32 getSoundElapsedTime(SoundHandle handle);


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