aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/sound
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-29 00:27:50 +0200
committerEinar Johan Trøan Sømåen2012-07-29 00:27:50 +0200
commit6dc1e09da93c0ba0507fd0ceadbbb504469deccc (patch)
treedae477f4ed7c6b9be7a5dd38174d81cdbae48c58 /engines/wintermute/base/sound
parente841bf16d6b955f779e5e30535848bd650d22352 (diff)
downloadscummvm-rg350-6dc1e09da93c0ba0507fd0ceadbbb504469deccc.tar.gz
scummvm-rg350-6dc1e09da93c0ba0507fd0ceadbbb504469deccc.tar.bz2
scummvm-rg350-6dc1e09da93c0ba0507fd0ceadbbb504469deccc.zip
WINTERMUTE: Replace const char* with const Common::String & in fonts, gfx, particles, sound and files.
Diffstat (limited to 'engines/wintermute/base/sound')
-rw-r--r--engines/wintermute/base/sound/base_sound.cpp50
-rw-r--r--engines/wintermute/base/sound/base_sound.h24
-rw-r--r--engines/wintermute/base/sound/base_sound_buffer.cpp17
-rw-r--r--engines/wintermute/base/sound/base_sound_buffer.h4
-rw-r--r--engines/wintermute/base/sound/base_sound_manager.cpp9
-rw-r--r--engines/wintermute/base/sound/base_sound_manager.h2
6 files changed, 31 insertions, 75 deletions
diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp
index 6151128624..7e32552d08 100644
--- a/engines/wintermute/base/sound/base_sound.cpp
+++ b/engines/wintermute/base/sound/base_sound.cpp
@@ -35,10 +35,9 @@ namespace WinterMute {
IMPLEMENT_PERSISTENT(BaseSound, false)
-//////////////////////////////////////////////////////////////////////////
BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) {
_sound = NULL;
- _soundFilename = NULL;
+ _soundFilename = "";
_soundType = Audio::Mixer::kSFXSoundType;
_soundStreamed = false;
@@ -54,32 +53,23 @@ BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) {
_sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0;
}
-
-//////////////////////////////////////////////////////////////////////////
BaseSound::~BaseSound() {
if (_sound) {
_gameRef->_soundMgr->removeSound(_sound);
}
_sound = NULL;
-
- delete[] _soundFilename;
- _soundFilename = NULL;
}
-
-//////////////////////////////////////////////////////////////////////////
-bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) {
+bool BaseSound::setSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) {
if (_sound) {
_gameRef->_soundMgr->removeSound(_sound);
_sound = NULL;
}
- delete[] _soundFilename;
- _soundFilename = NULL;
+ _soundFilename = Common::String(); // Set empty
_sound = _gameRef->_soundMgr->addSound(filename, type, streamed);
if (_sound) {
- _soundFilename = new char[strlen(filename) + 1];
- strcpy(_soundFilename, filename);
+ _soundFilename = filename;
_soundType = type;
_soundStreamed = streamed;
@@ -90,8 +80,6 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setSoundSimple() {
_sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed);
if (_sound) {
@@ -112,9 +100,6 @@ bool BaseSound::setSoundSimple() {
}
}
-
-
-//////////////////////////////////////////////////////////////////////////
uint32 BaseSound::getLength() {
if (_sound) {
return _sound->getLength();
@@ -123,8 +108,6 @@ uint32 BaseSound::getLength() {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::play(bool looping) {
if (_sound) {
_soundPaused = false;
@@ -134,8 +117,6 @@ bool BaseSound::play(bool looping) {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::stop() {
if (_sound) {
_soundPaused = false;
@@ -145,8 +126,6 @@ bool BaseSound::stop() {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::pause(bool freezePaused) {
if (_sound) {
_soundPaused = true;
@@ -159,8 +138,6 @@ bool BaseSound::pause(bool freezePaused) {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::resume() {
if (_sound && _soundPaused) {
_soundPaused = false;
@@ -170,8 +147,6 @@ bool BaseSound::resume() {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::persist(BasePersistenceManager *persistMgr) {
if (persistMgr->getIsSaving() && _sound) {
_soundPlaying = _sound->isPlaying();
@@ -205,20 +180,14 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) {
return STATUS_OK;
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::isPlaying() {
return _sound && _sound->isPlaying();
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::isPaused() {
return _sound && _soundPaused;
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPositionTime(uint32 time) {
if (!_sound) {
return STATUS_FAILED;
@@ -231,8 +200,6 @@ bool BaseSound::setPositionTime(uint32 time) {
return ret;
}
-
-//////////////////////////////////////////////////////////////////////////
uint32 BaseSound::getPositionTime() {
if (!_sound) {
return 0;
@@ -245,7 +212,6 @@ uint32 BaseSound::getPositionTime() {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setVolumePercent(int percent) {
if (!_sound) {
return STATUS_FAILED;
@@ -254,7 +220,6 @@ bool BaseSound::setVolumePercent(int percent) {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setVolume(int volume) {
if (!_sound) {
return STATUS_FAILED;
@@ -263,7 +228,6 @@ bool BaseSound::setVolume(int volume) {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPrivateVolume(int volume) {
if (!_sound) {
return STATUS_FAILED;
@@ -273,7 +237,6 @@ bool BaseSound::setPrivateVolume(int volume) {
}
}
-//////////////////////////////////////////////////////////////////////////
int BaseSound::getVolumePercent() {
if (!_sound) {
return 0;
@@ -282,7 +245,6 @@ int BaseSound::getVolumePercent() {
}
}
-//////////////////////////////////////////////////////////////////////////
int BaseSound::getVolume() {
if (!_sound) {
return 0;
@@ -291,7 +253,6 @@ int BaseSound::getVolume() {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setLoopStart(uint32 pos) {
if (!_sound) {
return STATUS_FAILED;
@@ -301,7 +262,6 @@ bool BaseSound::setLoopStart(uint32 pos) {
}
}
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::setPan(float pan) {
if (_sound) {
return _sound->setPan(pan);
@@ -310,8 +270,6 @@ bool BaseSound::setPan(float pan) {
}
}
-
-//////////////////////////////////////////////////////////////////////////
bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3, float param4) {
if (!_sound) {
return STATUS_OK;
diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h
index 7ea9f38f6c..cadba77bc8 100644
--- a/engines/wintermute/base/sound/base_sound.h
+++ b/engines/wintermute/base/sound/base_sound.h
@@ -40,7 +40,6 @@ class BaseSoundBuffer;
class BaseSound : public BaseClass {
public:
bool setPan(float pan);
- int _soundPrivateVolume;
int getVolume();
int getVolumePercent();
bool setVolumePercent(int percent);
@@ -49,31 +48,32 @@ public:
bool setLoopStart(uint32 pos);
uint32 getPositionTime();
bool setPositionTime(uint32 time);
- bool _soundPaused;
- bool _soundFreezePaused;
bool isPlaying();
bool isPaused();
- bool _soundPlaying;
- bool _soundLooping;
- uint32 _soundLoopStart;
- uint32 _soundPosition;
DECLARE_PERSISTENT(BaseSound, BaseClass)
bool resume();
bool pause(bool freezePaused = false);
bool stop();
bool play(bool looping = false);
uint32 getLength();
- bool _soundStreamed;
- Audio::Mixer::SoundType _soundType;
- char *_soundFilename;
+ const char *getFilename() { return _soundFilename.c_str(); }
bool setSoundSimple();
- bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
+ bool setSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
BaseSound(BaseGame *inGame);
virtual ~BaseSound();
bool applyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0);
-
private:
+ Common::String _soundFilename;
+ bool _soundStreamed;
+ Audio::Mixer::SoundType _soundType;
+ int _soundPrivateVolume;
+ uint32 _soundLoopStart;
+ uint32 _soundPosition;
+ bool _soundPlaying;
+ bool _soundLooping;
+ bool _soundPaused;
+ bool _soundFreezePaused;
TSFXType _sFXType;
float _sFXParam1;
float _sFXParam2;
diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp
index ed667592e9..5f36eb96d4 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.cpp
+++ b/engines/wintermute/base/sound/base_sound_buffer.cpp
@@ -56,7 +56,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) {
// _sync = NULL;
_streamed = false;
- _filename = NULL;
+ _filename = "";
_file = NULL;
_privateVolume = 255;
_volume = 255;
@@ -82,9 +82,6 @@ BaseSoundBuffer::~BaseSoundBuffer() {
}
delete _stream;
_stream = NULL;
-
- delete[] _filename;
- _filename = NULL;
}
@@ -95,13 +92,13 @@ void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 block
//////////////////////////////////////////////////////////////////////////
-bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
- debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload);
+bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) {
+ debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload);
// Load a file, but avoid having the File-manager handle the disposal of it.
_file = _gameRef->_fileManager->openFile(filename, true, false);
if (!_file) {
- _gameRef->LOG(0, "Error opening sound file '%s'", filename);
+ _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str());
return STATUS_FAILED;
}
Common::String strFilename(filename);
@@ -118,16 +115,16 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) {
_file = new Common::SeekableSubReadStream(_file, 0, waveSize);
_stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES);
} else {
- error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType);
+ error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename.c_str(), waveType);
}
}
} else {
- error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename);
+ error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename.c_str());
}
if (!_stream) {
return STATUS_FAILED;
}
- BaseUtils::setString(&_filename, filename);
+ _filename = filename;
return STATUS_OK;
}
diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h
index 107ceb87d7..7aec144283 100644
--- a/engines/wintermute/base/sound/base_sound_buffer.h
+++ b/engines/wintermute/base/sound/base_sound_buffer.h
@@ -72,7 +72,7 @@ public:
void setType(Audio::Mixer::SoundType Type);
- bool loadFromFile(const char *filename, bool forceReload = false);
+ bool loadFromFile(const Common::String &filename, bool forceReload = false);
void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0);
bool applyFX(TSFXType type, float param1, float param2, float param3, float param4);
@@ -89,7 +89,7 @@ public:
int _privateVolume;
private:
uint32 _startPos;
- char *_filename;
+ Common::String _filename;
bool _streamed;
Common::SeekableReadStream *_file;
int _volume;
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp
index 4659c35ff7..8df9f299ef 100644
--- a/engines/wintermute/base/sound/base_sound_manager.cpp
+++ b/engines/wintermute/base/sound/base_sound_manager.cpp
@@ -89,13 +89,14 @@ bool BaseSoundMgr::initialize() {
}
//////////////////////////////////////////////////////////////////////////
-BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) {
+BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) {
if (!_soundAvailable) {
return NULL;
}
BaseSoundBuffer *sound;
+ Common::String useFilename = filename;
// try to switch WAV to OGG file (if available)
AnsiString ext = PathUtil::getExtension(filename);
if (StringUtil::compareNoCase(ext, "wav")) {
@@ -104,7 +105,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun
AnsiString newFile = PathUtil::combine(path, name + "ogg");
if (_gameRef->_fileManager->hasFile(newFile)) {
- filename = newFile.c_str();
+ useFilename = newFile;
}
}
@@ -117,9 +118,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun
sound->setType(type);
- bool res = sound->loadFromFile(filename);
+ bool res = sound->loadFromFile(useFilename);
if (DID_FAIL(res)) {
- _gameRef->LOG(res, "Error loading sound '%s'", filename);
+ _gameRef->LOG(res, "Error loading sound '%s'", useFilename.c_str());
delete sound;
return NULL;
}
diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h
index 464330c733..a2b8f2c9e9 100644
--- a/engines/wintermute/base/sound/base_sound_manager.h
+++ b/engines/wintermute/base/sound/base_sound_manager.h
@@ -53,7 +53,7 @@ public:
uint32 _volumeOriginal;
int _volumeMaster;
bool removeSound(BaseSoundBuffer *sound);
- BaseSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
+ BaseSoundBuffer *addSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false);
bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType);
bool initialize();
bool _soundAvailable;