Rewind: Fixed crash/corrupted video when rewinding in games that switch between regular & high res modes
This commit is contained in:
parent
0a8173138b
commit
5e70221aa8
2 changed files with 16 additions and 4 deletions
|
@ -226,7 +226,11 @@ void RewindManager::ProcessFrame(void * frameBuffer, uint32_t width, uint32_t he
|
|||
return;
|
||||
}
|
||||
|
||||
_videoHistoryBuilder.push_back(vector<uint32_t>((uint32_t*)frameBuffer, (uint32_t*)frameBuffer + width*height));
|
||||
VideoFrame newFrame;
|
||||
newFrame.Data = vector<uint32_t>((uint32_t*)frameBuffer, (uint32_t*)frameBuffer + width * height);
|
||||
newFrame.Width = width;
|
||||
newFrame.Height = height;
|
||||
_videoHistoryBuilder.push_back(newFrame);
|
||||
|
||||
if(_videoHistoryBuilder.size() == (size_t)_historyBackup.front().FrameCount) {
|
||||
for(int i = (int)_videoHistoryBuilder.size() - 1; i >= 0; i--) {
|
||||
|
@ -239,7 +243,8 @@ void RewindManager::ProcessFrame(void * frameBuffer, uint32_t width, uint32_t he
|
|||
_rewindState = RewindState::Started;
|
||||
_settings->ClearFlag(EmulationFlags::MaximumSpeed);
|
||||
if(!_videoHistory.empty()) {
|
||||
_console->GetVideoRenderer()->UpdateFrame(_videoHistory.back().data(), width, height);
|
||||
VideoFrame &frameData = _videoHistory.back();
|
||||
_console->GetVideoRenderer()->UpdateFrame(frameData.Data.data(), frameData.Width, frameData.Height);
|
||||
_videoHistory.pop_back();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,13 @@ enum class RewindState
|
|||
Debugging = 4
|
||||
};
|
||||
|
||||
struct VideoFrame
|
||||
{
|
||||
vector<uint32_t> Data;
|
||||
uint32_t Width;
|
||||
uint32_t Height;
|
||||
};
|
||||
|
||||
class RewindManager : public INotificationListener, public IInputProvider, public IInputRecorder
|
||||
{
|
||||
private:
|
||||
|
@ -35,8 +42,8 @@ private:
|
|||
RewindState _rewindState;
|
||||
int32_t _framesToFastForward;
|
||||
|
||||
std::deque<vector<uint32_t>> _videoHistory;
|
||||
vector<vector<uint32_t>> _videoHistoryBuilder;
|
||||
std::deque<VideoFrame> _videoHistory;
|
||||
vector<VideoFrame> _videoHistoryBuilder;
|
||||
std::deque<int16_t> _audioHistory;
|
||||
vector<int16_t> _audioHistoryBuilder;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue