core/movie: Allow setting a playback completion callback

Instead of specifying it when starting playback. This is necessary as
you can end up playing the movie even if you started as Recording
(for example, loading a state in R/O mode will switch to Playing mode)
This commit is contained in:
zhupengfei 2020-07-07 16:38:24 +08:00
parent 06bc37a67d
commit 5a42a80f40
No known key found for this signature in database
GPG key ID: DD129E108BD09378
2 changed files with 8 additions and 6 deletions

View file

@ -486,8 +486,11 @@ void Movie::SaveMovie() {
} }
} }
void Movie::StartPlayback(const std::string& movie_file, void Movie::SetPlaybackCompletionCallback(std::function<void()> completion_callback) {
std::function<void()> completion_callback) { playback_completion_callback = completion_callback;
}
void Movie::StartPlayback(const std::string& movie_file) {
LOG_INFO(Movie, "Loading Movie for playback"); LOG_INFO(Movie, "Loading Movie for playback");
FileUtil::IOFile save_record(movie_file, "rb"); FileUtil::IOFile save_record(movie_file, "rb");
const u64 size = save_record.GetSize(); const u64 size = save_record.GetSize();
@ -510,7 +513,6 @@ void Movie::StartPlayback(const std::string& movie_file,
current_byte = 0; current_byte = 0;
id = header.id; id = header.id;
playback_completion_callback = completion_callback;
LOG_INFO(Movie, "Loaded Movie, ID: {:016X}", id); LOG_INFO(Movie, "Loaded Movie, ID: {:016X}", id);
} }

View file

@ -42,8 +42,8 @@ public:
return s_instance; return s_instance;
} }
void StartPlayback(const std::string& movie_file, void SetPlaybackCompletionCallback(std::function<void()> completion_callback);
std::function<void()> completion_callback = [] {}); void StartPlayback(const std::string& movie_file);
void StartRecording(const std::string& movie_file, const std::string& author); void StartRecording(const std::string& movie_file, const std::string& author);
/** /**
@ -165,7 +165,7 @@ private:
u32 rerecord_count = 1; u32 rerecord_count = 1;
bool read_only = true; bool read_only = true;
std::function<void()> playback_completion_callback; std::function<void()> playback_completion_callback = [] {};
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version); void serialize(Archive& ar, const unsigned int file_version);