BURIED: Pass the currently playing video to yield()

This allows sending the event to the specific video, not to all the
currently playing videos. Also, this allows to distinguish video from
audio loops and only process video skipping events when playing videos
This commit is contained in:
Filippos Karapetis 2021-12-28 18:57:20 +02:00
parent 64fc9de1f2
commit 2591106d38
13 changed files with 53 additions and 53 deletions

View File

@ -260,7 +260,7 @@ void BioChipRightWindow::onLButtonUp(const Common::Point &point, uint flags) {
video->playToFrame(23);
while (!_vm->shouldQuit() && video->getMode() != VideoWindow::kModeStopped) {
_vm->yield();
_vm->yield(video);
_vm->_sound->timerCallback();
}
@ -297,7 +297,7 @@ void BioChipRightWindow::onLButtonUp(const Common::Point &point, uint flags) {
video->playToFrame(47);
while (!_vm->shouldQuit() && video->getMode() != VideoWindow::kModeStopped) {
_vm->yield();
_vm->yield(video);
_vm->_sound->timerCallback();
}

View File

@ -314,7 +314,9 @@ void BuriedEngine::postMessageToWindow(Window *dest, Message *message) {
_messageQueue.push_back(msg);
}
void BuriedEngine::processVideoSkipMessages() {
void BuriedEngine::processVideoSkipMessages(VideoWindow *video) {
assert(video);
for (MessageQueue::iterator it = _messageQueue.begin(); it != _messageQueue.end();) {
MessageType messageType = it->message->getMessageType();
@ -323,9 +325,7 @@ void BuriedEngine::processVideoSkipMessages() {
// Send any skip video keyup events to the video player
if (keyState.keycode == Common::KEYCODE_ESCAPE) {
for (VideoList::iterator it2 = _videos.begin(); it2 != _videos.end(); ++it2) {
(*it2)->onKeyUp(keyState, ((KeyUpMessage *)it->message)->getFlags());
}
video->onKeyUp(keyState, ((KeyUpMessage *)it->message)->getFlags());
delete it->message;
it = _messageQueue.erase(it);
}
@ -420,7 +420,7 @@ bool BuriedEngine::hasMessage(Window *window, int messageBegin, int messageEnd)
return false;
}
void BuriedEngine::yield() {
void BuriedEngine::yield(VideoWindow *video) {
// A cut down version of the Win16 yield function. Win32 handles this
// asynchronously, which we don't want. Only needed for internal event loops.
@ -433,8 +433,8 @@ void BuriedEngine::yield() {
// We only send video skipping messages from here. Otherwise, this is the same
// as our main loop.
if (_allowVideoSkip)
processVideoSkipMessages();
if (video && _allowVideoSkip)
processVideoSkipMessages(video);
_gfx->updateScreen();
_system->delayMillis(10);

View File

@ -124,7 +124,7 @@ public:
// Messaging
void postMessageToWindow(Window *dest, Message *message);
void sendAllMessages();
void processVideoSkipMessages();
void processVideoSkipMessages(VideoWindow *video);
void removeKeyboardMessages(Window *window);
void removeMouseMessages(Window *window);
void removeAllMessages(Window *window);
@ -132,7 +132,7 @@ public:
bool hasMessage(Window *window, int messageBegin, int messageEnd) const;
// Miscellaneous
void yield();
void yield(VideoWindow *video);
int getTransitionSpeed();
void setTransitionSpeed(int newSpeed);
void releaseCapture() { _captureWindow = 0; }

View File

@ -87,7 +87,7 @@ void DemoMainMenuWindow::showWithSplash() {
uint32 startTime = g_system->getMillis();
while (g_system->getMillis() < (startTime + 6000) && !_vm->hasMessage(this, kMessageTypeLButtonUp, kMessageTypeLButtonUp) && !_vm->shouldQuit())
_vm->yield();
_vm->yield(nullptr);
_background->free();
delete _background;

View File

@ -133,7 +133,7 @@ int LairEntry::postEnterRoom(Window *viewWindow, const Location &priorLocation)
}
_vm->_sound->timerCallback();
_vm->yield();
_vm->yield(nullptr);
}
_vm->_sound->stopSoundEffect(_currentSoundID);
@ -162,7 +162,7 @@ int LairEntry::postEnterRoom(Window *viewWindow, const Location &priorLocation)
}
_vm->_sound->timerCallback();
_vm->yield();
_vm->yield(nullptr);
}
_vm->_sound->stopSoundEffect(_currentSoundID);
@ -336,7 +336,7 @@ int LairEntry::onCharacter(Window *viewWindow, const Common::KeyState &character
timerCallback(viewWindow);
_vm->_sound->timerCallback();
_vm->yield();
_vm->yield(nullptr);
}
_vm->_sound->stopSoundEffect(_currentSoundID);
@ -577,7 +577,7 @@ int TransporterControls::onCharacter(Window *viewWindow, const Common::KeyState
// Wait two seconds
uint32 startTime = g_system->getMillis();
while (!_vm->shouldQuit() && startTime + 2000 > g_system->getMillis())
_vm->yield();
_vm->yield(nullptr);
// Move to a different depth to enter the transporter
DestinationScene newScene;
@ -629,7 +629,7 @@ int TransporterControls::onCharacter(Window *viewWindow, const Common::KeyState
// Wait two seconds
uint32 startTime = g_system->getMillis();
while (!_vm->shouldQuit() && startTime + 2000 > g_system->getMillis())
_vm->yield();
_vm->yield(nullptr);
// Move to a different depth to enter the transporter
DestinationScene newScene;

View File

@ -1850,7 +1850,7 @@ int CapacitanceToHabitatDoorClosed::mouseUp(Window *viewWindow, const Common::Po
uint32 startTime = g_system->getMillis();
while (!_vm->shouldQuit() && g_system->getMillis() < startTime + 1000) {
_vm->yield();
_vm->yield(nullptr);
_vm->_sound->timerCallback();
}
@ -1874,7 +1874,7 @@ int CapacitanceToHabitatDoorClosed::mouseUp(Window *viewWindow, const Common::Po
uint32 startTime = g_system->getMillis();
while (!_vm->shouldQuit() && g_system->getMillis() < startTime + 1000) {
_vm->yield();
_vm->yield(nullptr);
_vm->_sound->timerCallback();
}
@ -2455,7 +2455,7 @@ int CapacitanceDockingBayDoor::mouseUp(Window *viewWindow, const Common::Point &
// Wait a second?
uint32 startTime = g_system->getMillis();
while (!_vm->shouldQuit() && g_system->getMillis() < startTime + 1000) {
_vm->yield();
_vm->yield(nullptr);
_vm->_sound->timerCallback();
}

View File

@ -1307,7 +1307,7 @@ int TrialRecallScene::postEnterRoom(Window *viewWindow, const Location &priorLoc
Cursor oldCursor = _vm->_gfx->setCursor(kCursorWait);
uint32 start = g_system->getMillis();
while (g_system->getMillis() - start < 10000)
_vm->yield();
_vm->yield(nullptr);
_vm->_gfx->setCursor(oldCursor);
// Force a recall

View File

@ -95,7 +95,7 @@ bool FrameWindow::showTitleSequence() {
uint32 startTime = g_system->getMillis();
while (g_system->getMillis() < (startTime + 7000) && !_vm->hasMessage(this, kMessageTypeLButtonDown, kMessageTypeLButtonDown) && !_vm->shouldQuit())
_vm->yield();
_vm->yield(nullptr);
_vm->_sound->stopInterfaceSound();
invalidateWindow();
@ -117,7 +117,7 @@ bool FrameWindow::showTitleSequence() {
_vm->removeMouseMessages(video);
while (!_vm->shouldQuit() && video->getMode() != VideoWindow::kModeStopped && !_vm->hasMessage(this, kMessageTypeLButtonDown, kMessageTypeLButtonDown))
_vm->yield();
_vm->yield(video);
delete video;

View File

@ -95,7 +95,7 @@ bool GameUIWindow::startNewGameIntro(bool walkthrough) {
video->playVideo();
while (!_vm->shouldQuit() && video->getMode() != VideoWindow::kModeStopped)
_vm->yield();
_vm->yield(video);
delete video;
@ -173,7 +173,7 @@ bool GameUIWindow::flashWarningLight() {
uint32 startTime = g_system->getMillis();
while (!_vm->shouldQuit() && (startTime + 200) > g_system->getMillis()) {
_vm->yield();
_vm->yield(nullptr);
_vm->_sound->timerCallback();
}
@ -188,7 +188,7 @@ bool GameUIWindow::flashWarningLight() {
startTime = g_system->getMillis();
while (!_vm->shouldQuit() && (startTime + 250) > g_system->getMillis()) {
_vm->yield();
_vm->yield(nullptr);
_vm->_sound->timerCallback();
}
@ -201,7 +201,7 @@ bool GameUIWindow::flashWarningLight() {
startTime = g_system->getMillis();
while (!_vm->shouldQuit() && (startTime + 250) > g_system->getMillis()) {
_vm->yield();
_vm->yield(nullptr);
_vm->_sound->timerCallback();
}

View File

@ -210,7 +210,7 @@ void BurnedLetterViewWindow::onLButtonUp(const Common::Point &point, uint flags)
memcpy(_preBuffer->getBasePtr(0, j), newFrame->getBasePtr(0, _preBuffer->h - (i + offset) + j), newFrame->w * newFrame->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
newFrame->free();
@ -240,7 +240,7 @@ void BurnedLetterViewWindow::onLButtonUp(const Common::Point &point, uint flags)
memcpy(_preBuffer->getBasePtr(0, newFrame->h - offset + j), newFrame->getBasePtr(0, i + j), newFrame->w * newFrame->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
newFrame->free();

View File

@ -213,7 +213,7 @@ void MainMenuWindow::onLButtonUp(const Common::Point &point, uint flags) {
video->playVideo();
while (!_vm->shouldQuit() && video->getMode() != VideoWindow::kModeStopped)
_vm->yield();
_vm->yield(video);
_vm->_sound->restart();
}

View File

@ -748,7 +748,7 @@ bool SceneViewWindow::timeSuitJump(int destination) {
jumpMovie->playToFrame(24);
while (!_vm->shouldQuit() && jumpMovie->getMode() != VideoWindow::kModeStopped && _vm->_sound->isInterfaceSoundPlaying()) {
_vm->yield();
_vm->yield(jumpMovie.get());
_vm->_sound->timerCallback();
}
@ -795,7 +795,7 @@ bool SceneViewWindow::timeSuitJump(int destination) {
jumpMovie->playVideo();
while (!_vm->shouldQuit() && jumpMovie->getMode() != VideoWindow::kModeStopped)
_vm->yield();
_vm->yield(jumpMovie.get());
if (_vm->shouldQuit())
return true;
@ -881,7 +881,7 @@ bool SceneViewWindow::timeSuitJump(int destination) {
jumpMovie->playToFrame(48);
while (!_vm->shouldQuit() && jumpMovie->getMode() != VideoWindow::kModeStopped && _vm->_sound->isInterfaceSoundPlaying()) {
_vm->yield();
_vm->yield(jumpMovie.get());
_vm->_sound->timerCallback();
}
@ -1078,7 +1078,7 @@ bool SceneViewWindow::videoTransition(const Location &location, DestinationScene
animationMovie->playToFrame(destinationData.transitionStartFrame + destinationData.transitionLength - 1);
while (!_vm->shouldQuit() && animationMovie->getMode() != VideoWindow::kModeStopped) {
_vm->yield();
_vm->yield(animationMovie.get());
_vm->_sound->timerCallback();
}
@ -1145,7 +1145,7 @@ bool SceneViewWindow::walkTransition(const Location &location, const Destination
_walkMovie->playToFrame(destinationData.transitionStartFrame + destinationData.transitionLength - 1);
while (!_vm->shouldQuit() && _walkMovie->getMode() != VideoWindow::kModeStopped) {
_vm->yield();
_vm->yield(_walkMovie);
_vm->_sound->timerCallback();
}
@ -1186,7 +1186,7 @@ bool SceneViewWindow::pushTransition(Graphics::Surface *curBackground, Graphics:
memcpy(curBackground->getBasePtr(0, j), newBackground->getBasePtr(0, curBackground->h - (i + stripSize) + j), newBackground->w * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 1: // Push right
@ -1197,7 +1197,7 @@ bool SceneViewWindow::pushTransition(Graphics::Surface *curBackground, Graphics:
memcpy(curBackground->getBasePtr(0, j), newBackground->getBasePtr(newBackground->w - (i + stripSize), j), stripSize * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 2: // Push left
@ -1208,7 +1208,7 @@ bool SceneViewWindow::pushTransition(Graphics::Surface *curBackground, Graphics:
memcpy(curBackground->getBasePtr(curBackground->w - (int)stripSize, j), newBackground->getBasePtr(i, j), stripSize * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 3: // Push up
@ -1219,7 +1219,7 @@ bool SceneViewWindow::pushTransition(Graphics::Surface *curBackground, Graphics:
memcpy(curBackground->getBasePtr(0, curBackground->h - stripSize + j), newBackground->getBasePtr(0, i + j), newBackground->w * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
}
@ -1255,7 +1255,7 @@ bool SceneViewWindow::slideInTransition(Graphics::Surface *newBackground, int di
memcpy(_preBuffer->getBasePtr(0, j), newBackground->getBasePtr(0, DIB_FRAME_HEIGHT - j), newBackground->w * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 1: // Push right
@ -1264,7 +1264,7 @@ bool SceneViewWindow::slideInTransition(Graphics::Surface *newBackground, int di
memcpy(_preBuffer->getBasePtr(0, j), newBackground->getBasePtr(DIB_FRAME_WIDTH - i, j), i * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 2: // Push left
@ -1273,7 +1273,7 @@ bool SceneViewWindow::slideInTransition(Graphics::Surface *newBackground, int di
memcpy(_preBuffer->getBasePtr(0, DIB_FRAME_WIDTH - i), newBackground->getBasePtr(0, j), i * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 3: // Push up
@ -1282,7 +1282,7 @@ bool SceneViewWindow::slideInTransition(Graphics::Surface *newBackground, int di
memcpy(_preBuffer->getBasePtr(0, DIB_FRAME_HEIGHT - j), newBackground->getBasePtr(0, j), newBackground->w * newBackground->format.bytesPerPixel);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
}
@ -1308,7 +1308,7 @@ bool SceneViewWindow::slideOutTransition(Graphics::Surface *newBackground, int d
_vm->_gfx->crossBlit(_preBuffer, 0, 0, 432, 189, newBackground, 0, 0);
_vm->_gfx->crossBlit(_preBuffer, 0, i, 432, 189 - i, &curBackground, 0, 0);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 1: // Push right
@ -1317,7 +1317,7 @@ bool SceneViewWindow::slideOutTransition(Graphics::Surface *newBackground, int d
_vm->_gfx->crossBlit(_preBuffer, i, 0, DIB_FRAME_WIDTH - i, 189, newBackground, i, 0);
_vm->_gfx->crossBlit(_preBuffer, 0, 0, i, 189, &curBackground, DIB_FRAME_WIDTH - i, 0);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 2: // Push left
@ -1325,7 +1325,7 @@ bool SceneViewWindow::slideOutTransition(Graphics::Surface *newBackground, int d
_vm->_gfx->crossBlit(_preBuffer, 0, 0, i, 189, newBackground, 0, 0);
_vm->_gfx->crossBlit(_preBuffer, i, 0, 432 - i, 189, &curBackground, 0, 0);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
case 3: // Push up
@ -1333,7 +1333,7 @@ bool SceneViewWindow::slideOutTransition(Graphics::Surface *newBackground, int d
_vm->_gfx->crossBlit(_preBuffer, 0, 0, 432, 189, newBackground, 0, 0);
_vm->_gfx->crossBlit(_preBuffer, 0, 189 - i, 432, i, &curBackground, 0, 0);
invalidateWindow(false);
_vm->yield();
_vm->yield(nullptr);
}
break;
}
@ -1572,7 +1572,7 @@ bool SceneViewWindow::playSynchronousAnimation(int animationID) {
animationMovie->playToFrame(animDatabase[i].startFrame + animDatabase[i].frameCount - 1);
while (!_vm->shouldQuit() && animationMovie->getMode() != VideoWindow::kModeStopped) {
_vm->yield();
_vm->yield(animationMovie.get());
_vm->_sound->timerCallback();
}
@ -1615,7 +1615,7 @@ bool SceneViewWindow::playSynchronousAnimationExtern(int animationID) {
animationMovie->playVideo();
while (!_vm->shouldQuit() && animationMovie->getMode() != VideoWindow::kModeStopped) {
_vm->yield();
_vm->yield(animationMovie.get());
_vm->_sound->timerCallback();
}
@ -1679,7 +1679,7 @@ bool SceneViewWindow::playPlacedSynchronousAnimation(int animationID, int left,
animationMovie->playToFrame(animDatabase[i].startFrame + animDatabase[i].frameCount - 1);
while (!_vm->shouldQuit() && animationMovie->getMode() != VideoWindow::kModeStopped) {
_vm->yield();
_vm->yield(animationMovie.get());
_vm->_sound->timerCallback();
}
@ -1749,7 +1749,7 @@ bool SceneViewWindow::playClippedSynchronousAnimation(int animationID, int left,
animationMovie->playToFrame(animDatabase[i].startFrame + animDatabase[i].frameCount - 1);
while (!_vm->shouldQuit() && animationMovie->getMode() != VideoWindow::kModeStopped) {
_vm->yield();
_vm->yield(animationMovie.get());
_vm->_sound->timerCallback();
}

View File

@ -352,7 +352,7 @@ bool SoundManager::playSynchronousAIComment(const Common::String &fileName) {
while (retVal && !_vm->shouldQuit() && _soundData[kAIVoiceIndex]->isPlaying()) {
timerCallback();
_vm->yield();
_vm->yield(nullptr);
}
// Now that is has been played, kill it here and now
@ -441,7 +441,7 @@ bool SoundManager::playSynchronousSoundEffect(const Common::String &fileName, in
// the sound finishes playing
do {
timerCallback();
_vm->yield();
_vm->yield(nullptr);
} while (!_vm->shouldQuit() && isSoundEffectPlaying(soundChannel));
// One last callback check