aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2003-06-22 01:55:53 +0000
committerMax Horn2003-06-22 01:55:53 +0000
commit4ad5a183ce4c37ede13e88f3bc0d5b0c0c687026 (patch)
treeecd3d72be68b996ab004d22ff775dac259c395ac /sound
parent573a1e3e9907d228d4826cfb26a99d27ca15676d (diff)
downloadscummvm-rg350-4ad5a183ce4c37ede13e88f3bc0d5b0c0c687026.tar.gz
scummvm-rg350-4ad5a183ce4c37ede13e88f3bc0d5b0c0c687026.tar.bz2
scummvm-rg350-4ad5a183ce4c37ede13e88f3bc0d5b0c0c687026.zip
renamed SoundMixer::hasActiveChannel->hasActiveSFXChannel, and fixed the regression in it caused by removing _beginSlots (I hope); added isActiveChannel method used by scumm/sound.cpp (this allowed me to move the Channel class from mixer.h into mixer.cpp); replaced Channel::soundFinished method by isActive
svn-id: r8597
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp63
-rw-r--r--sound/mixer.h27
2 files changed, 57 insertions, 33 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index b919ced842..9e1ca4cfc7 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -26,6 +26,22 @@
#include "common/file.h"
+class Channel {
+protected:
+ SoundMixer *_mixer;
+public:
+ bool _toBeDestroyed;
+ int _id;
+ Channel() : _mixer(0), _toBeDestroyed(false), _id(-1) {}
+ virtual ~Channel() {}
+ virtual void mix(int16 *data, uint len) = 0;
+ void destroy() {
+ _toBeDestroyed = true;
+ }
+ virtual bool isActive();
+ virtual bool isMusicChannel() = 0;
+};
+
class ChannelRaw : public Channel {
byte *_ptr;
uint32 _pos;
@@ -42,6 +58,9 @@ public:
~ChannelRaw();
void mix(int16 *data, uint len);
+ bool isMusicChannel() {
+ return false; // TODO: IS this correct? Or does any Scumm game us this for music?
+ }
};
class ChannelStream : public Channel {
@@ -61,6 +80,9 @@ public:
void mix(int16 *data, uint len);
void append(void *sound, uint32 size);
+ bool isMusicChannel() {
+ return true;
+ }
};
#ifdef USE_MAD
@@ -81,6 +103,9 @@ public:
~ChannelMP3();
void mix(int16 *data, uint len);
+ bool isMusicChannel() {
+ return false;
+ }
};
class ChannelMP3CDMusic : public Channel {
@@ -101,7 +126,10 @@ public:
~ChannelMP3CDMusic();
void mix(int16 *data, uint len);
- bool soundFinished();
+ bool isActive();
+ bool isMusicChannel() {
+ return true;
+ }
};
#endif
@@ -116,7 +144,10 @@ public:
ChannelVorbis(SoundMixer *mixer, OggVorbis_File *ov_file, int duration, bool is_cd_track);
void mix(int16 *data, uint len);
- bool soundFinished();
+ bool isActive();
+ bool isMusicChannel() {
+ return _is_cd_track;
+ }
};
#endif
@@ -276,13 +307,23 @@ void SoundMixer::pause(bool paused) {
_paused = paused;
}
-bool SoundMixer::hasActiveChannel() {
+bool SoundMixer::hasActiveSFXChannel() {
+ // FIXME/TODO: We need to distinguish between SFX and music channels
+ // (and maybe also voice) here to work properly in iMuseDigital
+ // games. In the past that was achieve using the _beginSlots hack.
+ // Since we don't have that anymore, it's not that simple anymore.
for (int i = 0; i != NUM_CHANNELS; i++)
- if (_channels[i])
+ if (_channels[i] && !_channels[i]->isMusicChannel())
return true;
return false;
}
+bool SoundMixer::isActiveChannel(int index) {
+ if (_channels[index])
+ return _channels[index]->isActive();
+ return false;
+}
+
void SoundMixer::setupPremix(void *param, PremixProc *proc) {
_premixParam = param;
_premixProc = proc;
@@ -596,9 +637,9 @@ static int16 mixer_element_size[] = {
4, 4
};
-bool Channel::soundFinished() {
- warning("sound_finished should never be called on a non-MP3 mixer ");
- return false;
+bool Channel::isActive() {
+ error("isActive should never be called on a non-MP3 mixer ");
+ return true;
}
/* RAW mixer */
@@ -979,8 +1020,8 @@ void ChannelMP3CDMusic::mix(int16 *data, uint len) {
}
}
-bool ChannelMP3CDMusic::soundFinished() {
- return mad_timer_compare(_duration, mad_timer_zero) <= 0;
+bool ChannelMP3CDMusic::isActive() {
+ return mad_timer_compare(_duration, mad_timer_zero) > 0;
}
#endif
@@ -1061,8 +1102,8 @@ void ChannelVorbis::mix(int16 *data, uint len) {
destroy();
}
-bool ChannelVorbis::soundFinished() {
- return _eof_flag || (_end_pos > 0 && ov_pcm_tell(_ov_file) >= _end_pos);
+bool ChannelVorbis::isActive() {
+ return !_eof_flag && (_end_pos <= 0 && ov_pcm_tell(_ov_file) >= _end_pos);
}
#endif
diff --git a/sound/mixer.h b/sound/mixer.h
index 06f22e38fc..bced868538 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -41,26 +41,6 @@ typedef uint32 PlayingSoundHandle;
class Channel;
class File;
-class SoundMixer;
-
-// TODO: class Channel should really be declared non-public, inside mixer.cpp
-// However, right now Sound::updateMP3CD directly calls soundFinished. That
-// should be changed, by adding proper API abstraction to SoundMixer for
-// MP3/Vorbis "CD" playback.
-class Channel {
-protected:
- SoundMixer *_mixer;
-public:
- bool _toBeDestroyed;
- int _id;
- Channel() : _mixer(0), _toBeDestroyed(false), _id(-1) {}
- virtual ~Channel() {}
- virtual void mix(int16 *data, uint len) = 0;
- void destroy() {
- _toBeDestroyed = true;
- }
- virtual bool soundFinished();
-};
class SoundMixer {
public:
@@ -133,8 +113,11 @@ public:
/** append to existing sound */
int append(int index, void * sound, uint32 size);
- /** is any channel active? */
- bool hasActiveChannel();
+ /** Check whether any SFX channel is active.*/
+ bool hasActiveSFXChannel();
+
+ /** Check whether the specified channel si active. */
+ bool isActiveChannel(int index);
/** bind to the OSystem object => mixer will be
* invoked automatically when samples need