[Scummvm-cvs-logs] SF.net SVN: scummvm: [29766] scummvm/trunk/engines/cine

cyx at users.sourceforge.net cyx at users.sourceforge.net
Sat Dec 8 16:24:44 CET 2007


Revision: 29766
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29766&view=rev
Author:   cyx
Date:     2007-12-08 07:24:42 -0800 (Sat, 08 Dec 2007)

Log Message:
-----------
reverted parts of commits #29447 and #29446 (caused regressions in ADL music playback) and properly (I hope) fixed the sound issues described in tracker item #1763053.

Modified Paths:
--------------
    scummvm/trunk/engines/cine/script.cpp
    scummvm/trunk/engines/cine/sound.cpp
    scummvm/trunk/engines/cine/sound.h

Modified: scummvm/trunk/engines/cine/script.cpp
===================================================================
--- scummvm/trunk/engines/cine/script.cpp	2007-12-08 15:11:20 UTC (rev 29765)
+++ scummvm/trunk/engines/cine/script.cpp	2007-12-08 15:24:42 UTC (rev 29766)
@@ -1434,8 +1434,6 @@
 
 	assert(startIdx + numIdx <= NUM_MAX_ANIMDATA);
 
-	g_sound->stopMusic();
-
 	debugC(5, kCineDebugScript, "Line: %d: freePartRange(%d,%d)", _currentLine, startIdx, numIdx);
 	freeAnimDataRange(startIdx, numIdx);
 }

Modified: scummvm/trunk/engines/cine/sound.cpp
===================================================================
--- scummvm/trunk/engines/cine/sound.cpp	2007-12-08 15:11:20 UTC (rev 29765)
+++ scummvm/trunk/engines/cine/sound.cpp	2007-12-08 15:24:42 UTC (rev 29766)
@@ -774,6 +774,10 @@
 }
 
 PaulaSound::~PaulaSound() {
+	for (int i = 0; i < NUM_CHANNELS; ++i) {
+		stopSound(i);
+	}
+	stopMusic();
 }
 
 void PaulaSound::loadMusic(const char *name) {
@@ -798,17 +802,12 @@
 void PaulaSound::playMusic() {
 	_mixer->stopHandle(_moduleHandle);
 	if (_moduleStream) {
-		_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_moduleHandle, _moduleStream, -1, 255, 0, false);
+		_mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_moduleHandle, _moduleStream);
 	}
 }
 
 void PaulaSound::stopMusic() {
 	_mixer->stopHandle(_moduleHandle);
-
-	_mixer->pauseAll(true);
-
-	for(int i = 0;i < NUM_CHANNELS;i++)
-		_soundChannelsTable[i].data = 0;
 }
 
 void PaulaSound::fadeOutMusic() {
@@ -817,19 +816,28 @@
 }
 
 void PaulaSound::playSound(int channel, int frequency, const uint8 *data, int size, int volumeStep, int stepCount, int volume, int repeat) {
+	stopSound(channel);
 	SoundChannel *ch = &_soundChannelsTable[channel];
-	ch->frequency = frequency;
-	ch->data = data;
-	ch->size = size;
-	ch->volumeStep = volumeStep;
-	ch->stepCount = stepCount;
-	ch->step = stepCount;
-	ch->repeat = repeat != 0;
-	ch->volume = volume;
+	size = MIN<int>(size - SPL_HDR_SIZE, READ_BE_UINT16(data + 4));
+	if (size > 0) {
+		ch->data = (byte *)malloc(size);
+		if (ch->data) {
+			memcpy(ch->data, data + SPL_HDR_SIZE, size);
+			ch->frequency = frequency;
+			ch->size = size;
+			ch->volumeStep = volumeStep;
+			ch->stepCount = stepCount;
+			ch->step = stepCount;
+			ch->repeat = repeat != 0;
+			ch->volume = volume;
+		}
+	}
 }
 
 void PaulaSound::stopSound(int channel) {
 	_mixer->stopHandle(_channelsTable[channel]);
+	free(_soundChannelsTable[channel].data);
+	_soundChannelsTable[channel].data = 0;
 }
 
 void PaulaSound::update() {
@@ -844,23 +852,16 @@
 			ch->step = ch->stepCount;
 			ch->volume = CLIP(ch->volume + ch->volumeStep, 0, 63);
 			playSoundChannel(i, ch->frequency, ch->data, ch->size, ch->volume);
-			if (!ch->repeat) {
-				ch->data = 0;
-			}
+			ch->data = 0;
 		}
 	}
 }
 
-void PaulaSound::playSoundChannel(int channel, int frequency, const uint8 *data, int size, int volume) {
-	stopSound(channel);
+void PaulaSound::playSoundChannel(int channel, int frequency, uint8 *data, int size, int volume) {
 	assert(frequency > 0);
 	frequency = PAULA_FREQ / frequency;
-	size = MIN<int>(size - SPL_HDR_SIZE, READ_BE_UINT16(data + 4));
-	data += SPL_HDR_SIZE;
-	if (size > 0) {
-		_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], const_cast<byte *>(data), size, frequency, 0);
-		_mixer->setChannelVolume(_channelsTable[channel], volume * Audio::Mixer::kMaxChannelVolume / 63);
-	}
+	_mixer->playRaw(Audio::Mixer::kSFXSoundType, &_channelsTable[channel], data, size, frequency, 0);
+	_mixer->setChannelVolume(_channelsTable[channel], volume * Audio::Mixer::kMaxChannelVolume / 63);
 }
 
 } // End of namespace Cine

Modified: scummvm/trunk/engines/cine/sound.h
===================================================================
--- scummvm/trunk/engines/cine/sound.h	2007-12-08 15:11:20 UTC (rev 29765)
+++ scummvm/trunk/engines/cine/sound.h	2007-12-08 15:24:42 UTC (rev 29766)
@@ -104,7 +104,7 @@
 
 	struct SoundChannel {
 		int frequency;
-		const uint8 *data;
+		uint8 *data;
 		int size;
 		int volumeStep;
 		int stepCount;
@@ -115,7 +115,7 @@
 
 protected:
 
-	void playSoundChannel(int channel, int frequency, const uint8 *data, int size, int volume);
+	void playSoundChannel(int channel, int frequency, uint8 *data, int size, int volume);
 
 	Audio::SoundHandle _channelsTable[NUM_CHANNELS];
 	SoundChannel _soundChannelsTable[NUM_CHANNELS];


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