aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorFilippos Karapetis2009-11-04 09:49:28 +0000
committerFilippos Karapetis2009-11-04 09:49:28 +0000
commit611f5dd95f30012a8c98c4285837a1ce32bdc19a (patch)
treeb3b42dd6359efbed16dd5c8146ff1988cc583ad0 /engines
parent597524b255a75bb61830c8c518d990a38a4923b5 (diff)
downloadscummvm-rg350-611f5dd95f30012a8c98c4285837a1ce32bdc19a.tar.gz
scummvm-rg350-611f5dd95f30012a8c98c4285837a1ce32bdc19a.tar.bz2
scummvm-rg350-611f5dd95f30012a8c98c4285837a1ce32bdc19a.zip
Moved sound sync related variables inside the AudioPlayer class and fixed compilation
svn-id: r45654
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/ksound.cpp32
-rw-r--r--engines/sci/sfx/audio.cpp11
-rw-r--r--engines/sci/sfx/audio.h7
-rw-r--r--engines/sci/sfx/core.cpp5
-rw-r--r--engines/sci/sfx/core.h2
5 files changed, 32 insertions, 25 deletions
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 688e1570cb..7db26b0815 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -1189,9 +1189,9 @@ reg_t kDoSync(EngineState *s, int argc, reg_t *argv) {
case kSciAudioSyncStart: {
ResourceId id;
- if (s->_sound._syncResource) {
- s->resMan->unlockResource(s->_sound._syncResource);
- s->_sound._syncResource = NULL;
+ if (s->_audio->_syncResource) {
+ s->resMan->unlockResource(s->_audio->_syncResource);
+ s->_audio->_syncResource = NULL;
}
// Load sound sync resource and lock it
@@ -1205,11 +1205,11 @@ reg_t kDoSync(EngineState *s, int argc, reg_t *argv) {
return s->r_acc;
}
- s->_sound._syncResource = s->resMan->findResource(id, 1);
+ s->_audio->_syncResource = s->resMan->findResource(id, 1);
- if (s->_sound._syncResource) {
+ if (s->_audio->_syncResource) {
PUT_SEL32V(segMan, argv[1], syncCue, 0);
- s->_sound._syncOffset = 0;
+ s->_audio->_syncOffset = 0;
} else {
warning("DoSync: failed to find resource %s", id.toString().c_str());
// Notify the scripts to stop sound sync
@@ -1218,16 +1218,16 @@ reg_t kDoSync(EngineState *s, int argc, reg_t *argv) {
break;
}
case kSciAudioSyncNext: {
- Resource *res = s->_sound._syncResource;
- if (res && (s->_sound._syncOffset < res->size - 1)) {
+ Resource *res = s->_audio->_syncResource;
+ if (res && (s->_audio->_syncOffset < res->size - 1)) {
int16 syncCue = -1;
- int16 syncTime = (int16)READ_LE_UINT16(res->data + s->_sound._syncOffset);
+ int16 syncTime = (int16)READ_LE_UINT16(res->data + s->_audio->_syncOffset);
- s->_sound._syncOffset += 2;
+ s->_audio->_syncOffset += 2;
- if ((syncTime != -1) && (s->_sound._syncOffset < res->size - 1)) {
- syncCue = (int16)READ_LE_UINT16(res->data + s->_sound._syncOffset);
- s->_sound._syncOffset += 2;
+ if ((syncTime != -1) && (s->_audio->_syncOffset < res->size - 1)) {
+ syncCue = (int16)READ_LE_UINT16(res->data + s->_audio->_syncOffset);
+ s->_audio->_syncOffset += 2;
}
PUT_SEL32V(segMan, argv[1], syncTime, syncTime);
@@ -1236,9 +1236,9 @@ reg_t kDoSync(EngineState *s, int argc, reg_t *argv) {
break;
}
case kSciAudioSyncStop:
- if (s->_sound._syncResource) {
- s->resMan->unlockResource(s->_sound._syncResource);
- s->_sound._syncResource = NULL;
+ if (s->_audio->_syncResource) {
+ s->resMan->unlockResource(s->_audio->_syncResource);
+ s->_audio->_syncResource = NULL;
}
break;
default:
diff --git a/engines/sci/sfx/audio.cpp b/engines/sci/sfx/audio.cpp
index 7a02677f63..1afda91a45 100644
--- a/engines/sci/sfx/audio.cpp
+++ b/engines/sci/sfx/audio.cpp
@@ -33,6 +33,17 @@
namespace Sci {
+AudioPlayer::AudioPlayer(ResourceManager *resMan) : _resMan(resMan), _audioRate(11025),
+ _syncResource(NULL), _syncOffset(0) {
+}
+
+AudioPlayer::~AudioPlayer() {
+ stopAudio();
+
+ if (_syncResource)
+ _resMan->unlockResource(_syncResource);
+}
+
int AudioPlayer::startAudio(uint16 module, uint32 number) {
int sampleLen;
Audio::AudioStream *audioStream = getAudioStream(number, module, &sampleLen);
diff --git a/engines/sci/sfx/audio.h b/engines/sci/sfx/audio.h
index b54b67567c..d3b9358ecb 100644
--- a/engines/sci/sfx/audio.h
+++ b/engines/sci/sfx/audio.h
@@ -33,8 +33,8 @@ class ResourceManager;
class AudioPlayer {
public:
- AudioPlayer(ResourceManager *resMan) : _resMan(resMan), _audioRate(11025) { }
- AudioPlayer::~AudioPlayer() { stopAudio(); }
+ AudioPlayer(ResourceManager *resMan);
+ ~AudioPlayer();
void setAudioRate(uint16 rate) { _audioRate = rate; }
Audio::SoundHandle* getAudioHandle() { return &_audioHandle; }
@@ -44,6 +44,9 @@ public:
void pauseAudio() { g_system->getMixer()->pauseHandle(_audioHandle, true); }
void resumeAudio() { g_system->getMixer()->pauseHandle(_audioHandle, false); }
+ Resource *_syncResource; /**< Used by kDoSync for speech syncing in CD talkie games */
+ uint _syncOffset;
+
private:
ResourceManager *_resMan;
uint16 _audioRate;
diff --git a/engines/sci/sfx/core.cpp b/engines/sci/sfx/core.cpp
index 90aa024dcd..b121d1d877 100644
--- a/engines/sci/sfx/core.cpp
+++ b/engines/sci/sfx/core.cpp
@@ -357,12 +357,9 @@ SfxState::SfxState() {
_flags = 0;
_song = NULL;
_suspended = 0;
- _syncResource = NULL;
}
SfxState::~SfxState() {
- if (_syncResource)
- _resMan->unlockResource(_syncResource);
}
@@ -653,8 +650,6 @@ void SfxState::sfx_init(ResourceManager *resMan, int flags) {
_songlib._lib = 0;
_song = NULL;
_flags = flags;
- _syncResource = NULL;
- _syncOffset = 0;
_player = NULL;
diff --git a/engines/sci/sfx/core.h b/engines/sci/sfx/core.h
index 92ea788636..60696583b7 100644
--- a/engines/sci/sfx/core.h
+++ b/engines/sci/sfx/core.h
@@ -54,8 +54,6 @@ public: // FIXME, make private
SongLibrary _songlib; /**< Song library */
Song *_song; /**< Active song, or start of active song chain */
bool _suspended; /**< Whether we are suspended */
- Resource *_syncResource; /**< Used by kDoSync for speech syncing in CD talkie games */
- uint _syncOffset;
ResourceManager *_resMan;
public: