aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2010-09-14 21:58:30 +0000
committerEugene Sandulenko2010-10-12 23:55:24 +0000
commit573dafefbb95924d11d6d869b2236a17c4b56bfd (patch)
tree34435da4719b3037428dfa8fec202e2576431c57 /engines
parent56aac421eb7846472f73b9b17a65d3e26f0d2c24 (diff)
downloadscummvm-rg350-573dafefbb95924d11d6d869b2236a17c4b56bfd.tar.gz
scummvm-rg350-573dafefbb95924d11d6d869b2236a17c4b56bfd.tar.bz2
scummvm-rg350-573dafefbb95924d11d6d869b2236a17c4b56bfd.zip
SWORD25: Got rid of FMODExSound class
svn-id: r53364
Diffstat (limited to 'engines')
-rw-r--r--engines/sword25/kernel/service_ids.h4
-rw-r--r--engines/sword25/module.mk1
-rw-r--r--engines/sword25/sfx/fmodexchannel.cpp279
-rw-r--r--engines/sword25/sfx/fmodexchannel.h83
-rw-r--r--engines/sword25/sfx/fmodexexception.h63
-rw-r--r--engines/sword25/sfx/fmodexresource.cpp170
-rw-r--r--engines/sword25/sfx/fmodexresource.h70
-rw-r--r--engines/sword25/sfx/fmodexsound.cpp886
-rw-r--r--engines/sword25/sfx/fmodexsound.h136
-rw-r--r--engines/sword25/sfx/soundengine.cpp101
-rw-r--r--engines/sword25/sfx/soundengine.h56
11 files changed, 137 insertions, 1712 deletions
diff --git a/engines/sword25/kernel/service_ids.h b/engines/sword25/kernel/service_ids.h
index 7c41fe459e..5ffd83d743 100644
--- a/engines/sword25/kernel/service_ids.h
+++ b/engines/sword25/kernel/service_ids.h
@@ -52,7 +52,7 @@ namespace Sword25 {
Service *GraphicEngine_CreateObject(Kernel *pKernel);
Service *PackageManager_CreateObject(Kernel *pKernel);
Service *InputEngine_CreateObject(Kernel *pKernel);
-Service *FMODExSound_CreateObject(Kernel *pKernel);
+Service *SoundEngine_CreateObject(Kernel *pKernel);
Service *LuaScriptEngine_CreateObject(Kernel *pKernel);
Service *Geometry_CreateObject(Kernel *pKernel);
Service *OggTheora_CreateObject(Kernel *pKernel);
@@ -67,7 +67,7 @@ const BS_ServiceInfo BS_SERVICE_TABLE[] = {
BS_ServiceInfo("gfx", "opengl", GraphicEngine_CreateObject),
BS_ServiceInfo("package", "archiveFS", PackageManager_CreateObject),
BS_ServiceInfo("input", "winapi", InputEngine_CreateObject),
- BS_ServiceInfo("sfx", "fmodex", FMODExSound_CreateObject),
+ BS_ServiceInfo("sfx", "fmodex", SoundEngine_CreateObject),
BS_ServiceInfo("script", "lua", LuaScriptEngine_CreateObject),
BS_ServiceInfo("geometry", "std", Geometry_CreateObject),
BS_ServiceInfo("fmv", "oggtheora", OggTheora_CreateObject),
diff --git a/engines/sword25/module.mk b/engines/sword25/module.mk
index fc4c6ebf8a..4d3a617cf7 100644
--- a/engines/sword25/module.mk
+++ b/engines/sword25/module.mk
@@ -68,7 +68,6 @@ MODULE_OBJS := \
script/luacallback.o \
script/luascript.o \
script/lua_extensions.o \
- sfx/fmodexsound.o \
sfx/soundengine.o \
sfx/soundengine_script.o \
util/lua/lapi.o \
diff --git a/engines/sword25/sfx/fmodexchannel.cpp b/engines/sword25/sfx/fmodexchannel.cpp
deleted file mode 100644
index 5214dd7b51..0000000000
--- a/engines/sword25/sfx/fmodexchannel.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-// -----------------------------------------------------------------------------
-// Logging
-// -----------------------------------------------------------------------------
-
-#define BS_LOG_PREFIX "FMODEXCHANNEL"
-
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
-#include "sword25/sfx/fmodexexception.h"
-#include "sword25/sfx/fmodexchannel.h"
-
-// -----------------------------------------------------------------------------
-// Konstruktion / Destruktion
-// -----------------------------------------------------------------------------
-
-BS_FMODExChannel::BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr) :
- m_ChannelPtr(ChannelPtr),
- m_SoundPtr(SoundPtr) {
-}
-
-// -----------------------------------------------------------------------------
-
-BS_FMODExChannel::~BS_FMODExChannel() {
- if (m_ChannelPtr) FMOD_Channel_Stop(m_ChannelPtr);
- if (m_SoundPtr) FMOD_Sound_Release(m_SoundPtr);
-}
-
-// -----------------------------------------------------------------------------
-// FMOD Ex macht alle Kanäle ungültig, sobald sie nicht mehr abgespielt werden,
-// oder wenn der Kanal in der zwischenzeit neu vergeben wurde.
-// Dann führen alle Aufrufe von Funktionen dieser Kanäle zu dem Fehlern
-// FMOD_ERR_INVALID_HANDLE oder FMOD_ERR_CHANNEL_STOLEN
-// Dieses Soundsystem entfernt aber nur jeden Frame alle toten Kanäle. Daher
-// kann es vorkommen, dass an einem bereits toten Kanal Aufrufe getätigt werden.
-// Diese Fehler werden daher von den folgenden Methoden ignoriert.
-// -----------------------------------------------------------------------------
-
-namespace {
-bool IsImportantError(FMOD_RESULT Result) {
- return Result != FMOD_OK && Result != FMOD_ERR_INVALID_HANDLE && Result != FMOD_ERR_CHANNEL_STOLEN;
-}
-}
-
-// -----------------------------------------------------------------------------
-// Setter
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::SetPaused(bool Paused) {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_RESULT Result = FMOD_Channel_SetPaused(m_ChannelPtr, Paused ? 1 : 0);
- if (IsImportantError(Result)) {
- BS_FMODExException("FMOD_Channel_SetPaused()", Result).Log();
- return false;
- } else
- return true;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::SetVolume(float Volume) {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_RESULT Result = FMOD_Channel_SetVolume(m_ChannelPtr, Volume);
- if (IsImportantError(Result)) {
- BS_FMODExException("FMOD_Channel_SetVolume()", Result).Log();
- return false;
- } else
- return true;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::SetPanning(float Panning) {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_RESULT Result = FMOD_Channel_SetPan(m_ChannelPtr, Panning);
- if (IsImportantError(Result)) {
- BS_FMODExException("FMOD_Channel_SetPan()", Result).Log();
- return false;
- } else
- return true;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::SetLoop(bool Loop) {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_RESULT Result = FMOD_Channel_SetLoopCount(m_ChannelPtr, Loop ? -1 : 0);
- if (IsImportantError(Result)) {
- BS_FMODExException("FMOD_Channel_SetLoopCount()", Result).Log();
- return false;
- } else
- return true;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::SetLoopPoints(uint LoopStart, uint LoopEnd) {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_RESULT Result = FMOD_Channel_SetLoopPoints(m_ChannelPtr, LoopStart, FMOD_TIMEUNIT_PCM, LoopEnd, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result)) {
- BS_FMODExException("FMOD_Channel_SetLoopPoints()", Result).Log();
- return false;
- } else
- return true;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::SetPosition(uint Position) {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_RESULT Result = FMOD_Channel_SetPosition(m_ChannelPtr, Position, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result)) {
- BS_FMODExException("FMOD_Channel_SetPosition()", Result).Log();
- return false;
- } else
- return true;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::Stop() {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_RESULT Result = FMOD_Channel_Stop(m_ChannelPtr);
- if (IsImportantError(Result)) {
- BS_FMODExException("FMOD_Channel_Stop()", Result).Log();
- return false;
- } else
- return true;
-}
-
-// -----------------------------------------------------------------------------
-// Getter
-// -----------------------------------------------------------------------------
-
-float BS_FMODExChannel::GetVolume() {
- BS_ASSERT(m_ChannelPtr);
-
- float Volume = 0;
- FMOD_RESULT Result = FMOD_Channel_GetVolume(m_ChannelPtr, &Volume);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetVolume()", Result).Log();
-
- return Volume;
-}
-
-// -----------------------------------------------------------------------------
-
-float BS_FMODExChannel::GetPanning() {
- BS_ASSERT(m_ChannelPtr);
-
- float Panning = 0;
- FMOD_RESULT Result = FMOD_Channel_GetPan(m_ChannelPtr, &Panning);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetPan()", Result).Log();
-
- return Panning;
-}
-
-// -----------------------------------------------------------------------------
-
-uint BS_FMODExChannel::GetPosition() {
- BS_ASSERT(m_ChannelPtr);
-
- uint Position = 0;
- FMOD_RESULT Result = FMOD_Channel_GetPosition(m_ChannelPtr, &Position, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetPosition()", Result).Log();
-
- return Position;
-}
-
-// -----------------------------------------------------------------------------
-
-uint BS_FMODExChannel::GetTime() {
- BS_ASSERT(m_ChannelPtr);
-
- uint Time = 0;
- FMOD_RESULT Result = FMOD_Channel_GetPosition(m_ChannelPtr, &Time, FMOD_TIMEUNIT_MS);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetPosition()", Result).Log();
-
- return Time;
-}
-
-// -----------------------------------------------------------------------------
-
-uint BS_FMODExChannel::GetLoopStart() {
- BS_ASSERT(m_ChannelPtr);
- uint LoopStart = 0;
- FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, &LoopStart, FMOD_TIMEUNIT_PCM, 0, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetLoopPoints()", Result).Log();
-
- return LoopStart;
-}
-
-// -----------------------------------------------------------------------------
-
-uint BS_FMODExChannel::GetLoopEnd() {
- BS_ASSERT(m_ChannelPtr);
- uint LoopEnd = 0;
- FMOD_RESULT Result = FMOD_Channel_GetLoopPoints(m_ChannelPtr, 0, FMOD_TIMEUNIT_PCM, &LoopEnd, FMOD_TIMEUNIT_PCM);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetLoopPoints()", Result).Log();
-
- return LoopEnd;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::IsLooping() {
- BS_ASSERT(m_ChannelPtr);
-
- int LoopCount = 0;
- FMOD_RESULT Result = FMOD_Channel_GetLoopCount(m_ChannelPtr, &LoopCount);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetLoopCount()", Result).Log();
-
- return LoopCount == -1;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::IsPaused() {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_BOOL Paused = 0;
- FMOD_RESULT Result = FMOD_Channel_GetPaused(m_ChannelPtr, &Paused);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_GetPaused()", Result).Log();
-
- return Paused != 0;
-}
-
-// -----------------------------------------------------------------------------
-
-bool BS_FMODExChannel::IsPlaying() {
- BS_ASSERT(m_ChannelPtr);
-
- FMOD_BOOL Playing = 0;
- FMOD_RESULT Result = FMOD_Channel_IsPlaying(m_ChannelPtr, &Playing);
- if (IsImportantError(Result)) BS_FMODExException("FMOD_Channel_IsPlaying()", Result).Log();
-
- return Playing != 0;
-}
diff --git a/engines/sword25/sfx/fmodexchannel.h b/engines/sword25/sfx/fmodexchannel.h
deleted file mode 100644
index bada197eb0..0000000000
--- a/engines/sword25/sfx/fmodexchannel.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-#ifndef SWORD25_FMODEXCHANNEL_H
-#define SWORD25_FMODEXCHANNEL_H
-
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
-#include "sword25/kernel/common.h"
-
-// -----------------------------------------------------------------------------
-// Forward Declarations
-// -----------------------------------------------------------------------------
-
-struct FMOD_CHANNEL;
-struct FMOD_SOUND;
-
-// -----------------------------------------------------------------------------
-// Klassendefinition
-// -----------------------------------------------------------------------------
-
-class BS_FMODExChannel {
-public:
- BS_FMODExChannel(FMOD_CHANNEL *ChannelPtr, FMOD_SOUND *SoundPtr);
- virtual ~BS_FMODExChannel();
-
- bool SetPaused(bool Paused);
- bool SetVolume(float Volume);
- bool SetPanning(float Panning);
- bool SetLoop(bool Loop);
- bool SetLoopPoints(uint LoopStart, uint LoopEnd);
- bool SetPosition(uint Position);
- bool Stop();
-
- float GetVolume();
- float GetPanning();
- uint GetPosition();
- uint GetTime();
- uint GetLoopStart();
- uint GetLoopEnd();
- bool IsLooping();
- bool IsPaused();
- bool IsPlaying();
-
-private:
- FMOD_CHANNEL *m_ChannelPtr;
- FMOD_SOUND *m_SoundPtr;
-};
-
-#endif
diff --git a/engines/sword25/sfx/fmodexexception.h b/engines/sword25/sfx/fmodexexception.h
deleted file mode 100644
index 05e6d82310..0000000000
--- a/engines/sword25/sfx/fmodexexception.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-#ifndef SWORD25_FMODEXEXCEPTION_H
-#define SWROD25_FMODEXEXCEPTION_H
-
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
-#include "sword25/kernel/common.h"
-
-// -----------------------------------------------------------------------------
-// Klassendefinition
-// -----------------------------------------------------------------------------
-
-class BS_FMODExException {
-public:
- BS_FMODExException(const char *Function_, FMOD_RESULT Result_) :
- Function(Function_),
- Result(Result_) {}
-
- const char *Function;
- FMOD_RESULT Result;
-
- void Log() {
- BS_LOG_ERROR("Call to %s failed.", Function);
- BS_LOGLN(" FMOD error: %s(%d)", FMOD_ErrorString(Result), Result);
- }
-};
-
-#endif
diff --git a/engines/sword25/sfx/fmodexresource.cpp b/engines/sword25/sfx/fmodexresource.cpp
deleted file mode 100644
index d4bdbb2887..0000000000
--- a/engines/sword25/sfx/fmodexresource.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-// -----------------------------------------------------------------------------
-// Logging
-// -----------------------------------------------------------------------------
-
-#define BS_LOG_PREFIX "FMODEXRESOURCE"
-
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
-#include <memory>
-#include "sword25/sfx/fmodexexception.h"
-#include "sword25/sfx/fmodexchannel.h"
-#include "sword25/package/packagemanager.h"
-#include "sword25/sfx/fmodexresource.h"
-
-// -----------------------------------------------------------------------------
-// Konstanten
-// -----------------------------------------------------------------------------
-
-namespace {
-const uint MAX_SAMPLE_SIZE = 100 * 1024; // Die Dateigröße in Byte ab der ein Sound als Stream abgespielt wird
-}
-
-// -----------------------------------------------------------------------------
-// Konstruktion / Destruktion
-// -----------------------------------------------------------------------------
-
-
-BS_FMODExResource::BS_FMODExResource(const std::string &FileName, FMOD_SYSTEM *FMOD, bool &Success) :
- m_SoundPtr(0),
- m_SoundDataPtr(0),
- BS_Resource(FileName, BS_Resource::TYPE_SOUND) {
- BS_ASSERT(FMOD);
-
- // Von Misserfolg ausgehen
- Success = false;
-
- // Pointer auf den Package-Manager bekommen
- BS_PackageManager *PackagePtr = BS_Kernel::GetInstance()->GetPackage();
- if (!PackagePtr) {
- BS_LOG_ERRORLN("Package manager not found.");
- return;
- }
-
- // Datei laden
- uint FileSize;
- char *FileDataPtr = (char *) PackagePtr->GetFile(GetFileName(), &FileSize);
- if (!FileDataPtr) {
- BS_LOG_ERRORLN("File \"%s\" could not be loaded.", GetFileName().c_str());
- return;
- }
-
- // Ob die Sounddatei als Sample oder als Stream behandelt wird, ist abhängig von der Dateigröße.
- // Samples werden sofort intialisiert.
- // Für Streams wird hingegen bei jedem Abspielen ein neuer Sound erstellt. Dieses Vorgehen ist notwendig, da FMOD Ex Samples beliebig oft
- // gleichzeitig abspielen kann, Streams jedoch nur ein mal.
- if (FileSize <= MAX_SAMPLE_SIZE) {
- FMOD_CREATESOUNDEXINFO ExInfo;
- memset(&ExInfo, 0, sizeof(ExInfo));
- ExInfo.cbsize = sizeof(ExInfo);
- ExInfo.length = FileSize;
-
- FMOD_RESULT Result = FMOD_System_CreateSound(FMOD, FileDataPtr,
- FMOD_CREATESAMPLE | FMOD_OPENMEMORY | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
- &ExInfo,
- &m_SoundPtr);
- if (Result != FMOD_OK) BS_FMODExException("FMOD_System_CreateSound()", Result).Log();
-
- Success = Result == FMOD_OK;
-
- delete FileDataPtr;
- } else {
- m_SoundDataPtr = FileDataPtr;
- m_SoundDataSize = FileSize;
-
- Success = true;
- }
-}
-
-// -----------------------------------------------------------------------------
-
-BS_FMODExResource::~BS_FMODExResource() {
- // Sound freigeben, solange des Soundsystem noch läuft.
- // Sollte das Soundsystem beendet worden sein müssen und können Sounds nicht mehr freigegeben werden.
- if (m_SoundPtr && BS_Kernel::GetInstance()->GetService("sfx")) FMOD_Sound_Release(m_SoundPtr);
- if (m_SoundDataPtr) delete [] m_SoundDataPtr;
-}
-
-// -----------------------------------------------------------------------------
-// Abspielen
-// -----------------------------------------------------------------------------
-
-BS_FMODExChannel *BS_FMODExResource::StartSound(FMOD_SYSTEM *FMOD) {
- BS_ASSERT(FMOD);
-
- FMOD_CHANNEL *NewChannelPtr;
- FMOD_SOUND *NewSoundPtr = 0;
-
- // Sample können sofort abgespielt werden.
- if (m_SoundPtr) {
- FMOD_RESULT Result = FMOD_System_PlaySound(FMOD, FMOD_CHANNEL_FREE, m_SoundPtr, 1, &NewChannelPtr);
- if (Result != FMOD_OK) {
- BS_FMODExException("FMOD_System_PlaySound()", Result).Log();
- return 0;
- }
- }
- // Für Streams muss ein neuer Sound erstellt werden.
- else {
- FMOD_CREATESOUNDEXINFO ExInfo;
- memset(&ExInfo, 0, sizeof(ExInfo));
- ExInfo.cbsize = sizeof(ExInfo);
- ExInfo.length = m_SoundDataSize;
-
- FMOD_RESULT Result;
- Result = FMOD_System_CreateSound(FMOD,
- m_SoundDataPtr,
- FMOD_CREATESTREAM | FMOD_OPENMEMORY_POINT | FMOD_SOFTWARE | FMOD_2D | FMOD_LOOP_NORMAL,
- &ExInfo,
- &NewSoundPtr);
- if (Result != FMOD_OK) {
- BS_FMODExException("FMOD_System_CreateSound()", Result).Log();
- return 0;
- }
-
- Result = FMOD_System_PlaySound(FMOD, FMOD_CHANNEL_FREE, NewSoundPtr, 1, &NewChannelPtr);
- if (Result != FMOD_OK) {
- BS_FMODExException("FMOD_System_PlaySound()", Result).Log();
- return 0;
- }
- }
-
- // Der Channel und der Sound (bei Streams) werden an ein BS_FMODExChannel-Objekt übergeben.
- // Dieses Sorgt auch dafür, dass Channel und Sound korrekt zerstört werden.
- return new BS_FMODExChannel(NewChannelPtr, NewSoundPtr);
-}
diff --git a/engines/sword25/sfx/fmodexresource.h b/engines/sword25/sfx/fmodexresource.h
deleted file mode 100644
index f74fef5365..0000000000
--- a/engines/sword25/sfx/fmodexresource.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-#ifndef SWORD25_FMODRESOURCE_H
-#define SWORD25_FMODRESOURCE_H
-
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
-#include "sword25/kernel/common.h"
-#include "sword25/kernel/resource.h"
-
-// -----------------------------------------------------------------------------
-// Forward Declarations
-// -----------------------------------------------------------------------------
-
-class BS_FMODExChannel;
-struct FMOD_SOUND;
-struct FMOD_SYSTEM;
-
-// -----------------------------------------------------------------------------
-// Klassendefinition
-// -----------------------------------------------------------------------------
-
-class BS_FMODExResource : public BS_Resource {
-public:
- BS_FMODExResource(const std::string &FileName, FMOD_SYSTEM *FMOD, bool &Success);
- virtual ~BS_FMODExResource();
-
- BS_FMODExChannel *StartSound(FMOD_SYSTEM *FMOD);
-
-private:
- FMOD_SOUND *m_SoundPtr;
- char *m_SoundDataPtr;
- uint m_SoundDataSize;
-};
-
-#endif
diff --git a/engines/sword25/sfx/fmodexsound.cpp b/engines/sword25/sfx/fmodexsound.cpp
deleted file mode 100644
index c67db28401..0000000000
--- a/engines/sword25/sfx/fmodexsound.cpp
+++ /dev/null
@@ -1,886 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-// Die von der Engine ausgegebenen Soundhandles werden intern auf FMOD Ex Handles gemapped.
-// Diese Handles sind nur solange gültig, wie der Sound spielt. Falls danach versucht wird manipulierend auf den Sound zuzugreifen,
-// schlägt dieses ohne Fehlermeldung fehl.
-
-// -----------------------------------------------------------------------------
-// Logging
-// -----------------------------------------------------------------------------
-
-#define BS_LOG_PREFIX "FMODEXSOUND"
-
-// -----------------------------------------------------------------------------
-// Includes
-// -----------------------------------------------------------------------------
-
-#include "sword25/kernel/inputpersistenceblock.h"
-#include "sword25/kernel/outputpersistenceblock.h"
-#include "sword25/package/packagemanager.h"
-#include "sword25/sfx/fmodexsound.h"
-
-// -----------------------------------------------------------------------------
-// Konstanten und lokale Funktionen
-// -----------------------------------------------------------------------------
-
-namespace Sword25 {
-const float DEFAULT_MUSIC_VOLUME = 1.0f;
-const float DEFAULT_SPEECH_VOLUME = 1.0f;
-const float DEFAULT_SFX_VOLUME = 1.0f;
-const uint SOUNDTYPE_COUNT = 3;
-const uint INVALID_SOUND_HANDLE = 0xffffffff;
-
-// -------------------------------------------------------------------------
-
-#if 0
-inline float NormalizePanning(float Panning) {
- bool Corrected = false;
- float Result = Panning;
- if (Result > 1.0f) {
- Result = 1.0f;
- Corrected = true;
- }
- if (Result < -1.0f) {
- Result = -1.0f;
- Corrected = true;
- }
-
- if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid panning value of %.2f. It was corrected to %.2f", Panning, Result);
-
- return Result;
-}
-
-// -------------------------------------------------------------------------
-
-inline float NormalizeVolume(float Volume) {
- bool Corrected = false;
- float Result = Volume;
- if (Result > 1.0f) {
- Result = 1.0f;
- Corrected = true;
- }
- if (Result < 0.0f) {
- Result = 0.0f;
- Corrected = true;
- }
-
- if (Corrected) BS_LOG_WARNINGLN("Tried to set an invalid volume value of %.2f. It was corrected to %.2f", Volume, Result);
-
- return Result;
-}
-
-// -------------------------------------------------------------------------
-
-inline FMOD_SOUND_FORMAT BitsPerSampleToFMODExSoundFormat(uint BitsPerSample) {
- switch (BitsPerSample) {
- case 8:
- return FMOD_SOUND_FORMAT_PCM8;
- case 16:
- return FMOD_SOUND_FORMAT_PCM16;
- case 24:
- return FMOD_SOUND_FORMAT_PCM24;
- case 32:
- return FMOD_SOUND_FORMAT_PCM32;
- default:
- return FMOD_SOUND_FORMAT_NONE;
- }
-}
-
-#endif
-
-FMODExSound::FMODExSound(Kernel *pKernel) :
- SoundEngine(pKernel)
- /* m_FMOD(0),
- m_NextHandle(1) */ {
- // Lautstärkeneinstellungen auf die Standardwerte setzen
-#if 0
- m_Volumes[MUSIC] = DEFAULT_MUSIC_VOLUME;
- m_Volumes[SPEECH] = DEFAULT_SPEECH_VOLUME;
- m_Volumes[SFX] = DEFAULT_SFX_VOLUME;
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-FMODExSound::~FMODExSound() {
-#if 0
- // Alle noch spielenden Sounds stoppen und die Ressourcen freigeben
- for (PSM_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it) {
- if (it->second.ChannelPtr) delete it->second.ChannelPtr;
- if (it->second.ResourcePtr) it->second.ResourcePtr->Release();
- }
-
- // FMOD Ex deinitialisieren
- if (m_FMOD) FMOD_System_Release(m_FMOD);
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-Service *FMODExSound_CreateObject(Kernel *pKernel) {
- return new FMODExSound(pKernel);
-}
-
-// -----------------------------------------------------------------------------
-
-bool FMODExSound::Init(uint SampleRate, uint Channels) {
-#if 0
- // Eine Warnung ausgeben, wenn dieser Service schon initialisiert wurde.
- // Allerdings wird trotzdem true zurückgegeben, weil kein Fehler aufgetreten ist, der Service ist noch benutzbar.
- if (m_FMOD) {
- BS_LOG_WARNINGLN("Tried to initialize again. Call ignored.");
- return true;
- } else {
- try {
- // Die FMOD Ex mit den übergebenen Werte initialisieren
- FMOD_RESULT Result = FMOD_System_Create(&m_FMOD);
- if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Create()", Result));
-
- Result = FMOD_System_SetSoftwareFormat(m_FMOD, SampleRate, FMOD_SOUND_FORMAT_PCM16, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);
- if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_SetSoftwareFormat()", Result));
-
- Result = FMOD_System_Init(m_FMOD, Channels, FMOD_INIT_NORMAL, 0);
- if (Result != FMOD_OK) throw(BS_FMODExException("FMOD_System_Init()", Result));
- }
-
- catch (BS_FMODExException Ex) {
- Ex.Log();
- BS_LOG_ERRORLN("FMOD Ex could not be initialized.");
-
- if (m_FMOD) {
- FMOD_System_Release(m_FMOD);
- m_FMOD = 0;
- }
-
- return false;
- }
-
- BS_LOGLN("FMOD Ex initialized. Sample rate: %d / Channels: %d", SampleRate, Channels);
- return true;
- }
-#else
- return true;
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::Update() {
-#if 0
- BS_ASSERT(m_FMOD);
-
- FMOD_RESULT Result = FMOD_System_Update(m_FMOD);
- if (Result != FMOD_OK) BS_FMODExException("FMOD_System_Update()", Result).Log();
-
- RemoveInactiveSounds();
-#endif
-}
-
-// -----------------------------------------------------------------------------
-// Sounds abspielen
-// -----------------------------------------------------------------------------
-
-bool FMODExSound::PlaySound(const Common::String &FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- uint Layer) {
-#if 0
- return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0) != 0;
-#else
- return true;
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-uint FMODExSound::PlaySoundEx(const Common::String &FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- uint Layer) {
-#if 0
- return PlaySoundInternal(FileName, Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, 0, 0);
-#else
- return true;
-#endif
-}
-
-// -------------------------------------------------------------------------
-
-#if 0
-FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundSetPosCallback(FMOD_SOUND *sound, int subsound, uint position, FMOD_TIMEUNIT postype) {
- // In dynamischen Sounds wird nicht gesprungen, daher tut dieses Funktion nichts.
- return FMOD_OK;
-}
-
-// -------------------------------------------------------------------------
-
-FMOD_RESULT F_CALLBACK BS_FMODExSound::FMODExDynamicSoundReadCallback(FMOD_SOUND *sound, void *data, uint datalen) {
- // Handle auf das aktuelle Soundsystem holen, dies ist wohl dieses hier.
- BS_FMODExSound *t = reinterpret_cast<BS_FMODExSound *>(BS_Kernel::GetInstance()->GetSfx());
-
- // Handle auf den richtigen Sound holen, wurde als FMOD Ex Benutzerdaten gesetzt.
- uint Handle;
- FMOD_RESULT Result = FMOD_Sound_GetUserData(sound, reinterpret_cast<void **>(&Handle));
- if (Result != FMOD_OK) {
- BS_FMODExException("FMOD_Sound_GetUserData()", Result).Log();
- return FMOD_OK;
- }
-
- // Sounddaten holen und Callbackfunktion aufrufen.
- PlayingSoundData *PSD = t->GetPlayingSoundDataByHandle(Handle);
- if (PSD) PSD->ReadCallback(PSD->UserData, data, datalen);
-
- return FMOD_OK;
-}
-#endif
-// -----------------------------------------------------------------------------
-
-uint FMODExSound::PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback,
- void *UserData,
- SOUND_TYPES Type,
- uint SampleRate,
- uint BitsPerSample,
- uint Channels,
- float Volume,
- float Pan,
- uint Layer) {
-#if 0
- // Parameter überprüfen
- if (BitsPerSampleToFMODExSoundFormat(BitsPerSample) == FMOD_SOUND_FORMAT_NONE) {
- BS_LOG_ERRORLN("Cannot create a dynamic sound with %d bits per sample.", BitsPerSample);
- return 0;
- }
- if (Channels == 0 || Channels > 2) {
- BS_LOG_ERRORLN("Cannot create a dynamic sound with %d channels.", Channels);
- return 0;
- }
-
- // Zu vergebendes Handle bestimmen
- uint Handle = m_NextHandle++;
-
- // Sound in die Sound-Map eintragen mit all den Informationen, die wir bisher haben.
- // Dies muss für dynamische Sounds so früh geschehen, da sofort nach dem Aufruf von FMOD_System_CreateSound der Callback aufgerufen wird um
- // den Decode-Buffer zu füllen. Unser Callback liest den BS-Callback aus der Sound-Map. Wenn wir den Sound später hinzufügen würden, würde der
- // BS-Callback zu diesem Sound nicht in der Map stehen und nicht aufgerufen werden können.
- // Den fehlenden ChannelPtr tragen wir später in dieser Funktion ein.
- m_PlayingSoundsMap[Handle] = PlayingSoundData(0, 0, Type, Layer, Volume, ReadCallback, UserData);
-
- // Dynamischen FMOD Ex Sound erstellen
- FMOD_CREATESOUNDEXINFO CreateSoundExInfo;
- memset(&CreateSoundExInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
- CreateSoundExInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
- CreateSoundExInfo.length = 0xffffffff;
- CreateSoundExInfo.numchannels = Channels;
- CreateSoundExInfo.defaultfrequency = SampleRate;
- CreateSoundExInfo.format = BitsPerSampleToFMODExSoundFormat(BitsPerSample);
- CreateSoundExInfo.pcmreadcallback = FMODExDynamicSoundReadCallback;
- CreateSoundExInfo.pcmsetposcallback = FMODExDynamicSoundSetPosCallback;
- CreateSoundExInfo.userdata = reinterpret_cast<void *>(Handle);
-
- FMOD_SOUND *FMODExSoundPtr;
- FMOD_RESULT Result = FMOD_System_CreateSound(m_FMOD,
- 0,
- FMOD_2D | FMOD_OPENUSER | FMOD_LOOP_NORMAL | FMOD_HARDWARE | FMOD_CREATESTREAM,
- &CreateSoundExInfo,
- &FMODExSoundPtr);
- if (Result != FMOD_OK) {
- BS_FMODExException("FMOD_System_CreateSound() from PlayDynamicSoundEx()", Result).Log();
- return 0;
- }
-
- // Neu erstellten Sound einem Kanal zuweisen
- FMOD_CHANNEL *FMODExChannelPtr;
- Result = FMOD_System_PlaySound(m_FMOD, FMOD_CHANNEL_FREE, FMODExSoundPtr, 1, &FMODExChannelPtr);
- if (Result != FMOD_OK) {
- BS_FMODExException("FMOD_System_PlaySound() from PlayDynamicSoundEx()", Result).Log();
- return 0;
- }
-
- // FMOD Ex Kanal an einen BS_FMODExChannel binden und abspielen
- BS_FMODExChannel *ChannelPtr = new BS_FMODExChannel(FMODExChannelPtr, FMODExSoundPtr);
- ChannelPtr->SetPaused(false);
-
- // ChannelPtr in die PlayingSoundData-Struktur eintragen
- PlayingSoundData *PSD = GetPlayingSoundDataByHandle(Handle);
- if (PSD) PSD->ChannelPtr = ChannelPtr;
-
- return Handle;
-#else
- return 0;
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-#if 0
-uint BS_FMODExSound::PlaySoundInternal(const Common::String &FileName,
- SOUND_TYPES Type,
- float Volume,
- float Pan,
- bool Loop,
- int LoopStart, int LoopEnd,
- uint Layer,
- uint Position,
- uint Handle) {
- BS_ASSERT(m_FMOD);
- BS_ASSERT(Type < SOUNDTYPE_COUNT);
-
- // Resource anfordern
- BS_Resource *ResourcePtr = BS_Kernel::GetInstance()->GetResourceManager()->RequestResource(FileName);
- if (!ResourcePtr) {
- BS_LOG_ERRORLN("Could not request resource \"%s\".", FileName.c_str());
- return 0;
- }
- if (ResourcePtr->GetType() != BS_Resource::TYPE_SOUND) {
- BS_LOG_ERRORLN("Requested resource \"%s\" is not a sound.", FileName.c_str());
- return 0;
- }
- BS_FMODExResource *SoundResourcePtr = static_cast<BS_FMODExResource *>(ResourcePtr);
-
- // Sound im Pause-Modus starten
- BS_FMODExChannel *ChannelPtr = SoundResourcePtr->StartSound(m_FMOD);
-
- if (ChannelPtr) {
- try {
- // Falls der Sound gelooped wird, Loop-Points setzen
- if (Loop) {
- // Bestimmen, welche Loop-Points benutzt werden. Falls ein Loop-Point als Parameter nicht spezifiziert wurde (Wert -1),
- // wird der Loop-Point von FMOD Ex benutzt.
- uint RealLoopStart = (LoopStart > 0) ? LoopStart : ChannelPtr->GetLoopStart();
- uint RealLoopEnd = (LoopEnd > 0) ? LoopEnd : ChannelPtr->GetLoopEnd();
-
- // Loop-Points auf Gültigkeit überprüfen
- if (RealLoopStart > RealLoopEnd) {
- BS_LOG_ERRORLN("Loop start (%d) was placed after loop end (%d) for sound \"%s\".",
- RealLoopStart, RealLoopEnd,
- SoundResourcePtr->GetFileName().c_str());
- throw(0);
- }
- if (RealLoopStart > ChannelPtr->GetLoopEnd()) {
- BS_LOG_ERRORLN("Loop start (%d) was placed after end (%d) of sound \"%s\".",
- RealLoopStart,
- ChannelPtr->GetLoopEnd(),
- SoundResourcePtr->GetFileName().c_str());
- throw(0);
- }
- if (RealLoopEnd > ChannelPtr->GetLoopEnd()) {
- BS_LOG_ERRORLN("Loop end (%d) was placed after end (%d) of sound \"%s\".",
- RealLoopEnd,
- ChannelPtr->GetLoopEnd(),
- SoundResourcePtr->GetFileName().c_str());
- throw(0);
- }
-
- // Loop-Points setzen
- if (!ChannelPtr->SetLoopPoints(RealLoopStart, RealLoopEnd)) throw(0);
- }
-
- // Sound-Parameter gemäß der Übergabeparameter setzen
- if (!ChannelPtr->SetVolume(NormalizeVolume(Volume) * m_Volumes[Type])) throw(0);
- if (!ChannelPtr->SetPanning(NormalizePanning(Pan))) throw(0);
- if (!ChannelPtr->SetLoop(Loop)) throw(0);
- if (!ChannelPtr->SetPosition(Position)) throw(0);
- } catch (...) {
- delete ChannelPtr;
- SoundResourcePtr->Release();
- return 0;
- }
-
- uint MyLoopStart = ChannelPtr->GetLoopStart();
- uint MyLoopEnd = ChannelPtr->GetLoopEnd();
- ChannelPtr->SetLoopPoints(MyLoopStart, MyLoopEnd);
-
- // Sound abspielen
- ChannelPtr->SetPaused(false);
-
- // Sound in die Sound-Map eintragen
- uint NewHandle = (Handle != 0) ? Handle : m_NextHandle++;
- m_PlayingSoundsMap[NewHandle] = PlayingSoundData(SoundResourcePtr, ChannelPtr, Type, Layer, Volume);
-
- return NewHandle;
- } else {
- SoundResourcePtr->Release();
- return 0;
- }
-}
-#endif
-// -----------------------------------------------------------------------------
-// Sonstige Methoden
-// -----------------------------------------------------------------------------
-
-void FMODExSound::SetVolume(float Volume, SOUND_TYPES Type) {
-#if 0
- BS_ASSERT(m_FMOD);
- BS_ASSERT(Type < SOUNDTYPE_COUNT);
- m_Volumes[Type] = NormalizeVolume(Volume);
-
- // Alle Volumen der Sounds der Kategorie aktualisieren
- PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end()) {
- const PlayingSoundData &PSD = it->second;
- if (PSD.ChannelPtr && PSD.Type == Type) PSD.ChannelPtr->SetVolume(Volume * PSD.Volume);
-
- ++it;
- }
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-float FMODExSound::GetVolume(SOUND_TYPES Type) {
-#if 0
- BS_ASSERT(m_FMOD);
- BS_ASSERT(Type < SOUNDTYPE_COUNT);
- return m_Volumes[Type];
-#else
- return 0;
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::PauseAll() {
-#if 0
- BS_ASSERT(m_FMOD);
-
- // Alle Sounds durchgehen und alle pausieren.
- // Diese werden dann markiert, damit ResumeAll() feststellen kann, welche Sounds mit PauseAll() pausiert wurden.
- // ResumeAll() setzt dann nur diejenigen fort, die nur über PauseAll() pausiert wurden.
- PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end()) {
- PlayingSoundData &PSD = it->second;
-
- if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
- PSD.PausedGlobal = true;
-
- ++it;
- }
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::ResumeAll() {
-#if 0
- BS_ASSERT(m_FMOD);
-
- // Alle Sounds durchgehen, die gloable Pause aufheben und diejenigen fortsetzen,
- // die keine Pause mehr haben (weder explizit, über den Layer oder global).
- PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end()) {
- PlayingSoundData &PSD = it->second;
-
- if (PSD.PausedGlobal) {
- PSD.PausedGlobal = false;
- if (PSD.ChannelPtr && !PSD.PausedLayer && !PSD.Paused) PSD.ChannelPtr->SetPaused(false);
- }
-
- ++it;
- }
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::PauseLayer(uint Layer) {
-#if 0
- BS_ASSERT(m_FMOD);
-
- // Alle Sounds durchgehen und alle pausieren, die sich auf den angegebenen Layer befinden.
- // Diese werden dann markiert, damit ResumeLayer() feststellen kann, welche Sounds mit PauseLayer() pausiert wurden.
- // ResumeLayer() setzt dann nur diejenigen fort, die nur über PauseLayer() mit der entsprechenden Layer-Nummer pausiert wurden.
- PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end()) {
- PlayingSoundData &PSD = it->second;
-
- if (PSD.Layer == Layer) {
- if (PSD.ChannelPtr) PSD.ChannelPtr->SetPaused(true);
- PSD.PausedLayer = true;
- }
-
- ++it;
- }
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::ResumeLayer(uint Layer) {
-#if 0
- BS_ASSERT(m_FMOD);
-
- // Alle Sounds durchgehen, die Layer-Pause aufheben und diejenigen fortsetzen,
- // die keine Pause mehr haben (weder explizit, über den Layer oder global).
- PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end()) {
- PlayingSoundData &PSD = it->second;
-
- if (PSD.PausedLayer && PSD.Layer == Layer) {
- PSD.PausedLayer = false;
- if (PSD.ChannelPtr && !PSD.PausedGlobal && !PSD.Paused) PSD.ChannelPtr->SetPaused(false);
- }
-
- ++it;
- }
-#endif
-}
-
-// -----------------------------------------------------------------------------
-// Sound Setter
-// -----------------------------------------------------------------------------
-
-void FMODExSound::SetSoundVolume(uint Handle, float Volume) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr) if (PSDPtr->ChannelPtr && PSDPtr->ChannelPtr->SetVolume(NormalizeVolume(Volume) * m_Volumes[PSDPtr->Type])) PSDPtr->Volume = Volume;
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::SetSoundPanning(uint Handle, float Pan) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPanning(NormalizePanning(Pan));
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::PauseSound(uint Handle) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr) {
- PSDPtr->Paused = true;
- if (PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->SetPaused(true);
- }
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::ResumeSound(uint Handle) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr) {
- PSDPtr->Paused = false;
- if (PSDPtr->ChannelPtr && !PSDPtr->PausedGlobal && !PSDPtr->PausedLayer) PSDPtr->ChannelPtr->SetPaused(false);
- }
-#endif
-}
-
-// -----------------------------------------------------------------------------
-
-void FMODExSound::StopSound(uint Handle) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr && PSDPtr->ChannelPtr) PSDPtr->ChannelPtr->Stop();
-#endif
-}
-
-// -----------------------------------------------------------------------------
-// Sound Getter
-// -----------------------------------------------------------------------------
-
-bool FMODExSound::IsSoundPaused(uint Handle) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPaused();
-#endif
- return false;
-}
-
-// -----------------------------------------------------------------------------
-
-bool FMODExSound::IsSoundPlaying(uint Handle) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->IsPlaying();
-#endif
- return false;
-}
-
-// -----------------------------------------------------------------------------
-
-float FMODExSound::GetSoundVolume(uint Handle) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr) return PSDPtr->Volume;
-#endif
- return 0;
-}
-
-// -----------------------------------------------------------------------------
-
-float FMODExSound::GetSoundPanning(uint Handle) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr && PSDPtr->ChannelPtr) return PSDPtr->ChannelPtr->GetPanning();
-#endif
- return 0;
-}
-
-// -----------------------------------------------------------------------------
-
-float FMODExSound::GetSoundTime(uint Handle) {
-#if 0
- BS_ASSERT(m_FMOD);
- PlayingSoundData *PSDPtr = GetPlayingSoundDataByHandle(Handle);
- if (PSDPtr && PSDPtr->ChannelPtr) return static_cast<float>(PSDPtr->ChannelPtr->GetTime()) / 1000.0f;
-#endif
- return 0;
-}
-
-#if 0
-void BS_FMODExSound::RemoveInactiveSounds() {
- PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end()) {
- if (!it->second.ChannelPtr || !it->second.ChannelPtr->IsPlaying()) {
- PlayingSoundData &PSD = it->second;
-
- delete PSD.ChannelPtr;
- if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
-
- it = m_PlayingSoundsMap.erase(it);
- } else
- ++it;
- }
-
- /*
- static size_t lastActiveChannels = 0;
- if (m_PlayingSoundsMap.size() != lastActiveChannels)
- {
- BS_LOGLN("Aktive Kanaele: %d", m_PlayingSoundsMap.size());
- lastActiveChannels = m_PlayingSoundsMap.size();
- }
- */
-}
-
-// -----------------------------------------------------------------------------
-
-BS_FMODExSound::PlayingSoundData *BS_FMODExSound::GetPlayingSoundDataByHandle(uint Handle) {
- // Zum Soundhandle gehörige Daten in der Hash-Map finden
- PSM_ITER it = m_PlayingSoundsMap.find(Handle);
- // Falls die Daten nicht gefunden werden konnten, Fehler zurückgebene, ansonsten ein Pointer auf die Daten.
- if (it == m_PlayingSoundsMap.end()) return 0;
- return &((*it).second);
-}
-
-// -----------------------------------------------------------------------------
-
-uint BS_FMODExSound::CountPlayingDynamicSounds() {
- uint Result = 0;
- for (PSM_CONST_ITER it = m_PlayingSoundsMap.begin(); it != m_PlayingSoundsMap.end(); ++it) if (!it->second.ResourcePtr) ++Result;
-
- return Result;
-}
-#endif
-
-// -----------------------------------------------------------------------------
-// Ressourcen-Verwaltung
-// -----------------------------------------------------------------------------
-
-Resource *FMODExSound::LoadResource(const Common::String &FileName) {
-#if 0
- BS_ASSERT(m_FMOD);
- BS_ASSERT(CanLoadResource(FileName));
-
- bool Success;
- BS_FMODExResource *ResourcePtr = new BS_FMODExResource(FileName, m_FMOD, Success);
- if (Success)
- return ResourcePtr;
- else {
- delete ResourcePtr;
- return 0;
- }
-#else
- return 0;
-#endif
-}
-bool FMODExSound::CanLoadResource(const Common::String &FileName) {
-#if 0
- if (FileName.size() >= 4) {
- Common::String Extension(FileName.end() - 4, FileName.end());
- BS_String::ToLower(Extension);
-
- return Extension == ".wav" ||
- Extension == ".ogg" ||
- Extension == ".mp3";
- } else
- return false;
-#else
- return true;
-#endif
-}
-
-// -----------------------------------------------------------------------------
-// Persistenz
-// -----------------------------------------------------------------------------
-
-bool FMODExSound::persist(OutputPersistenceBlock &writer) {
-#if 0
- BS_ASSERT(m_FMOD);
-
- // Alle inaktiven Sounds entfernen, damit kein unnötiger Ballast gespeichert wird
- RemoveInactiveSounds();
-
- // Warnung ausgeben, wenn dynamische Sounds abgespielt werden
- uint PlayingDynamicSounds = CountPlayingDynamicSounds();
- if (PlayingDynamicSounds) BS_LOG_WARNINGLN("There are currently dynamic sounds playing. These will not be persisted.");
-
- // Nächstes Handle speichern
- Writer.Write(m_NextHandle);
-
- // Anzahl spielender (nicht dynamischer) Sounds speichern
- Writer.Write(m_PlayingSoundsMap.size() - PlayingDynamicSounds);
-
- // Informationen für jeden spielenden (nicht dynamischen) Sound speichern
- PSM_CONST_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end()) {
- const PlayingSoundData &PSD = it->second;
-
- if (PSD.ResourcePtr) {
- // Handle speichern
- Writer.Write(it->first);
-
- // Soundeigenschaften speichern
- Writer.Write(PSD.ResourcePtr->GetFileName());
- Writer.Write(static_cast<uint>(PSD.Type));
- Writer.Write(PSD.Layer);
-
- Writer.Write(PSD.Volume);
- Writer.Write(PSD.ChannelPtr->GetPanning());
- Writer.Write(PSD.ChannelPtr->IsLooping());
- Writer.Write(PSD.ChannelPtr->GetLoopStart());
- Writer.Write(PSD.ChannelPtr->GetLoopEnd());
- Writer.Write(PSD.ChannelPtr->GetPosition());
- Writer.Write(PSD.Paused);
- Writer.Write(PSD.PausedLayer);
- Writer.Write(PSD.PausedGlobal);
- }
-
- ++it;
- }
-
-#endif
- return true;
-}
-
-// -----------------------------------------------------------------------------
-
-bool FMODExSound::unpersist(InputPersistenceBlock &reader) {
-#if 0
- BS_ASSERT(m_FMOD);
-
- // Alle Sounds stoppen
- PSM_ITER it = m_PlayingSoundsMap.begin();
- while (it != m_PlayingSoundsMap.end()) {
- const PlayingSoundData &PSD = it->second;
- if (PSD.ChannelPtr) delete PSD.ChannelPtr;
- if (PSD.ResourcePtr) PSD.ResourcePtr->Release();
- ++it;
- }
-
- // Sound-Map leeren
- m_PlayingSoundsMap.clear();
-
- // Nächstes Handle laden
- Reader.Read(m_NextHandle);
-
- // Soundanzahl einlesen
- uint SoundCount = 0;
- Reader.Read(SoundCount);
-
- // Informationen über jeden spielenden Sound einlesen und ihn mit den Parametern abspielen
- for (uint i = 0; i < SoundCount; ++i) {
- uint Handle;
- Common::String FileName;
- uint Type;
- uint Layer;
-
- float Volume;
- float Pan;
- bool Loop;
- uint LoopStart;
- uint LoopEnd;
- uint Position;
- bool Paused;
- bool PausedLayer;
- bool PausedGlobal;
-
- Reader.Read(Handle);
- Reader.Read(FileName);
- Reader.Read(Type);
- Reader.Read(Layer);
-
- Reader.Read(Volume);
- Reader.Read(Pan);
- Reader.Read(Loop);
- Reader.Read(LoopStart);
- Reader.Read(LoopEnd);
- Reader.Read(Position);
- Reader.Read(Paused);
- Reader.Read(PausedLayer);
- Reader.Read(PausedGlobal);
-
- if (Reader.IsGood()) {
- PlaySoundInternal(FileName, (SOUND_TYPES) Type, Volume, Pan, Loop, LoopStart, LoopEnd, Layer, Position, Handle);
- } else {
- return false;
- }
- }
-
- return Reader.IsGood();
-#else
- return true;
-#endif
-}
-
-} // End of namespace Sword25
diff --git a/engines/sword25/sfx/fmodexsound.h b/engines/sword25/sfx/fmodexsound.h
deleted file mode 100644
index b599334d1c..0000000000
--- a/engines/sword25/sfx/fmodexsound.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-#ifndef SWORD25_FMODEXSOUND_H
-#define SWORD25_FMODEXSOUND_H
-
-#include "sword25/sfx/soundengine.h"
-
-namespace Sword25 {
-
-class FMODExSound : public SoundEngine {
-public:
- // -----------------------------------------------------------------------------
- // Konstruktion / Destruktion
- // -----------------------------------------------------------------------------
-
- FMODExSound(Kernel *pKernel);
- virtual ~FMODExSound();
-
- bool Init(uint SampleRate, uint Channels = 32);
- void Update();
- void SetVolume(float Volume, SOUND_TYPES Type);
- float GetVolume(SOUND_TYPES Type);
- void PauseAll();
- void ResumeAll();
- void PauseLayer(uint Layer);
- void ResumeLayer(uint Layer);
- bool PlaySound(const Common::String &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, uint Layer);
- uint PlaySoundEx(const Common::String &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, uint Layer);
- uint PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void *UserData, SOUND_TYPES Type, uint SampleRate, uint BitsPerSample, uint Channels, float Volume = 1.0f, float Pan = 0.0f, uint Layer = 0);
-
- void SetSoundVolume(uint Handle, float Volume);
- void SetSoundPanning(uint Handle, float Pan);
- void PauseSound(uint Handle);
- void ResumeSound(uint Handle);
- void StopSound(uint Handle);
- bool IsSoundPaused(uint Handle);
- bool IsSoundPlaying(uint Handle);
- float GetSoundVolume(uint Handle);
- float GetSoundPanning(uint Handle);
- float GetSoundTime(uint Handle);
-
- Resource *LoadResource(const Common::String &FileName);
- bool CanLoadResource(const Common::String &FileName);
-
- // -----------------------------------------------------------------------------
- // Persistenz
- // -----------------------------------------------------------------------------
-
- bool persist(OutputPersistenceBlock &writer);
- bool unpersist(InputPersistenceBlock &reader);
-
-#if 0
-private:
- struct PlayingSoundData {
- PlayingSoundData() {};
- PlayingSoundData(BS_Resource *ResourcePtr_, BS_FMODExChannel *ChannelPtr_, SOUND_TYPES Type_, uint Layer_, float Volume_, DynamicSoundReadCallback ReadCallback_ = 0, void *UserData_ = 0) :
- ResourcePtr(ResourcePtr_),
- ChannelPtr(ChannelPtr_),
- Type(Type_),
- Layer(Layer_),
- Volume(Volume_),
- ReadCallback(ReadCallback_),
- UserData(UserData_),
- Paused(false),
- PausedLayer(false),
- PausedGlobal(false)
- {}
-
- BS_Resource *ResourcePtr;
- BS_FMODExChannel *ChannelPtr;
- SOUND_TYPES Type;
- uint Layer;
- DynamicSoundReadCallback ReadCallback;
- void *UserData;
-
- float Volume;
- bool Paused;
- bool PausedLayer;
- bool PausedGlobal;
- };
-
- typedef BS_Hashmap<uint, PlayingSoundData> PSM;
- typedef BS_Hashmap<uint, PlayingSoundData>::iterator PSM_ITER;
- typedef BS_Hashmap<uint, PlayingSoundData>::const_iterator PSM_CONST_ITER;
- PSM m_PlayingSoundsMap;
-
- FMOD_SYSTEM *m_FMOD;
- float m_Volumes[3];
- uint m_NextHandle;
-
- void RemoveInactiveSounds();
- PlayingSoundData *GetPlayingSoundDataByHandle(uint Handle);
- uint PlaySoundInternal(const Common::String &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, uint Layer, uint Handle, uint Position);
- uint CountPlayingDynamicSounds();
-
- static FMOD_RESULT F_CALLBACK FMODExDynamicSoundSetPosCallback(FMOD_SOUND *sound, int subsound, uint position, FMOD_TIMEUNIT postype);
- static FMOD_RESULT F_CALLBACK FMODExDynamicSoundReadCallback(FMOD_SOUND *sound, void *data, uint datalen);
- static FMOD_RESULT F_CALLBACK DSPReadCallback(FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, uint length, int inchannels, int outchannels);
-#endif
-};
-
-} // End of namespace Sword25
-
-#endif
diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp
index 022d58b4b4..cd83085e44 100644
--- a/engines/sword25/sfx/soundengine.cpp
+++ b/engines/sword25/sfx/soundengine.cpp
@@ -43,6 +43,107 @@ SoundEngine::SoundEngine(Kernel *pKernel) : ResourceService(pKernel) {
BS_LOG_ERRORLN("Script bindings could not be registered.");
else
BS_LOGLN("Script bindings registered.");
+
+ _mixer = g_system->getMixer();
+}
+
+Service *SoundEngine_CreateObject(Kernel *pKernel) {
+ return new SoundEngine(pKernel);
+}
+
+bool SoundEngine::Init(uint SampleRate, uint Channels) {
+ return true;
+}
+
+void SoundEngine::Update() {
+}
+
+void SoundEngine::SetVolume(float Volume, SOUND_TYPES Type) {
+}
+
+float SoundEngine::GetVolume(SOUND_TYPES Type) {
+ return 0;
+}
+
+void SoundEngine::PauseAll() {
+}
+
+void SoundEngine::ResumeAll() {
+}
+
+void SoundEngine::PauseLayer(uint Layer) {
+}
+
+void SoundEngine::ResumeLayer(uint Layer) {
+}
+
+bool SoundEngine::PlaySound(const Common::String &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, uint Layer) {
+ return true;
+}
+
+uint SoundEngine::PlaySoundEx(const Common::String &FileName, SOUND_TYPES Type, float Volume, float Pan, bool Loop, int LoopStart, int LoopEnd, uint Layer) {
+ return 0;
+}
+
+void SoundEngine::SetSoundVolume(uint Handle, float Volume) {
+}
+
+void SoundEngine::SetSoundPanning(uint Handle, float Pan) {
+}
+
+void SoundEngine::PauseSound(uint Handle) {
}
+void SoundEngine::ResumeSound(uint Handle) {
+}
+
+void SoundEngine::StopSound(uint Handle) {
+}
+
+bool SoundEngine::IsSoundPaused(uint Handle) {
+ return false;
+}
+
+bool SoundEngine::IsSoundPlaying(uint Handle) {
+ return false;
+}
+
+float SoundEngine::GetSoundVolume(uint Handle) {
+ return 0;
+}
+
+float SoundEngine::GetSoundPanning(uint Handle) {
+ return 0;
+}
+
+float SoundEngine::GetSoundTime(uint Handle) {
+ return 0;
+}
+
+Resource *SoundEngine::LoadResource(const Common::String &FileName) {
+ return 0;
+}
+
+bool SoundEngine::CanLoadResource(const Common::String &fileName) {
+ Common::String fname = fileName;
+
+ fname.toLowercase();
+
+ return fname.hasSuffix(".ogg");
+}
+
+
+bool SoundEngine::persist(OutputPersistenceBlock &writer) {
+ warning("STUB: SoundEngine::persist()");
+
+ return true;
+}
+
+bool SoundEngine::unpersist(InputPersistenceBlock &reader) {
+ warning("STUB: SoundEngine::unpersist()");
+
+ return true;
+}
+
+
} // End of namespace Sword25
diff --git a/engines/sword25/sfx/soundengine.h b/engines/sword25/sfx/soundengine.h
index 6c67c9c531..2bc29cdd1e 100644
--- a/engines/sword25/sfx/soundengine.h
+++ b/engines/sword25/sfx/soundengine.h
@@ -56,6 +56,9 @@
#include "sword25/kernel/resservice.h"
#include "sword25/kernel/persistable.h"
+#include "sound/audiostream.h"
+#include "sound/mixer.h"
+
namespace Sword25 {
// -----------------------------------------------------------------------------
@@ -87,7 +90,7 @@ public:
// -----------------------------------------------------------------------------
SoundEngine(Kernel *pKernel);
- virtual ~SoundEngine() {};
+ ~SoundEngine() {};
// --------------------------------------------------------------
// THIS METHOD MUST BE IMPLEMENTED BY THE SOUND ENGINE
@@ -101,7 +104,7 @@ public:
* @remark Calls to other methods may take place only if this
* method was called successfully.
*/
- virtual bool Init(uint SampleRate, uint Channels = 32) = 0;
+ bool Init(uint SampleRate, uint Channels = 32);
/**
* Performs a "tick" of the sound engine
@@ -110,14 +113,14 @@ public:
* of the sound engine that are not running in their own thread, or to perform
* additional administrative tasks that are needed.
*/
- virtual void Update() = 0;
+ void Update();
/**
* Sets the default volume for the different sound types
* @param Volume The default volume level (0 = off, 1 = full volume)
* @param Type The SoundType whose volume is to be changed
*/
- virtual void SetVolume(float Volume, SOUND_TYPES Type) = 0;
+ void SetVolume(float Volume, SOUND_TYPES Type);
/**
* Specifies the default volume of different sound types
@@ -125,29 +128,29 @@ public:
* @return Returns the standard sound volume for the given type
* (0 = off, 1 = full volume).
*/
- virtual float GetVolume(SOUND_TYPES Type) = 0;
+ float GetVolume(SOUND_TYPES Type);
/**
* Pauses all the sounds that are playing.
*/
- virtual void PauseAll() = 0;
+ void PauseAll();
/**
* Resumes all currently stopped sounds
*/
- virtual void ResumeAll() = 0;
+ void ResumeAll();
/**
* Pauses all sounds of a given layer.
* @param Layer The Sound Layer
*/
- virtual void PauseLayer(uint Layer) = 0;
+ void PauseLayer(uint Layer);
/**
* Resumes all the sounds in a layer that was previously stopped with PauseLayer()
* @param Layer The Sound Layer
*/
- virtual void ResumeLayer(uint Layer) = 0;
+ void ResumeLayer(uint Layer);
/**
@@ -166,7 +169,7 @@ public:
* @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
- virtual bool PlaySound(const Common::String &FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, uint Layer = 0) = 0;
+ bool PlaySound(const Common::String &FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, uint Layer = 0);
/**
* Plays a sound
@@ -183,7 +186,7 @@ public:
* @remark If more control is needed over the playing, eg. changing the sound parameters
* for Volume and Panning, then PlaySoundEx should be used.
*/
- virtual uint PlaySoundEx(const Common::String &FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, uint Layer = 0) = 0;
+ uint PlaySoundEx(const Common::String &FileName, SOUND_TYPES Type, float Volume = 1.0f, float Pan = 0.0f, bool Loop = false, int LoopStart = -1, int LoopEnd = -1, uint Layer = 0);
/**
* Plays a sound generated at runtime
@@ -202,72 +205,81 @@ public:
* @return Returns a handle to the sound. With this handle, the sound can be manipulated during playback.
* @remark Dynamic sounds cannot be persisted.
*/
- virtual uint PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void *UserData, SOUND_TYPES Type, uint SampleRate, uint BitsPerSample, uint Channels, float Volume = 1.0f, float Pan = 0.0f, uint Layer = 0) = 0;
+ uint PlayDynamicSoundEx(DynamicSoundReadCallback ReadCallback, void *UserData, SOUND_TYPES Type, uint SampleRate, uint BitsPerSample, uint Channels, float Volume = 1.0f, float Pan = 0.0f, uint Layer = 0);
/**
* Sets the volume of a playing sound
* @param Handle The sound handle
* @param Volume The volume of the sound (0 = off, 1 = full volume)
*/
- virtual void SetSoundVolume(uint Handle, float Volume) = 0;
+ void SetSoundVolume(uint Handle, float Volume);
/**
* Sets the panning of a playing sound
* @param Handle The sound handle
* @param Pan Panning (-1 = full left, 1 = right)
*/
- virtual void SetSoundPanning(uint Handle, float Pan) = 0;
+ void SetSoundPanning(uint Handle, float Pan);
/**
* Pauses a playing sound
* @param Handle The sound handle
*/
- virtual void PauseSound(uint Handle) = 0;
+ void PauseSound(uint Handle);
/**
* Resumes a paused sound
* @param Handle The sound handle
*/
- virtual void ResumeSound(uint Handle) = 0;
+ void ResumeSound(uint Handle);
/**
* Stops a playing sound
* @param Handle The sound handle
* @remark Calling this method invalidates the passed handle; it can no longer be used.
*/
- virtual void StopSound(uint Handle) = 0;
+ void StopSound(uint Handle);
/**
* Returns whether a sound is paused
* @param Handle The sound handle
* @return Returns true if the sound is paused, false otherwise.
*/
- virtual bool IsSoundPaused(uint Handle) = 0;
+ bool IsSoundPaused(uint Handle);
/**
* Returns whether a sound is still playing.
* @param Handle The sound handle
* @return Returns true if the sound is playing, false otherwise.
*/
- virtual bool IsSoundPlaying(uint Handle) = 0;
+ bool IsSoundPlaying(uint Handle);
/**
* Returns the volume of a playing sound (0 = off, 1 = full volume)
*/
- virtual float GetSoundVolume(uint Handle) = 0;
+ float GetSoundVolume(uint Handle);
/**
* Returns the panning of a playing sound (-1 = full left, 1 = right)
*/
- virtual float GetSoundPanning(uint Handle) = 0;
+ float GetSoundPanning(uint Handle);
/**
* Returns the position within a playing sound in seconds
*/
- virtual float GetSoundTime(uint Handle) = 0;
+ float GetSoundTime(uint Handle);
+
+ Resource *LoadResource(const Common::String &FileName);
+ bool CanLoadResource(const Common::String &FileName);
+
+ bool persist(OutputPersistenceBlock &writer);
+ bool unpersist(InputPersistenceBlock &reader);
private:
bool _RegisterScriptBindings();
+
+private:
+ Audio::Mixer *_mixer;
};
} // End of namespace Sword25