aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-05-22 01:19:00 +0200
committerEugene Sandulenko2016-05-22 01:19:00 +0200
commit377a6115d1f1a1adc5e469bb00c66239f614cea6 (patch)
treefe827711495a51f7751ae6459e9436c81fda03fc
parentad04376054f9734d81099b36b013478498364cb3 (diff)
parent3ad6af92f20b98b3c7a5045fe8e55045cff9caf1 (diff)
downloadscummvm-rg350-377a6115d1f1a1adc5e469bb00c66239f614cea6.tar.gz
scummvm-rg350-377a6115d1f1a1adc5e469bb00c66239f614cea6.tar.bz2
scummvm-rg350-377a6115d1f1a1adc5e469bb00c66239f614cea6.zip
Merge pull request #760 from salty-horse/scumm_audio
SCUMM: Reduce audio header dependencies
-rw-r--r--engines/scumm/he/sound_he.cpp2
-rw-r--r--engines/scumm/he/sound_he.h2
-rw-r--r--engines/scumm/input.cpp1
-rw-r--r--engines/scumm/smush/smush_player.cpp32
-rw-r--r--engines/scumm/smush/smush_player.h6
-rw-r--r--engines/scumm/sound.cpp21
-rw-r--r--engines/scumm/sound.h10
-rw-r--r--engines/scumm/string.cpp3
8 files changed, 49 insertions, 28 deletions
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 2e0a03af7f..8670116c68 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -51,10 +51,12 @@ SoundHE::SoundHE(ScummEngine *parent, Audio::Mixer *mixer)
_heMusicTracks(0) {
memset(_heChannel, 0, sizeof(_heChannel));
+ _heSoundChannels = new Audio::SoundHandle[8]();
}
SoundHE::~SoundHE() {
free(_heMusic);
+ delete[] _heSoundChannels;
}
void SoundHE::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
diff --git a/engines/scumm/he/sound_he.h b/engines/scumm/he/sound_he.h
index 323858a7c9..e0324d0753 100644
--- a/engines/scumm/he/sound_he.h
+++ b/engines/scumm/he/sound_he.h
@@ -44,7 +44,7 @@ protected:
HEMusic *_heMusic;
int16 _heMusicTracks;
- Audio::SoundHandle _heSoundChannels[8];
+ Audio::SoundHandle *_heSoundChannels;
public: // Used by createSound()
struct {
diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp
index 12047635a0..6ef7e4d7f4 100644
--- a/engines/scumm/input.cpp
+++ b/engines/scumm/input.cpp
@@ -24,6 +24,7 @@
#include "common/events.h"
#include "common/system.h"
#include "common/translation.h"
+#include "audio/mixer.h"
#include "scumm/debugger.h"
#include "scumm/dialogs.h"
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index 2ca2579b54..42ee0115c7 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -25,6 +25,8 @@
#include "common/system.h"
#include "common/util.h"
+#include "audio/mixer.h"
+
#include "graphics/cursorman.h"
#include "graphics/palette.h"
@@ -242,9 +244,15 @@ SmushPlayer::SmushPlayer(ScummEngine_v7 *scumm) {
_paused = false;
_pauseStartTime = 0;
_pauseTime = 0;
+
+
+ _IACTchannel = new Audio::SoundHandle();
+ _compressedFileSoundHandle = new Audio::SoundHandle();
}
SmushPlayer::~SmushPlayer() {
+ delete _IACTchannel;
+ delete _compressedFileSoundHandle;
}
void SmushPlayer::init(int32 speed) {
@@ -271,8 +279,8 @@ void SmushPlayer::init(int32 speed) {
vs->pitch = vs->w;
_vm->_gdi->_numStrips = vs->w / 8;
- _vm->_mixer->stopHandle(_compressedFileSoundHandle);
- _vm->_mixer->stopHandle(_IACTchannel);
+ _vm->_mixer->stopHandle(*_compressedFileSoundHandle);
+ _vm->_mixer->stopHandle(*_IACTchannel);
_IACTpos = 0;
_vm->_smixer->stop();
}
@@ -470,7 +478,7 @@ void SmushPlayer::handleIACT(int32 subSize, Common::SeekableReadStream &b) {
if (!_IACTstream) {
_IACTstream = Audio::makeQueuingAudioStream(22050, true);
- _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_IACTchannel, _IACTstream);
+ _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, _IACTchannel, _IACTstream);
}
_IACTstream->queueBuffer(output_data, 0x1000, DisposeAfterUse::YES, Audio::FLAG_STEREO | Audio::FLAG_16BITS);
@@ -1091,7 +1099,7 @@ void SmushPlayer::seekSan(const char *file, int32 pos, int32 contFrame) {
}
void SmushPlayer::tryCmpFile(const char *filename) {
- _vm->_mixer->stopHandle(_compressedFileSoundHandle);
+ _vm->_mixer->stopHandle(*_compressedFileSoundHandle);
_compressedFileMode = false;
const char *i = strrchr(filename, '.');
@@ -1110,7 +1118,7 @@ void SmushPlayer::tryCmpFile(const char *filename) {
strcpy(fname + (i - filename), ".ogg");
if (file->open(fname)) {
_compressedFileMode = true;
- _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeVorbisStream(file, DisposeAfterUse::YES));
+ _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, _compressedFileSoundHandle, Audio::makeVorbisStream(file, DisposeAfterUse::YES));
return;
}
#endif
@@ -1119,7 +1127,7 @@ void SmushPlayer::tryCmpFile(const char *filename) {
strcpy(fname + (i - filename), ".mp3");
if (file->open(fname)) {
_compressedFileMode = true;
- _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_compressedFileSoundHandle, Audio::makeMP3Stream(file, DisposeAfterUse::YES));
+ _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, _compressedFileSoundHandle, Audio::makeMP3Stream(file, DisposeAfterUse::YES));
return;
}
#endif
@@ -1185,12 +1193,12 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st
// the sound. Synt to time instead.
now = _vm->_system->getMillis() - _pauseTime;
elapsed = now - _startTime;
- } else if (_vm->_mixer->isSoundHandleActive(_compressedFileSoundHandle)) {
+ } else if (_vm->_mixer->isSoundHandleActive(*_compressedFileSoundHandle)) {
// Compressed SMUSH files.
- elapsed = _vm->_mixer->getSoundElapsedTime(_compressedFileSoundHandle);
- } else if (_vm->_mixer->isSoundHandleActive(_IACTchannel)) {
+ elapsed = _vm->_mixer->getSoundElapsedTime(*_compressedFileSoundHandle);
+ } else if (_vm->_mixer->isSoundHandleActive(*_IACTchannel)) {
// Curse of Monkey Island SMUSH files.
- elapsed = _vm->_mixer->getSoundElapsedTime(_IACTchannel);
+ elapsed = _vm->_mixer->getSoundElapsedTime(*_IACTchannel);
} else {
// For other SMUSH files, we don't necessarily have any
// one channel to sync against, so we have to use
@@ -1245,8 +1253,8 @@ void SmushPlayer::play(const char *filename, int32 speed, int32 offset, int32 st
break;
if (_vm->shouldQuit() || _vm->_saveLoadFlag || _vm->_smushVideoShouldFinish) {
_smixer->stop();
- _vm->_mixer->stopHandle(_compressedFileSoundHandle);
- _vm->_mixer->stopHandle(_IACTchannel);
+ _vm->_mixer->stopHandle(*_compressedFileSoundHandle);
+ _vm->_mixer->stopHandle(*_IACTchannel);
_IACTpos = 0;
break;
}
diff --git a/engines/scumm/smush/smush_player.h b/engines/scumm/smush/smush_player.h
index b0d6e6a9f0..f1dffef7c7 100644
--- a/engines/scumm/smush/smush_player.h
+++ b/engines/scumm/smush/smush_player.h
@@ -24,9 +24,9 @@
#define SCUMM_SMUSH_PLAYER_H
#include "common/util.h"
-#include "scumm/sound.h"
namespace Audio {
+class SoundHandle;
class QueuingAudioStream;
}
@@ -65,10 +65,10 @@ private:
bool _skipNext;
uint32 _frame;
- Audio::SoundHandle _IACTchannel;
+ Audio::SoundHandle *_IACTchannel;
Audio::QueuingAudioStream *_IACTstream;
- Audio::SoundHandle _compressedFileSoundHandle;
+ Audio::SoundHandle *_compressedFileSoundHandle;
bool _compressedFileMode;
byte _IACToutput[4096];
int32 _IACTpos;
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index f66452e99c..33b7c3108d 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -97,12 +97,17 @@ Sound::Sound(ScummEngine *parent, Audio::Mixer *mixer)
_loomSteamCD.balance = 0;
_isLoomSteam = _vm->_game.id == GID_LOOM && Common::File::exists("CDDA.SOU");
+
+ _loomSteamCDAudioHandle = new Audio::SoundHandle();
+ _talkChannelHandle = new Audio::SoundHandle();
}
Sound::~Sound() {
stopCDTimer();
stopCD();
free(_offsetTable);
+ delete _loomSteamCDAudioHandle;
+ delete _talkChannelHandle;
}
void Sound::addSoundToQueue(int sound, int heOffset, int heChannel, int heFlags) {
@@ -425,7 +430,7 @@ void Sound::processSfxQueues() {
if (_talk_sound_mode & 1)
startTalkSound(_talk_sound_a1, _talk_sound_b1, 1);
if (_talk_sound_mode & 2)
- startTalkSound(_talk_sound_a2, _talk_sound_b2, 2, &_talkChannelHandle);
+ startTalkSound(_talk_sound_a2, _talk_sound_b2, 2, _talkChannelHandle);
_talk_sound_mode = 0;
}
@@ -439,7 +444,7 @@ void Sound::processSfxQueues() {
} else if (_vm->_game.heversion >= 60) {
finished = !isSoundRunning(1);
} else {
- finished = !_mixer->isSoundHandleActive(_talkChannelHandle);
+ finished = !_mixer->isSoundHandleActive(*_talkChannelHandle);
}
if ((uint) act < 0x80 && ((_vm->_game.version == 8) || (_vm->_game.version <= 7 && !_vm->_string[0].no_talk_anim))) {
@@ -675,7 +680,7 @@ void Sound::stopTalkSound() {
} else if (_vm->_game.heversion >= 60) {
stopSound(1);
} else {
- _mixer->stopHandle(_talkChannelHandle);
+ _mixer->stopHandle(*_talkChannelHandle);
}
_sfxMode &= ~2;
}
@@ -1060,7 +1065,7 @@ void Sound::playCDTrackInternal(int track, int numLoops, int startFrame, int dur
g_system->getAudioCDManager()->play(track, numLoops, startFrame, duration);
} else {
// Stop any currently playing track
- _mixer->stopHandle(_loomSteamCDAudioHandle);
+ _mixer->stopHandle(*_loomSteamCDAudioHandle);
Common::File *cddaFile = new Common::File();
if (cddaFile->open("CDDA.SOU")) {
@@ -1068,7 +1073,7 @@ void Sound::playCDTrackInternal(int track, int numLoops, int startFrame, int dur
Audio::Timestamp end = Audio::Timestamp(0, startFrame + duration, 75);
Audio::SeekableAudioStream *stream = makeCDDAStream(cddaFile, DisposeAfterUse::YES);
- _mixer->playStream(Audio::Mixer::kMusicSoundType, &_loomSteamCDAudioHandle,
+ _mixer->playStream(Audio::Mixer::kMusicSoundType, _loomSteamCDAudioHandle,
Audio::makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops));
} else {
delete cddaFile;
@@ -1080,14 +1085,14 @@ void Sound::stopCD() {
if (!_isLoomSteam)
g_system->getAudioCDManager()->stop();
else
- _mixer->stopHandle(_loomSteamCDAudioHandle);
+ _mixer->stopHandle(*_loomSteamCDAudioHandle);
}
int Sound::pollCD() const {
if (!_isLoomSteam)
return g_system->getAudioCDManager()->isPlaying();
else
- return _mixer->isSoundHandleActive(_loomSteamCDAudioHandle);
+ return _mixer->isSoundHandleActive(*_loomSteamCDAudioHandle);
}
void Sound::updateCD() {
@@ -1100,7 +1105,7 @@ AudioCDManager::Status Sound::getCDStatus() {
return g_system->getAudioCDManager()->getStatus();
else {
AudioCDManager::Status info = _loomSteamCD;
- info.playing = _mixer->isSoundHandleActive(_loomSteamCDAudioHandle);
+ info.playing = _mixer->isSoundHandleActive(*_loomSteamCDAudioHandle);
return info;
}
}
diff --git a/engines/scumm/sound.h b/engines/scumm/sound.h
index 8c11c7b5b2..7fdb16371c 100644
--- a/engines/scumm/sound.h
+++ b/engines/scumm/sound.h
@@ -26,10 +26,14 @@
#include "common/scummsys.h"
#include "common/str.h"
#include "audio/mididrv.h"
-#include "audio/mixer.h"
#include "backends/audiocd/audiocd.h"
#include "scumm/saveload.h"
+namespace Audio {
+class Mixer;
+class SoundHandle;
+}
+
namespace Scumm {
class ScummEngine;
@@ -81,12 +85,12 @@ protected:
int16 _currentCDSound;
int16 _currentMusic;
- Audio::SoundHandle _loomSteamCDAudioHandle;
+ Audio::SoundHandle *_loomSteamCDAudioHandle;
bool _isLoomSteam;
AudioCDManager::Status _loomSteamCD;
public:
- Audio::SoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
+ Audio::SoundHandle *_talkChannelHandle; // Handle of mixer channel actor is talking on
bool _soundsPaused;
byte _sfxMode;
diff --git a/engines/scumm/string.cpp b/engines/scumm/string.cpp
index 3049fbcf62..e6054918fa 100644
--- a/engines/scumm/string.cpp
+++ b/engines/scumm/string.cpp
@@ -23,6 +23,7 @@
#include "common/config-manager.h"
+#include "audio/mixer.h"
#include "scumm/actor.h"
#include "scumm/charset.h"
@@ -662,7 +663,7 @@ void ScummEngine::CHARSET_1() {
// Special case for HE games
} else if (_game.id == GID_LOOM && !ConfMan.getBool("subtitles") && (_sound->pollCD())) {
// Special case for Loom (CD), since it only uses CD audio.for sound
- } else if (!ConfMan.getBool("subtitles") && (!_haveActorSpeechMsg || _mixer->isSoundHandleActive(_sound->_talkChannelHandle))) {
+ } else if (!ConfMan.getBool("subtitles") && (!_haveActorSpeechMsg || _mixer->isSoundHandleActive(*_sound->_talkChannelHandle))) {
// Subtitles are turned off, and there is a voice version
// of this message -> don't print it.
} else {