mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-20 08:53:51 +00:00
Added numLoops parameter to DigitalTrackInfo::play
svn-id: r25836
This commit is contained in:
parent
d6467f79a2
commit
65b30d84a8
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user