aboutsummaryrefslogtreecommitdiff
path: root/engines/cine
diff options
context:
space:
mode:
authorGregory Montoir2007-12-08 15:24:42 +0000
committerGregory Montoir2007-12-08 15:24:42 +0000
commit6ef7e3748876e799cf37b8af15e95e5d3adce744 (patch)
treea022ab778187dc008909e38ca3320aab37096946 /engines/cine
parent9f43e2cf8a7c42db3521bfa408ddbf40cb03d845 (diff)
downloadscummvm-rg350-6ef7e3748876e799cf37b8af15e95e5d3adce744.tar.gz
scummvm-rg350-6ef7e3748876e799cf37b8af15e95e5d3adce744.tar.bz2
scummvm-rg350-6ef7e3748876e799cf37b8af15e95e5d3adce744.zip
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.
svn-id: r29766
Diffstat (limited to 'engines/cine')
-rw-r--r--engines/cine/script.cpp2
-rw-r--r--engines/cine/sound.cpp51
-rw-r--r--engines/cine/sound.h4
3 files changed, 28 insertions, 29 deletions
diff --git a/engines/cine/script.cpp b/engines/cine/script.cpp
index 7d6147d6af..813eb0c376 100644
--- a/engines/cine/script.cpp
+++ b/engines/cine/script.cpp
@@ -1434,8 +1434,6 @@ void o1_freePartRange() {
assert(startIdx + numIdx <= NUM_MAX_ANIMDATA);
- g_sound->stopMusic();
-
debugC(5, kCineDebugScript, "Line: %d: freePartRange(%d,%d)", _currentLine, startIdx, numIdx);
freeAnimDataRange(startIdx, numIdx);
}
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp
index 00b7d27663..1c7c6ff4f1 100644
--- a/engines/cine/sound.cpp
+++ b/engines/cine/sound.cpp
@@ -774,6 +774,10 @@ PaulaSound::PaulaSound(Audio::Mixer *mixer, CineEngine *vm)
}
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::loadMusic(const char *name) {
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::fadeOutMusic() {
}
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 @@ void PaulaSound::update() {
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
diff --git a/engines/cine/sound.h b/engines/cine/sound.h
index 719f37f151..81fe13112d 100644
--- a/engines/cine/sound.h
+++ b/engines/cine/sound.h
@@ -104,7 +104,7 @@ public:
struct SoundChannel {
int frequency;
- const uint8 *data;
+ uint8 *data;
int size;
int volumeStep;
int stepCount;
@@ -115,7 +115,7 @@ public:
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];