aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/videoplayer.cpp
diff options
context:
space:
mode:
authorSven Hesse2008-05-14 23:58:26 +0000
committerSven Hesse2008-05-14 23:58:26 +0000
commitaac4786bbe6be0618266eb4f24ed2171523b268e (patch)
tree808a9be6fb4403b06fb1852e5b8aae720bb5f00b /engines/gob/videoplayer.cpp
parentf481821eeb6c757a1300d62c8a762e86e5a2213b (diff)
downloadscummvm-rg350-aac4786bbe6be0618266eb4f24ed2171523b268e.tar.gz
scummvm-rg350-aac4786bbe6be0618266eb4f24ed2171523b268e.tar.bz2
scummvm-rg350-aac4786bbe6be0618266eb4f24ed2171523b268e.zip
This should fix the video not closing / chunk slot clogging bug (Yeah, I'm apparently stupid *g*)
svn-id: r32131
Diffstat (limited to 'engines/gob/videoplayer.cpp')
-rw-r--r--engines/gob/videoplayer.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/engines/gob/videoplayer.cpp b/engines/gob/videoplayer.cpp
index c435136b75..f421646ee2 100644
--- a/engines/gob/videoplayer.cpp
+++ b/engines/gob/videoplayer.cpp
@@ -348,15 +348,30 @@ int VideoPlayer::slotOpen(const char *videoFile, Type which) {
video->getVideo()->setVideoMemory();
video->getVideo()->enableSound(*_vm->_mixer);
- _videoSlots.push_back(video);
+ int slot = getNextFreeSlot();
+
+ _videoSlots[slot] = video;
WRITE_VAR(7, video->getVideo()->getFramesCount());
- return _videoSlots.size() - 1;
+ return slot;
+}
+
+int VideoPlayer::getNextFreeSlot() {
+ uint slot;
+
+ for (slot = 0; slot < _videoSlots.size(); slot++)
+ if (!_videoSlots[slot])
+ break;
+
+ if (slot == _videoSlots.size())
+ _videoSlots.push_back(0);
+
+ return slot;
}
void VideoPlayer::slotPlay(int slot, int16 frame) {
- if ((slot < 0) || (((uint) slot) >= _videoSlots.size()))
+ if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
return;
CoktelVideo &video = *(_videoSlots[slot]->getVideo());
@@ -377,18 +392,18 @@ void VideoPlayer::slotPlay(int slot, int16 frame) {
}
void VideoPlayer::slotClose(int slot) {
- if ((slot < 0) || (((uint) slot) >= _videoSlots.size()))
+ if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
return;
delete _videoSlots[slot];
- _videoSlots.remove_at(slot);
+ _videoSlots[slot] = 0;
}
void VideoPlayer::slotCopyFrame(int slot, byte *dest,
uint16 left, uint16 top, uint16 width, uint16 height,
uint16 x, uint16 y, uint16 pitch, int16 transp) {
- if ((slot < 0) || (((uint) slot) >= _videoSlots.size()))
+ if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
return;
_videoSlots[slot]->getVideo()->copyCurrentFrame(dest,
@@ -396,14 +411,14 @@ void VideoPlayer::slotCopyFrame(int slot, byte *dest,
}
void VideoPlayer::slotCopyPalette(int slot, int16 palStart, int16 palEnd) {
- if ((slot < 0) || (((uint) slot) >= _videoSlots.size()))
+ if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
return;
copyPalette(*(_videoSlots[slot]->getVideo()), palStart, palEnd);
}
void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) {
- if ((slot < 0) || (((uint) slot) >= _videoSlots.size()))
+ if ((slot < 0) || (((uint) slot) >= _videoSlots.size()) || !_videoSlots[slot])
return;
CoktelVideo &video = *(_videoSlots[slot]->getVideo());
@@ -413,7 +428,7 @@ void VideoPlayer::slotWaitEndFrame(int slot, bool onlySound) {
}
bool VideoPlayer::slotIsOpen(int slot) const {
- if ((slot >= 0) && (((uint) slot) < _videoSlots.size()))
+ if ((slot >= 0) && (((uint) slot) < _videoSlots.size()) && _videoSlots[slot])
return true;
return false;
@@ -423,7 +438,7 @@ const VideoPlayer::Video *VideoPlayer::getVideoBySlot(int slot) const {
if (slot < 0) {
if (_primaryVideo->isOpen())
return _primaryVideo;
- } else if (((uint) slot) < _videoSlots.size())
+ } else if (((uint) slot) < _videoSlots.size() && _videoSlots[slot])
return _videoSlots[slot];
return 0;