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

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Thu Jun 10 22:27:00 CEST 2010


Revision: 49583
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49583&view=rev
Author:   mthreepwood
Date:     2010-06-10 20:26:59 +0000 (Thu, 10 Jun 2010)

Log Message:
-----------
kSciAudioWPlay should not actually play the song, but 'pre-load' it. We fake the pre-loading with a flag that will return 0 if the song has been called with kSciAudioWPlay. Fixes the dream sequence sound in MUMG.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/ksound.cpp
    scummvm/trunk/engines/sci/sound/audio.cpp
    scummvm/trunk/engines/sci/sound/audio.h

Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp	2010-06-10 18:16:05 UTC (rev 49582)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp	2010-06-10 20:26:59 UTC (rev 49583)
@@ -44,7 +44,6 @@
 
 reg_t kDoCdAudio(EngineState *s, int argc, reg_t *argv) {
 	switch (argv[0].toUint16()) {
-	case kSciAudioWPlay:
 	case kSciAudioPlay: {
 		if (argc < 2)
 			return NULL_REG;
@@ -72,6 +71,7 @@
 		break;
 	case kSciAudioPosition:
 		return make_reg(0, g_sci->_audio->audioCdPosition());
+	case kSciAudioWPlay: // CD Audio can't be preloaded
 	case kSciAudioRate: // No need to set the audio rate
 	case kSciAudioVolume: // The speech setting isn't used by CD Audio
 	case kSciAudioLanguage: // No need to set the language
@@ -119,7 +119,11 @@
 			return NULL_REG;
 		}
 
-		return make_reg(0, g_sci->_audio->startAudio(module, number)); // return sample length in ticks
+		// return sample length in ticks
+		if (argv[0].toUint16() == kSciAudioWPlay)
+			return make_reg(0, g_sci->_audio->wPlayAudio(module, number));
+		else
+			return make_reg(0, g_sci->_audio->startAudio(module, number));
 	}
 	case kSciAudioStop:
 		g_sci->_audio->stopAudio();

Modified: scummvm/trunk/engines/sci/sound/audio.cpp
===================================================================
--- scummvm/trunk/engines/sci/sound/audio.cpp	2010-06-10 18:16:05 UTC (rev 49582)
+++ scummvm/trunk/engines/sci/sound/audio.cpp	2010-06-10 20:26:59 UTC (rev 49583)
@@ -47,6 +47,7 @@
 		_syncResource(NULL), _syncOffset(0), _audioCdStart(0) {
 
 	_mixer = g_system->getMixer();
+	_wPlayFlag = false;
 }
 
 AudioPlayer::~AudioPlayer() {
@@ -65,6 +66,7 @@
 	Audio::AudioStream *audioStream = getAudioStream(number, module, &sampleLen);
 
 	if (audioStream) {
+		_wPlayFlag = false;
 		_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_audioHandle, audioStream);
 		return sampleLen;
 	}
@@ -72,6 +74,18 @@
 	return 0;
 }
 
+int AudioPlayer::wPlayAudio(uint16 module, uint32 tuple) {
+	// Get the audio sample length and set the wPlay flag so we return 0 on position.
+	// SSCI pre-loads the audio here, but it's much easier for us to just get the
+	// sample length and return that. wPlayAudio should *not* actually start the sample.
+
+	int sampleLen = 0;
+	Audio::AudioStream *audioStream = getAudioStream(module, tuple, &sampleLen);
+	delete audioStream;
+	_wPlayFlag = true;
+	return sampleLen;
+}
+
 void AudioPlayer::stopAudio() {
 	_mixer->stopHandle(_audioHandle);
 }
@@ -87,6 +101,8 @@
 int AudioPlayer::getAudioPosition() {
 	if (_mixer->isSoundHandleActive(_audioHandle))
 		return _mixer->getSoundElapsedTime(_audioHandle) * 6 / 100; // return elapsed time in ticks
+	else if (_wPlayFlag)
+		return 0; // Sound has "loaded" so return that it hasn't started
 	else
 		return -1; // Sound finished
 }

Modified: scummvm/trunk/engines/sci/sound/audio.h
===================================================================
--- scummvm/trunk/engines/sci/sound/audio.h	2010-06-10 18:16:05 UTC (rev 49582)
+++ scummvm/trunk/engines/sci/sound/audio.h	2010-06-10 20:26:59 UTC (rev 49583)
@@ -33,8 +33,7 @@
 namespace Sci {
 
 enum AudioCommands {
-	// TODO: find the difference between kSci1AudioWPlay and kSci1AudioPlay
-	kSciAudioWPlay = 1, /* Plays an audio stream */
+	kSciAudioWPlay = 1, /* Loads an audio stream */
 	kSciAudioPlay = 2, /* Plays an audio stream */
 	kSciAudioStop = 3, /* Stops an audio stream */
 	kSciAudioPause = 4, /* Pauses an audio stream */
@@ -69,6 +68,7 @@
 	Audio::RewindableAudioStream *getAudioStream(uint32 number, uint32 volume, int *sampleLen);
 	int getAudioPosition();
 	int startAudio(uint16 module, uint32 tuple);
+	int wPlayAudio(uint16 module, uint32 tuple);
 	void stopAudio();
 	void pauseAudio();
 	void resumeAudio();
@@ -92,6 +92,7 @@
 	Resource *_syncResource; /**< Used by kDoSync for speech syncing in CD talkie games */
 	uint _syncOffset;
 	uint32 _audioCdStart;
+	bool _wPlayFlag;
 };
 
 } // End of namespace Sci


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