Mesen/Core/RewindManager.h

65 lines
1.7 KiB
C
Raw Normal View History

2017-04-28 23:54:58 +00:00
#pragma once
#include "stdafx.h"
#include <deque>
#include "INotificationListener.h"
#include "RewindData.h"
#include "IInputProvider.h"
#include "IInputRecorder.h"
2017-04-28 23:54:58 +00:00
enum class RewindState
{
Stopped = 0,
Stopping = 1,
Starting = 2,
Started = 3,
Debugging = 4
2017-04-28 23:54:58 +00:00
};
class RewindManager : public INotificationListener, public IInputProvider, public IInputRecorder
2017-04-28 23:54:58 +00:00
{
private:
static const uint32_t BufferSize = 30; //Number of frames between each save state
static RewindManager* _instance;
std::deque<RewindData> _history;
std::deque<RewindData> _historyBackup;
RewindData _currentHistory;
RewindState _rewindState;
int32_t _framesToFastForward;
std::deque<vector<uint32_t>> _videoHistory;
vector<vector<uint32_t>> _videoHistoryBuilder;
std::deque<int16_t> _audioHistory;
vector<int16_t> _audioHistoryBuilder;
void AddHistoryBlock();
void PopHistory();
void Start(bool forDebugger);
2017-04-28 23:54:58 +00:00
void Stop();
void ForceStop();
2017-04-28 23:54:58 +00:00
void ProcessFrame(void *frameBuffer, uint32_t width, uint32_t height);
bool ProcessAudio(int16_t *soundBuffer, uint32_t sampleCount, uint32_t sampleRate);
void ClearBuffer();
2017-04-28 23:54:58 +00:00
public:
RewindManager();
~RewindManager();
void ProcessNotification(ConsoleNotificationType type, void* parameter) override;
void ProcessEndOfFrame();
void RecordInput(vector<shared_ptr<BaseControlDevice>> devices) override;
bool SetInput(BaseControlDevice *device) override;
2017-04-28 23:54:58 +00:00
static void StartRewinding(bool forDebugger = false);
static void StopRewinding(bool forDebugger = false);
2017-04-28 23:54:58 +00:00
static bool IsRewinding();
static bool IsStepBack();
2017-04-28 23:54:58 +00:00
static void RewindSeconds(uint32_t seconds);
static void SendFrame(void *frameBuffer, uint32_t width, uint32_t height);
static bool SendAudio(int16_t *soundBuffer, uint32_t sampleCount, uint32_t sampleRate);
};