diff options
Diffstat (limited to 'engines/wintermute')
-rw-r--r-- | engines/wintermute/BSoundBuffer.cpp | 25 | ||||
-rw-r--r-- | engines/wintermute/BSoundBuffer.h | 7 | ||||
-rw-r--r-- | engines/wintermute/BSoundMgr.cpp | 29 |
3 files changed, 38 insertions, 23 deletions
diff --git a/engines/wintermute/BSoundBuffer.cpp b/engines/wintermute/BSoundBuffer.cpp index 7de8aec436..a58f39c869 100644 --- a/engines/wintermute/BSoundBuffer.cpp +++ b/engines/wintermute/BSoundBuffer.cpp @@ -33,6 +33,10 @@ #include "BSoundBuffer.h"
#include "BFileManager.h"
#include "utils.h"
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "audio/decoders/vorbis.h"
+#include "common/system.h"
namespace WinterMute {
@@ -44,9 +48,8 @@ namespace WinterMute { //////////////////////////////////////////////////////////////////////////
CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) {
-#if 0
_stream = NULL;
- _sync = NULL;
+// _sync = NULL;
_streamed = false;
_filename = NULL;
@@ -59,7 +62,6 @@ CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { _type = SOUND_SFX;
_freezePaused = false;
-#endif
}
@@ -91,11 +93,15 @@ void CBSoundBuffer::SetStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSi //////////////////////////////////////////////////////////////////////////
HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) {
+ warning("BSoundBuffer::LoadFromFile(%s,%d)", Filename, ForceReload);
#if 0
if (_stream) {
BASS_StreamFree(_stream);
_stream = NULL;
}
+#endif
+ delete _stream;
+ _stream = NULL;
if (_file) Game->_fileManager->CloseFile(_file);
@@ -104,7 +110,12 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { Game->LOG(0, "Error opening sound file '%s'", Filename);
return E_FAIL;
}
-
+
+ _stream = Audio::makeVorbisStream(_file->getMemStream(), DisposeAfterUse::YES);
+ CBUtils::SetString(&_filename, Filename);
+
+ return S_OK;
+#if 0
BASS_FILEPROCS fileProc;
fileProc.close = CBSoundBuffer::FileCloseProc;
fileProc.read = CBSoundBuffer::FileReadProc;
@@ -166,13 +177,13 @@ HRESULT CBSoundBuffer::LoadFromFile(const char *Filename, bool ForceReload) { //////////////////////////////////////////////////////////////////////////
HRESULT CBSoundBuffer::Play(bool Looping, uint32 StartSample) {
-#if 0
+ warning("Play: %s", _filename);
if (_stream) {
SetLooping(Looping);
- BASS_ChannelPlay(_stream, TRUE);
+ g_system->getMixer()->playStream(Audio::Mixer::kPlainSoundType, _handle, _stream);
+ //BASS_ChannelPlay(_stream, TRUE);
}
return S_OK;
-#endif
}
//////////////////////////////////////////////////////////////////////////
diff --git a/engines/wintermute/BSoundBuffer.h b/engines/wintermute/BSoundBuffer.h index 2a1016f7a9..e9ef8264f7 100644 --- a/engines/wintermute/BSoundBuffer.h +++ b/engines/wintermute/BSoundBuffer.h @@ -33,6 +33,11 @@ #include "BBase.h"
//#include "bass.h"
+namespace Audio {
+ class SeekableAudioStream;
+ class SoundHandle;
+}
+
namespace WinterMute {
class CBFile;
@@ -72,6 +77,8 @@ public: //HSTREAM _stream;
//HSYNC _sync;
+ Audio::SeekableAudioStream *_stream;
+ Audio::SoundHandle *_handle;
bool _freezePaused;
uint32 _loopStart;
diff --git a/engines/wintermute/BSoundMgr.cpp b/engines/wintermute/BSoundMgr.cpp index 469d601e46..17fd3c64b0 100644 --- a/engines/wintermute/BSoundMgr.cpp +++ b/engines/wintermute/BSoundMgr.cpp @@ -59,10 +59,9 @@ CBSoundMgr::~CBSoundMgr() { //////////////////////////////////////////////////////////////////////////
HRESULT CBSoundMgr::Cleanup() {
-#if 0
for (int i = 0; i < _sounds.GetSize(); i++) delete _sounds[i];
_sounds.RemoveAll();
-
+#if 0
BASS_Free();
#endif
return S_OK;
@@ -107,10 +106,9 @@ HRESULT CBSoundMgr::Initialize() { _volumeSpeech = Game->_registry->ReadInt("Audio", "SpeechVolume", 100);
_volumeMusic = Game->_registry->ReadInt("Audio", "MusicVolume", 100);
-#if 0
_soundAvailable = true;
SetMasterVolumePercent(_volumeMaster);
-#endif
+
return S_OK;
}
@@ -129,7 +127,6 @@ HRESULT CBSoundMgr::InitLoop() { //////////////////////////////////////////////////////////////////////////
CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool Streamed) {
if (!_soundAvailable) return NULL;
-#if 0
CBSoundBuffer *sound;
@@ -178,14 +175,14 @@ CBSoundBuffer *CBSoundMgr::AddSound(const char *Filename, TSoundType Type, bool _sounds.Add(sound);
return sound;
-#endif
+
return NULL;
}
//////////////////////////////////////////////////////////////////////////
HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) {
if (!Sound) return E_FAIL;
-#if 0
+
// set volume appropriately
switch (Type) {
case SOUND_SFX:
@@ -201,13 +198,13 @@ HRESULT CBSoundMgr::AddSound(CBSoundBuffer *Sound, TSoundType Type) { // register sound
_sounds.Add(Sound);
-#endif
+
return S_OK;
}
//////////////////////////////////////////////////////////////////////////
HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) {
-#if 0
+
for (int i = 0; i < _sounds.GetSize(); i++) {
if (_sounds[i] == Sound) {
delete _sounds[i];
@@ -215,7 +212,7 @@ HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { return S_OK;
}
}
-#endif
+
return E_FAIL;
}
@@ -223,7 +220,7 @@ HRESULT CBSoundMgr::RemoveSound(CBSoundBuffer *Sound) { //////////////////////////////////////////////////////////////////////////
HRESULT CBSoundMgr::SetVolume(TSoundType Type, int Volume) {
if (!_soundAvailable) return S_OK;
-#if 0
+
switch (Type) {
case SOUND_SFX:
_volumeSFX = Volume;
@@ -239,7 +236,7 @@ HRESULT CBSoundMgr::SetVolume(TSoundType Type, int Volume) { for (int i = 0; i < _sounds.GetSize(); i++) {
if (_sounds[i]->_type == Type) _sounds[i]->SetVolume(Volume);
}
-#endif
+
return S_OK;
}
@@ -291,28 +288,28 @@ byte CBSoundMgr::GetMasterVolumePercent() { //////////////////////////////////////////////////////////////////////////
HRESULT CBSoundMgr::PauseAll(bool IncludingMusic) {
-#if 0
+
for (int i = 0; i < _sounds.GetSize(); i++) {
if (_sounds[i]->IsPlaying() && (_sounds[i]->_type != SOUND_MUSIC || IncludingMusic)) {
_sounds[i]->Pause();
_sounds[i]->_freezePaused = true;
}
}
-#endif
+
return S_OK;
}
//////////////////////////////////////////////////////////////////////////
HRESULT CBSoundMgr::ResumeAll() {
-#if 0
+
for (int i = 0; i < _sounds.GetSize(); i++) {
if (_sounds[i]->_freezePaused) {
_sounds[i]->Resume();
_sounds[i]->_freezePaused = false;
}
}
-#endif
+
return S_OK;
}
|