aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2007-02-24 23:19:53 +0000
committerMax Horn2007-02-24 23:19:53 +0000
commit65b30d84a805a7b22322474970a219d5628997d5 (patch)
tree71a3b15d15d59eb4802982ad7dc3a549b1bf2070
parentd6467f79a29cf053370d20960697c9a60f71f81e (diff)
downloadscummvm-rg350-65b30d84a805a7b22322474970a219d5628997d5.tar.gz
scummvm-rg350-65b30d84a805a7b22322474970a219d5628997d5.tar.bz2
scummvm-rg350-65b30d84a805a7b22322474970a219d5628997d5.zip
Added numLoops parameter to DigitalTrackInfo::play
svn-id: r25836
-rw-r--r--engines/saga/music.cpp2
-rw-r--r--sound/audiocd.cpp26
-rw-r--r--sound/audiocd.h2
-rw-r--r--sound/flac.cpp6
-rw-r--r--sound/mp3.cpp6
-rw-r--r--sound/vorbis.cpp6
6 files changed, 24 insertions, 24 deletions
diff --git a/engines/saga/music.cpp b/engines/saga/music.cpp
index f4af44f826..c30e77ff8a 100644
--- a/engines/saga/music.cpp
+++ b/engines/saga/music.cpp
@@ -416,7 +416,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
break;
}
if (_track) {
- _track->play(_mixer, &_musicHandle, (flags == MUSIC_LOOP) ? -1 : 1, 10000);
+ _track->play(_mixer, &_musicHandle, 1, (flags == MUSIC_LOOP) ? -1 : 1, 10000);
return;
}
diff --git a/sound/audiocd.cpp b/sound/audiocd.cpp
index 8ae811ef10..09713eaf0f 100644
--- a/sound/audiocd.cpp
+++ b/sound/audiocd.cpp
@@ -91,7 +91,13 @@ void AudioCDManager::play(int track, int numLoops, int startFrame, int duration)
if (index >= 0) {
_mixer->stopHandle(_cd.handle);
_cd.playing = true;
- _trackInfo[index]->play(_mixer, &_cd.handle, _cd.start, _cd.duration);
+ /*
+ FIXME: Seems numLoops == 0 and numLoops == 1 both indicate a single repetition,
+ while all other positive numbers indicate precisely the number of desired
+ repetitions. Finally, -1 means infinitely many
+ */
+ numLoops = (numLoops < 1) ? numLoops + 1 : numLoops;
+ _trackInfo[index]->play(_mixer, &_cd.handle, numLoops, _cd.start, _cd.duration);
} else {
g_system->playCD(track, numLoops, startFrame, duration);
_cd.playing = false;
@@ -114,19 +120,13 @@ bool AudioCDManager::isPlaying() const {
void AudioCDManager::updateCD() {
if (_cd.playing) {
- // If the sound handle is 0, then playback stopped.
+ // Check whether the audio track stopped playback
if (!_mixer->isSoundHandleActive(_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 (_cd.numLoops == -1 || --_cd.numLoops > 0) {
- int index = getCachedTrack(_cd.track);
- assert(index >= 0);
- _trackInfo[index]->play(_mixer, &_cd.handle, _cd.start, _cd.duration);
- } else {
- _mixer->stopHandle(_cd.handle);
- _cd.playing = false;
- }
+ // FIXME: We do not update the numLoops parameter here (and in fact,
+ // currently can't do that). Luckily, only one engine ever checks
+ // this part of the AudioCD status, namely the SCUMM engine; and it
+ // only checks
+ _cd.playing = false;
}
} else {
g_system->updateCD();
diff --git a/sound/audiocd.h b/sound/audiocd.h
index 5b9c05355c..23367ba262 100644
--- a/sound/audiocd.h
+++ b/sound/audiocd.h
@@ -36,7 +36,7 @@ class DigitalTrackInfo {
public:
virtual ~DigitalTrackInfo() {}
- virtual void play(Mixer *mixer, SoundHandle *handle, int startFrame, int duration) = 0;
+ virtual void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) = 0;
// virtual void stop();
};
diff --git a/sound/flac.cpp b/sound/flac.cpp
index 2e5ea293ba..539d5f429e 100644
--- a/sound/flac.cpp
+++ b/sound/flac.cpp
@@ -780,7 +780,7 @@ private:
public:
FlacTrackInfo(const char *filename);
bool error() { return _errorFlag; }
- void play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration);
+ void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
};
FlacTrackInfo::FlacTrackInfo(const char *filename) :
@@ -804,7 +804,7 @@ FlacTrackInfo::FlacTrackInfo(const char *filename) :
delete tempStream;
}
-void FlacTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration) {
+void FlacTrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
assert(!_errorFlag);
if (error()) {
@@ -824,7 +824,7 @@ void FlacTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int st
uint end = duration ? ((startFrame + duration) * 1000 / 75) : 0;
// ... create an AudioStream ...
- FlacInputStream *input = new FlacInputStream(file, true, start, end);
+ FlacInputStream *input = new FlacInputStream(file, true, start, end, numLoops);
if (!input->isStreamDecoderReady()) {
delete input;
return;
diff --git a/sound/mp3.cpp b/sound/mp3.cpp
index e98134adc7..ff8787833b 100644
--- a/sound/mp3.cpp
+++ b/sound/mp3.cpp
@@ -346,7 +346,7 @@ private:
public:
MP3TrackInfo(const char *filename);
bool error() { return _errorFlag; }
- void play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration);
+ void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
};
MP3TrackInfo::MP3TrackInfo(const char *filename) :
@@ -371,7 +371,7 @@ MP3TrackInfo::MP3TrackInfo(const char *filename) :
delete tempStream;
}
-void MP3TrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration) {
+void MP3TrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
assert(!_errorFlag);
mad_timer_t start;
@@ -396,7 +396,7 @@ void MP3TrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int sta
}
// ... create an AudioStream ...
- MP3InputStream *input = new MP3InputStream(file, true, start, end);
+ MP3InputStream *input = new MP3InputStream(file, true, start, end, numLoops);
// ... and play it
mixer->playInputStream(Audio::Mixer::kMusicSoundType, handle, input);
diff --git a/sound/vorbis.cpp b/sound/vorbis.cpp
index 42a19ea309..9b88020974 100644
--- a/sound/vorbis.cpp
+++ b/sound/vorbis.cpp
@@ -306,7 +306,7 @@ private:
public:
VorbisTrackInfo(const char *filename);
bool error() { return _errorFlag; }
- void play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration);
+ void play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration);
};
VorbisTrackInfo::VorbisTrackInfo(const char *filename) :
@@ -332,7 +332,7 @@ VorbisTrackInfo::VorbisTrackInfo(const char *filename) :
delete tempStream;
}
-void VorbisTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int startFrame, int duration) {
+void VorbisTrackInfo::play(Mixer *mixer, SoundHandle *handle, int numLoops, int startFrame, int duration) {
assert(!_errorFlag);
// Open the file
@@ -349,7 +349,7 @@ void VorbisTrackInfo::play(Audio::Mixer *mixer, Audio::SoundHandle *handle, int
uint end = duration ? ((startFrame + duration) * 40 / 3) : 0;
// ... create an AudioStream ...
- VorbisInputStream *input = new VorbisInputStream(file, true, start, end);
+ VorbisInputStream *input = new VorbisInputStream(file, true, start, end, numLoops);
// ... and play it
mixer->playInputStream(Audio::Mixer::kMusicSoundType, handle, input);