VIDEO: Fix VideoDecoder::needsUpdate to work for audio-only files

VideoDecoder::needsUpdate() only returns true if there are frames
remaining to be rendered. This won't work for video files that are
audio-only, so in the event of a such a file, fall back to checking
endOfVideo() which includes audio tracks.

Fixes audio-only DigitalVideoCastMembers in the Director engine.

Fixes playback of the cupcake song in Chop Suey.
This commit is contained in:
Scott Percival 2022-09-30 21:46:04 +08:00 committed by Eugene Sandulenko
parent dcceb4c34b
commit 32f87b27cb

View File

@ -96,7 +96,26 @@ bool VideoDecoder::loadFile(const Common::Path &filename) {
}
bool VideoDecoder::needsUpdate() const {
return hasFramesLeft() && getTimeToNextFrame() == 0;
bool hasVideo = false;
bool hasAudio = false;
for (auto &it : _tracks) {
switch (it->getTrackType()) {
case Track::kTrackTypeAudio:
hasAudio = true;
break;
case Track::kTrackTypeVideo:
hasVideo = true;
break;
default:
break;
}
}
if (hasVideo) {
return hasFramesLeft() && getTimeToNextFrame() == 0;
} else if (hasAudio) {
return !endOfVideo();
}
return false;
}
void VideoDecoder::pauseVideo(bool pause) {