[Scummvm-cvs-logs] scummvm master -> 30005b450bc2b503dc7b43ea351e6e3621882f84

dreammaster dreammaster at scummvm.org
Thu Jul 28 12:47:14 CEST 2011


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
034bbde204 TSAGE: Fix problem with sound Fx start method being called multiple times
0034257976 TSAGE: Sound Fx is now playing
4778bf99eb TSAGE: Added sound debugger command
30005b450b TSAGE: Clarified some method names in the sound code


Commit: 034bbde2046ec2db0fdd746e032ca7f19f00f4fe
    https://github.com/scummvm/scummvm/commit/034bbde2046ec2db0fdd746e032ca7f19f00f4fe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2011-07-27T14:30:41-07:00

Commit Message:
TSAGE: Fix problem with sound Fx start method being called multiple times

Changed paths:
    engines/tsage/sound.cpp



diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp
index 3f02d63..87c31c3 100644
--- a/engines/tsage/sound.cpp
+++ b/engines/tsage/sound.cpp
@@ -2301,6 +2301,7 @@ void Sound::_soServiceTrackType1(int trackIndex, const byte *channelData) {
 						driver->proc32(channelData, 14, -1, vtStruct->_entries[entryIndex]._voiceNum, *(channelData + 1), 0x7f);
 						driver->proc42(vtStruct->_entries[entryIndex]._voiceNum, *(channelData + 1), _loop ? 1 : 0,
 							&v1, &v2);
+						_trkState[trackIndex] = 2;
 					}
 				} else {
 					for (uint entryIndex = 0; entryIndex < vtStruct->_entries.size(); ++entryIndex) {


Commit: 0034257976dc2ad5c91cb3825021681c4919811f
    https://github.com/scummvm/scummvm/commit/0034257976dc2ad5c91cb3825021681c4919811f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2011-07-27T14:30:42-07:00

Commit Message:
TSAGE: Sound Fx is now playing

Changed paths:
    engines/tsage/sound.cpp
    engines/tsage/sound.h



diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp
index 87c31c3..0e763cd 100644
--- a/engines/tsage/sound.cpp
+++ b/engines/tsage/sound.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "audio/decoders/raw.h"
 #include "common/config-manager.h"
 #include "tsage/core.h"
 #include "tsage/globals.h"
@@ -158,9 +159,7 @@ Common::List<SoundDriverEntry> &SoundManager::buildDriverList(bool detectFlag) {
 
 void SoundManager::installConfigDrivers() {
 	installDriver(ADLIB_DRIVER_NUM);
-#ifdef DEBUG
 	installDriver(SBLASTER_DRIVER_NUM);
-#endif
 }
 
 Common::List<SoundDriverEntry> &SoundManager::getDriverList(bool detectFlag) {
@@ -2801,6 +2800,7 @@ AdlibFxSoundDriver::AdlibFxSoundDriver(): SoundDriver() {
 
 	_mixer = _vm->_mixer;
 	_sampleRate = _mixer->getOutputRate();
+	_audioStream = NULL;
 //	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
 /*
 	Common::set_to(_channelVoiced, _channelVoiced + ADLIB_CHANNEL_COUNT, false);
@@ -2818,7 +2818,7 @@ AdlibFxSoundDriver::AdlibFxSoundDriver(): SoundDriver() {
 }
 
 AdlibFxSoundDriver::~AdlibFxSoundDriver() {
-//	_mixer->stopHandle(_soundHandle);
+	_mixer->stopHandle(_soundHandle);
 }
 
 bool AdlibFxSoundDriver::open() {
@@ -2878,14 +2878,28 @@ void AdlibFxSoundDriver::proc32(const byte *channelData, int dataOffset, int pro
 	_channelData = channelData + dataOffset;
 	_soundData = _channelData + 18;
 
+	// Make a copy of the buffer
+	int dataSize = _vm->_memoryManager.getSize(channelData);
+	byte *soundData = (byte *)malloc(dataSize - dataOffset);
+	Common::copy(_channelData, _channelData + (dataSize - dataOffset), soundData);
+
+	_audioStream = Audio::makeQueuingAudioStream(11025, false);
+	_audioStream->queueBuffer(soundData, dataSize - dataOffset, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
+
 	// Start the new sound
-	debug("Start sound");
+	if (!_mixer->isSoundHandleActive(_soundHandle))
+		_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _audioStream);
 }
 
 void AdlibFxSoundDriver::updateVoice(int channel) {
 	if (_channelData) {
 		write(208);
-
+/*
+		if (_audioStream && _audioStream->numQueuedStreams() != 0) {
+			_mixer->stopAll();
+			_audioStream = NULL;
+		}
+*/
 		_channelData = NULL;
 		_v45062 = 0;
 		_v45066 = 0;
@@ -2911,46 +2925,7 @@ void AdlibFxSoundDriver::proc42(int channel, int cmd, int value, int *v1, int *v
 }
 
 void AdlibFxSoundDriver::write(int v) {
-	/*
-	port[adlib_port + 12] = v;
-	for (int i = 0; i < 100; ++i) {
-		if (!port[adlib_port + 12] & 0x80)
-			break;
-	}
-	*/
-}
-
-void AdlibFxSoundDriver::flush() {
-	Common::StackLock slock(SoundManager::sfManager()._serverDisabledMutex);
-
-	// No data output yet
-}
-
-
-
-int AdlibFxSoundDriver::readBuffer(int16 *buffer, const int numSamples) {
-	update(buffer, numSamples);
-	return numSamples;
-}
-
-void AdlibFxSoundDriver::update(int16 *buf, int len) {
-/*
-	static int samplesLeft = 0;
-	while (len != 0) {
-		int count = samplesLeft;
-		if (count > len) {
-			count = len;
-		}
-		samplesLeft -= count;
-		len -= count;
-		YM3812UpdateOne(_opl, buf, count);
-		if (samplesLeft == 0) {
-			flush();
-			samplesLeft = _sampleRate / 50;
-		}
-		buf += count;
-	}
-*/
+	// No implementation
 }
 
 void AdlibFxSoundDriver::write209() {
diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h
index 923b3e0..b3403f2 100644
--- a/engines/tsage/sound.h
+++ b/engines/tsage/sound.h
@@ -459,12 +459,13 @@ public:
 	void update(int16 *buf, int len);
 };
 
-class AdlibFxSoundDriver: public SoundDriver, Audio::AudioStream {
+class AdlibFxSoundDriver: public SoundDriver {
 private:
 	Common::Queue<RegisterValue> _queue;
 	GroupData _groupData;
 	Audio::Mixer *_mixer;
 	Audio::SoundHandle _soundHandle;
+	Audio::QueuingAudioStream *_audioStream;
 	int _sampleRate;
 
 	int _v45062;
@@ -497,14 +498,6 @@ public:
 	virtual void updateVoice(int channel);
 	virtual void proc38(int channel, int cmd, int value);
 	virtual void proc42(int channel, int cmd, int value, int *v1, int *v2);
-
-	// AudioStream interface
-	virtual int readBuffer(int16 *buffer, const int numSamples);
-	virtual bool isStereo() const { return false; }
-	virtual bool endOfData() const { return false; }
-	virtual int getRate() const { return _sampleRate; }
-
-	void update(int16 *buf, int len);
 };
 
 


Commit: 4778bf99eb358df0ba315ac95df3a422c6a94604
    https://github.com/scummvm/scummvm/commit/4778bf99eb358df0ba315ac95df3a422c6a94604
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2011-07-27T14:30:42-07:00

Commit Message:
TSAGE: Added sound debugger command

Changed paths:
    engines/tsage/debugger.cpp
    engines/tsage/debugger.h



diff --git a/engines/tsage/debugger.cpp b/engines/tsage/debugger.cpp
index 9277fd4..00cd61a 100644
--- a/engines/tsage/debugger.cpp
+++ b/engines/tsage/debugger.cpp
@@ -38,6 +38,7 @@ Debugger::Debugger() : GUI::Debugger() {
 	DCmd_Register("listobjects",	WRAP_METHOD(Debugger, Cmd_ListObjects));
 	DCmd_Register("moveobject",		WRAP_METHOD(Debugger, Cmd_MoveObject));
 	DCmd_Register("hotspots",		WRAP_METHOD(Debugger, Cmd_Hotspots));
+	DCmd_Register("sound",			WRAP_METHOD(Debugger, Cmd_Sound));
 }
 
 static int strToInt(const char *s) {
@@ -434,5 +435,18 @@ bool Debugger::Cmd_Hotspots(int argc, const char **argv) {
 	return false;
 }
 
+/**
+ * Play the specified sound
+ */
+bool Debugger::Cmd_Sound(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Usage: %s <sound number>\n", argv[0]);
+		return true;
+	}
+
+	int soundNum = strToInt(argv[1]);
+	_globals->_soundHandler.play(soundNum);
+	return false;
+}
 
 } // End of namespace tSage
diff --git a/engines/tsage/debugger.h b/engines/tsage/debugger.h
index 3c14cd7..44fd61e 100644
--- a/engines/tsage/debugger.h
+++ b/engines/tsage/debugger.h
@@ -42,8 +42,8 @@ protected:
 	bool Cmd_ClearFlag(int argc, const char **argv);
 	bool Cmd_ListObjects(int argc, const char **argv);
 	bool Cmd_MoveObject(int argc, const char **argv);
-
 	bool Cmd_Hotspots(int argc, const char **argv);
+	bool Cmd_Sound(int argc, const char **argv);
 };
 
 } // End of namespace tSage


Commit: 30005b450bc2b503dc7b43ea351e6e3621882f84
    https://github.com/scummvm/scummvm/commit/30005b450bc2b503dc7b43ea351e6e3621882f84
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2011-07-28T03:42:29-07:00

Commit Message:
TSAGE: Clarified some method names in the sound code

Changed paths:
    engines/tsage/sound.cpp
    engines/tsage/sound.h



diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp
index 0e763cd..3d725a4 100644
--- a/engines/tsage/sound.cpp
+++ b/engines/tsage/sound.cpp
@@ -1969,9 +1969,9 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) {
 				if (channelNum != -1) {
 					if (voiceType != VOICETYPE_0) {
 						if (chFlags & 0x10)
-							_soProc42(vtStruct, channelData, channelNum, chVoiceType, v);
+							_soPlaySound2(vtStruct, channelData, channelNum, chVoiceType, v);
 						else
-							_soProc32(vtStruct, channelData, channelNum, chVoiceType, v, b);
+							_soPlaySound(vtStruct, channelData, channelNum, chVoiceType, v, b);
 					} else if (voiceNum != -1) {
 						assert(driver);
 						driver->proc20(voiceNum, chVoiceType);
@@ -2139,7 +2139,7 @@ void Sound::_soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceTyp
 	}
 }
 
-void Sound::_soProc32(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1) {
+void Sound::_soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1) {
 	int entryIndex = _soFindSound(vtStruct, channelNum);
 	if (entryIndex != -1) {
 		SoundDriver *driver = vtStruct->_entries[entryIndex]._driver;
@@ -2149,11 +2149,11 @@ void Sound::_soProc32(VoiceTypeStruct *vtStruct, const byte *channelData, int ch
 		vtStruct->_entries[entryIndex]._type1._field4 = v0;
 		vtStruct->_entries[entryIndex]._type1._field5 = 0;
 
-		driver->proc32(channelData, 0, _chProgram[channelNum], vtStruct->_entries[entryIndex]._voiceNum, v0, v1);
+		driver->playSound(channelData, 0, _chProgram[channelNum], vtStruct->_entries[entryIndex]._voiceNum, v0, v1);
 	}
 }
 
-void Sound::_soProc42(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0) {
+void Sound::_soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0) {
 	for (int trackCtr = 0; trackCtr < _trackInfo._numTracks; ++trackCtr) {
 		const byte *instrument = _channelData[trackCtr];
 		if ((*(instrument + 13) == v0) && (*instrument == 1)) {
@@ -2168,7 +2168,7 @@ void Sound::_soProc42(VoiceTypeStruct *vtStruct, const byte *channelData, int ch
 				vtStruct->_entries[entryIndex]._type1._field5 = 0;
 
 				int v1, v2;
-				driver->proc32(channelData, 14, -1, vtStruct->_entries[entryIndex]._voiceNum, v0, 0x7F);
+				driver->playSound(channelData, 14, -1, vtStruct->_entries[entryIndex]._voiceNum, v0, 0x7F);
 				driver->proc42(vtStruct->_entries[entryIndex]._voiceNum, voiceType, 0, &v1, &v2);
 			}
 			break;
@@ -2297,7 +2297,7 @@ void Sound::_soServiceTrackType1(int trackIndex, const byte *channelData) {
 						vtStruct->_entries[entryIndex]._type1._field5 = 0;
 
 						int v1, v2;
-						driver->proc32(channelData, 14, -1, vtStruct->_entries[entryIndex]._voiceNum, *(channelData + 1), 0x7f);
+						driver->playSound(channelData, 14, -1, vtStruct->_entries[entryIndex]._voiceNum, *(channelData + 1), 0x7f);
 						driver->proc42(vtStruct->_entries[entryIndex]._voiceNum, *(channelData + 1), _loop ? 1 : 0,
 							&v1, &v2);
 						_trkState[trackIndex] = 2;
@@ -2309,9 +2309,9 @@ void Sound::_soServiceTrackType1(int trackIndex, const byte *channelData) {
 						if ((vse._sound == this) && (vse._channelNum == channel) && (vse._field4 == vtStruct->_total)) {
 							SoundDriver *driver = vte._driver;
 
-							int v1, v2;
-							driver->proc42(vte._voiceNum, vtStruct->_total, _loop ? 1 : 0, &v1, &v2);
-							if (v2) {
+							int v1, isEnded;
+							driver->proc42(vte._voiceNum, vtStruct->_total, _loop ? 1 : 0, &v1, &isEnded);
+							if (isEnded) {
 								_trkState[trackIndex] = 0;
 							} else if (vtStruct->_total) {
 								_timer = 0;
@@ -2566,7 +2566,7 @@ int AdlibSoundDriver::setMasterVolume(int volume) {
 	return oldVolume;
 }
 
-void AdlibSoundDriver::proc32(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {
+void AdlibSoundDriver::playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {
 	if (program == -1)
 		return;
 
@@ -2866,7 +2866,7 @@ int AdlibFxSoundDriver::setMasterVolume(int volume) {
 	return oldVolume;
 }
 
-void AdlibFxSoundDriver::proc32(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {
+void AdlibFxSoundDriver::playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {
 	if (program != -1)
 		return;
 
@@ -2892,19 +2892,7 @@ void AdlibFxSoundDriver::proc32(const byte *channelData, int dataOffset, int pro
 }
 
 void AdlibFxSoundDriver::updateVoice(int channel) {
-	if (_channelData) {
-		write(208);
-/*
-		if (_audioStream && _audioStream->numQueuedStreams() != 0) {
-			_mixer->stopAll();
-			_audioStream = NULL;
-		}
-*/
-		_channelData = NULL;
-		_v45062 = 0;
-		_v45066 = 0;
-		_v45068 = 0;
-	}
+	// No implementation
 }
 
 void AdlibFxSoundDriver::proc38(int channel, int cmd, int value) {
@@ -2920,7 +2908,17 @@ void AdlibFxSoundDriver::proc42(int channel, int cmd, int value, int *v1, int *v
 	*v2 = 0;
 	_v4506B = 0;
 
+	// Note: Checking whether a playing Fx sound had finished was originally done in another
+	// method in the sample playing code. But since we're using the ScummVM audio soundsystem,
+	// it's easier simply to do the check right here
+	if (_audioStream && _audioStream->endOfStream()) {
+		delete _audioStream;
+		_audioStream = NULL;
+		_channelData = NULL;
+	}
+
 	if (!_channelData)
+		// Flag that sound isn't playing
 		*v2 = 1;
 }
 
diff --git a/engines/tsage/sound.h b/engines/tsage/sound.h
index b3403f2..244b4dd 100644
--- a/engines/tsage/sound.h
+++ b/engines/tsage/sound.h
@@ -108,7 +108,7 @@ public:
 	virtual void setProgram(int channel, int program) {}			// Method #13
 	virtual void setVolume1(int channel, int v2, int v3, int volume) {}
 	virtual void setPitchBlend(int channel, int pitchBlend) {}		// Method #15
-	virtual void proc32(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {}// Method #16
+	virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {}// Method #16
 	virtual void updateVoice(int channel) {}						// Method #17
 	virtual void proc36() {}										// Method #18
 	virtual void proc38(int channel, int cmd, int value) {}			// Method #19
@@ -349,8 +349,8 @@ public:
 	void _soRemoteReceive();
 	void _soServiceTrackType0(int trackIndex, const byte *channelData);
 	void _soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceType mode, int v0);
-	void _soProc32(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1);
-	void _soProc42(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0);
+	void _soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1);
+	void _soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0);
 	void _soProc38(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int cmd, int value);
 	void _soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend);
 	void _soDoTrackCommand(int channelNum, int command, int value);
@@ -445,7 +445,7 @@ public:
 	virtual const GroupData *getGroupData();
 	virtual void installPatch(const byte *data, int size);
 	virtual int setMasterVolume(int volume);
-	virtual void proc32(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1);
+	virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1);
 	virtual void updateVoice(int channel);
 	virtual void proc38(int channel, int cmd, int value);
 	virtual void setPitch(int channel, int pitchBlend);
@@ -494,7 +494,7 @@ public:
 	virtual const GroupData *getGroupData();
 	virtual void poll();
 	virtual int setMasterVolume(int volume);
-	virtual void proc32(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1);
+	virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1);
 	virtual void updateVoice(int channel);
 	virtual void proc38(int channel, int cmd, int value);
 	virtual void proc42(int channel, int cmd, int value, int *v1, int *v2);






More information about the Scummvm-git-logs mailing list