[Scummvm-cvs-logs] CVS: scummvm/sound audiocd.cpp,1.6,1.7 mixer.cpp,1.145,1.146 mixer.h,1.66,1.67
Max Horn
fingolfin at users.sourceforge.net
Tue Dec 23 16:26:09 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_mixer.cpp,1.24,1.25 smush_player.cpp,1.80,1.81
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_draw.cpp,1.49,1.50 d_sound.cpp,1.89,1.90 d_sound.h,1.35,1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1:/tmp/cvs-serv23172/sound
Modified Files:
audiocd.cpp mixer.cpp mixer.h
Log Message:
turned PlayingSoundHandle into an 'opaque' (well not really :-) data type, mainly because people kept (accidentally and sometimes on purpose :-) misusing them
Index: audiocd.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/audiocd.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- audiocd.cpp 12 Dec 2003 15:05:33 -0000 1.6
+++ audiocd.cpp 24 Dec 2003 00:25:17 -0000 1.7
@@ -74,7 +74,7 @@
void AudioCDManager::updateCD() {
if (_cd.playing) {
// If the sound handle is 0, then playback stopped.
- if (!_cd.handle) {
+ if (!_cd.handle.isActive()) {
// If playback just stopped, check if the current track is supposed
// to be repeated, and if that's the case, play it again. Else, stop
// the CD explicitly.
@@ -94,7 +94,7 @@
AudioCDManager::Status AudioCDManager::getStatus() const {
// TODO: This could be improved for "real" CD playback.
- // But to do that, we have to extend the OSystem interface.
+ // But to do that, we would have to extend the OSystem interface.
Status info = _cd;
info.playing = isPlaying();
return info;
Index: mixer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.cpp,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -d -r1.145 -r1.146
--- mixer.cpp 23 Dec 2003 19:14:57 -0000 1.145
+++ mixer.cpp 24 Dec 2003 00:25:17 -0000 1.146
@@ -152,10 +152,10 @@
void SoundMixer::appendStream(PlayingSoundHandle handle, void *sound, uint32 size) {
Common::StackLock lock(_mutex);
- if (handle == 0)
+ if (!handle.isActive())
return;
- int index = handle - 1;
+ int index = handle.getIndex();
if ((index < 0) || (index >= NUM_CHANNELS)) {
warning("soundMixer::appendStream has invalid index %d", index);
@@ -179,10 +179,10 @@
Common::StackLock lock(_mutex);
// Simply ignore stop requests for handles of sounds that already terminated
- if (handle == 0)
+ if (!handle.isActive())
return;
- int index = handle - 1;
+ int index = handle.getIndex();
if ((index < 0) || (index >= NUM_CHANNELS)) {
warning("soundMixer::endStream has invalid index %d", index);
@@ -219,7 +219,7 @@
_channels[index] = chan;
if (handle)
- *handle = index + 1;
+ handle->setIndex(index);
}
void SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id, byte volume, int8 pan, uint32 loopStart, uint32 loopEnd) {
@@ -358,10 +358,10 @@
Common::StackLock lock(_mutex);
// Simply ignore stop requests for handles of sounds that already terminated
- if (handle == 0)
+ if (!handle.isActive())
return;
- int index = handle - 1;
+ int index = handle.getIndex();
if ((index < 0) || (index >= NUM_CHANNELS)) {
warning("soundMixer::stopHandle has invalid index %d", index);
@@ -377,10 +377,10 @@
void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
Common::StackLock lock(_mutex);
- if (handle == 0)
+ if (!handle.isActive())
return;
- int index = handle - 1;
+ int index = handle.getIndex();
if ((index < 0) || (index >= NUM_CHANNELS)) {
warning("soundMixer::setChannelVolume has invalid index %d", index);
@@ -394,10 +394,10 @@
void SoundMixer::setChannelPan(PlayingSoundHandle handle, int8 pan) {
Common::StackLock lock(_mutex);
- if (handle == 0)
+ if (!handle.isActive())
return;
- int index = handle - 1;
+ int index = handle.getIndex();
if ((index < 0) || (index >= NUM_CHANNELS)) {
warning("soundMixer::setChannelVolume has invalid index %d", index);
@@ -426,10 +426,10 @@
Common::StackLock lock(_mutex);
// Simply ignore pause/unpause requests for handles of sound that alreayd terminated
- if (handle == 0)
+ if (!handle.isActive())
return;
- int index = handle - 1;
+ int index = handle.getIndex();
if ((index < 0) || (index >= NUM_CHANNELS)) {
warning("soundMixer::pauseHandle has invalid index %d", index);
@@ -496,7 +496,7 @@
delete _converter;
delete _input;
if (_handle)
- *_handle = 0;
+ _handle->resetIndex();
}
/* len indicates the number of sample *pairs*. So a value of
Index: mixer.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/mixer.h,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- mixer.h 23 Dec 2003 19:14:57 -0000 1.66
+++ mixer.h 24 Dec 2003 00:25:17 -0000 1.67
@@ -35,11 +35,21 @@
#endif
-typedef uint32 PlayingSoundHandle;
-
class AudioInputStream;
class Channel;
class File;
+
+class PlayingSoundHandle {
+ friend class Channel;
+ friend class SoundMixer;
+ int val;
+ int getIndex() const { return val - 1; }
+ void setIndex(int i) { val = i + 1; }
+ void resetIndex() { val = 0; }
+public:
+ PlayingSoundHandle() { resetIndex(); }
+ bool isActive() const { return val > 0; }
+};
class SoundMixer {
public:
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm/smush smush_mixer.cpp,1.24,1.25 smush_player.cpp,1.80,1.81
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_draw.cpp,1.49,1.50 d_sound.cpp,1.89,1.90 d_sound.h,1.35,1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list