[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.239,1.240 sound.h,1.46,1.47
Max Horn
fingolfin at users.sourceforge.net
Sun Sep 7 12:49:03 CEST 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm dialogs.cpp,1.69,1.70 imuse.cpp,2.89,2.90 imuse.h,1.43,1.44 imuse_digi.cpp,1.43,1.44 imuse_digi.h,1.12,1.13 imuse_internal.h,2.19,2.20 music.h,2.3,2.4 player_v2.cpp,2.26,2.27 player_v2.h,2.13,2.14 player_v3a.cpp,1.4,1.5 player_v3a.h,1.3,1.4 saveload.cpp,1.106,1.107 script_v6.cpp,1.182,1.183 sound.cpp,1.238,1.239 sound.h,1.45,1.46
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sound voc.h,NONE,1.1 mixer.h,1.52,1.53
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv7629
Modified Files:
sound.cpp sound.h
Log Message:
removed the seperate 'MP3' CD methods in class Sound (besides being misnamed, merging them into their parent functions actually seems clearer to me, reading wise)
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.239
retrieving revision 1.240
diff -u -d -r1.239 -r1.240
--- sound.cpp 7 Sep 2003 19:28:45 -0000 1.239
+++ sound.cpp 7 Sep 2003 19:47:58 -0000 1.240
@@ -1480,32 +1480,70 @@
}
void Sound::playCDTrack(int track, int numLoops, int startFrame, int duration) {
- if (playMP3CDTrack(track, numLoops, startFrame, duration) == -1)
- _scumm->_system->play_cdrom(track, numLoops, startFrame, duration);
+
+ // Reset the music timer variable at the start of a new track
+ _scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0;
+
+ if (!_soundsPaused && (numLoops != 0 || startFrame != 0)) {
+ int index;
+
+ // Try to load the track from a .mp3/.ogg file, and if found, use
+ // that. If not found, attempt to do regular Audio CD playback of
+ // the requested track.
+ index = getCachedTrack(track);
+ if (index >= 0) {
+ _scumm->_mixer->stopHandle(_dig_cd.handle);
+ _track_info[index]->play(_scumm->_mixer, &_dig_cd.handle, startFrame, duration);
+ _dig_cd.playing = true;
+ _dig_cd.track = track;
+ _dig_cd.numLoops = numLoops;
+ _dig_cd.start = startFrame;
+ _dig_cd.duration = duration;
+ } else {
+ _scumm->_system->play_cdrom(track, numLoops, startFrame, duration);
+ }
+ }
// Start the timer after starting the track. Starting an MP3 track is
// almost instantaneous, but a CD player may take some time. Hopefully
// play_cdrom() will block during that delay.
-
startCDTimer();
}
void Sound::stopCD() {
stopCDTimer();
- if (stopMP3CD() == -1)
+
+ if (_dig_cd.playing) {
+ _scumm->_mixer->stopHandle(_dig_cd.handle);
+ _dig_cd.playing = false;
+ _dig_cd.track = 0;
+ _dig_cd.numLoops = 0;
+ _dig_cd.start = 0;
+ _dig_cd.duration = 0;
+ } else {
_scumm->_system->stop_cdrom();
+ }
}
int Sound::pollCD() const {
- if (pollMP3CD())
- return 1;
-
- return _scumm->_system->poll_cdrom();
+ return _dig_cd.playing || _scumm->_system->poll_cdrom();
}
void Sound::updateCD() {
- if (updateMP3CD() == -1)
+ if (_dig_cd.playing) {
+ // If the sound handle is 0, then playback stopped.
+ if (!_dig_cd.handle) {
+ // 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
+ if (_dig_cd.numLoops == -1 || --_dig_cd.numLoops > 0)
+ playCDTrack(_dig_cd.track, _dig_cd.numLoops, _dig_cd.start, _dig_cd.duration);
+ else
+ stopCD();
+ }
+ } else {
_scumm->_system->update_cdrom();
+ }
}
int Sound::getCachedTrack(int track) {
@@ -1567,64 +1605,6 @@
debug(2, "Track %d not available in compressed format", track);
return -1;
-}
-
-int Sound::playMP3CDTrack(int track, int numLoops, int startFrame, int duration) {
- int index;
- _scumm->VAR(_scumm->VAR_MUSIC_TIMER) = 0;
-
- if (_soundsPaused)
- return 0;
-
- if ((numLoops == 0) && (startFrame == 0)) {
- return 0;
- }
-
- index = getCachedTrack(track);
- if (index < 0)
- return -1;
-
- _scumm->_mixer->stopHandle(_dig_cd.handle);
- _track_info[index]->play(_scumm->_mixer, &_dig_cd.handle, startFrame, duration);
- _dig_cd.playing = true;
- _dig_cd.track = track;
- _dig_cd.numLoops = numLoops;
- _dig_cd.start = startFrame;
- _dig_cd.duration = duration;
- return 0;
-}
-
-int Sound::stopMP3CD() {
- if (_dig_cd.playing) {
- _scumm->_mixer->stopHandle(_dig_cd.handle);
- _dig_cd.playing = false;
- _dig_cd.track = 0;
- _dig_cd.numLoops = 0;
- _dig_cd.start = 0;
- _dig_cd.duration = 0;
- return 0;
- }
- return -1;
-}
-
-int Sound::pollMP3CD() const {
- if (_dig_cd.playing)
- return 1;
- return 0;
-}
-
-int Sound::updateMP3CD() {
- if (!_dig_cd.playing)
- return -1;
-
- if (!_dig_cd.handle) {
- if (_dig_cd.numLoops == -1 || --_dig_cd.numLoops > 0)
- playCDTrack(_dig_cd.track, _dig_cd.numLoops, _dig_cd.start, _dig_cd.duration);
- else
- stopCD();
- }
-
- return 0;
}
#ifdef USE_MAD
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- sound.h 7 Sep 2003 19:28:45 -0000 1.46
+++ sound.h 7 Sep 2003 19:47:58 -0000 1.47
@@ -159,10 +159,6 @@
void playSfxSound_Vorbis(void *sound, uint32 size, PlayingSoundHandle *handle);
int getCachedTrack(int track);
- int playMP3CDTrack(int track, int numLoops, int startFrame, int duration);
- int stopMP3CD();
- int pollMP3CD() const;
- int updateMP3CD();
};
#endif
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm dialogs.cpp,1.69,1.70 imuse.cpp,2.89,2.90 imuse.h,1.43,1.44 imuse_digi.cpp,1.43,1.44 imuse_digi.h,1.12,1.13 imuse_internal.h,2.19,2.20 music.h,2.3,2.4 player_v2.cpp,2.26,2.27 player_v2.h,2.13,2.14 player_v3a.cpp,1.4,1.5 player_v3a.h,1.3,1.4 saveload.cpp,1.106,1.107 script_v6.cpp,1.182,1.183 sound.cpp,1.238,1.239 sound.h,1.45,1.46
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sound voc.h,NONE,1.1 mixer.h,1.52,1.53
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list