[Scummvm-cvs-logs] CVS: scummvm/sound mixer.cpp,1.45,1.46 mixer.h,1.25,1.26
Max Horn
fingolfin at users.sourceforge.net
Sat Jun 21 18:56:02 CEST 2003
Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv27726
Modified Files:
mixer.cpp mixer.h
Log Message:
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
Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- mixer.cpp 22 Jun 2003 01:34:28 -0000 1.45
+++ mixer.cpp 22 Jun 2003 01:55:51 -0000 1.46
@@ -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 @@
~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 @@
void mix(int16 *data, uint len);
void append(void *sound, uint32 size);
+ bool isMusicChannel() {
+ return true;
+ }
};
#ifdef USE_MAD
@@ -81,6 +103,9 @@
~ChannelMP3();
void mix(int16 *data, uint len);
+ bool isMusicChannel() {
+ return false;
+ }
};
class ChannelMP3CDMusic : public Channel {
@@ -101,7 +126,10 @@
~ChannelMP3CDMusic();
void mix(int16 *data, uint len);
- bool soundFinished();
+ bool isActive();
+ bool isMusicChannel() {
+ return true;
+ }
};
#endif
@@ -116,7 +144,10 @@
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 @@
_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 @@
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 @@
}
}
-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 @@
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
Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- mixer.h 22 Jun 2003 01:34:28 -0000 1.25
+++ mixer.h 22 Jun 2003 01:55:51 -0000 1.26
@@ -41,26 +41,6 @@
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 @@
/** 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
More information about the Scummvm-git-logs
mailing list