mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
State: Simplify interthread communication and cleanups. Save/Load calls are now always non-blocking for the caller, but appropriately block the CPU thread as needed.
This commit is contained in:
@@ -233,19 +233,17 @@ object NativeLibrary {
|
||||
* Saves a game state to the slot number.
|
||||
*
|
||||
* @param slot The slot location to save state to.
|
||||
* @param wait If false, returns as early as possible. If true, returns once the savestate has been written to disk.
|
||||
*/
|
||||
@JvmStatic
|
||||
external fun SaveState(slot: Int, wait: Boolean)
|
||||
external fun SaveState(slot: Int)
|
||||
|
||||
/**
|
||||
* Saves a game state to the specified path.
|
||||
*
|
||||
* @param path The path to save state to.
|
||||
* @param wait If false, returns as early as possible. If true, returns once the savestate has been written to disk.
|
||||
*/
|
||||
@JvmStatic
|
||||
external fun SaveStateAs(path: String, wait: Boolean)
|
||||
external fun SaveStateAs(path: String)
|
||||
|
||||
/**
|
||||
* Loads a game state from the slot number.
|
||||
|
||||
+7
-7
@@ -494,16 +494,16 @@ class EmulationActivity : AppCompatActivity(), ThemeProvider {
|
||||
}
|
||||
|
||||
MENU_ACTION_TAKE_SCREENSHOT -> NativeLibrary.SaveScreenShot()
|
||||
MENU_ACTION_QUICK_SAVE -> NativeLibrary.SaveState(9, false)
|
||||
MENU_ACTION_QUICK_SAVE -> NativeLibrary.SaveState(9)
|
||||
MENU_ACTION_QUICK_LOAD -> NativeLibrary.LoadState(9)
|
||||
MENU_ACTION_SAVE_ROOT -> showSubMenu(SaveOrLoad.SAVE)
|
||||
MENU_ACTION_LOAD_ROOT -> showSubMenu(SaveOrLoad.LOAD)
|
||||
MENU_ACTION_SAVE_SLOT1 -> NativeLibrary.SaveState(0, false)
|
||||
MENU_ACTION_SAVE_SLOT2 -> NativeLibrary.SaveState(1, false)
|
||||
MENU_ACTION_SAVE_SLOT3 -> NativeLibrary.SaveState(2, false)
|
||||
MENU_ACTION_SAVE_SLOT4 -> NativeLibrary.SaveState(3, false)
|
||||
MENU_ACTION_SAVE_SLOT5 -> NativeLibrary.SaveState(4, false)
|
||||
MENU_ACTION_SAVE_SLOT6 -> NativeLibrary.SaveState(5, false)
|
||||
MENU_ACTION_SAVE_SLOT1 -> NativeLibrary.SaveState(0)
|
||||
MENU_ACTION_SAVE_SLOT2 -> NativeLibrary.SaveState(1)
|
||||
MENU_ACTION_SAVE_SLOT3 -> NativeLibrary.SaveState(2)
|
||||
MENU_ACTION_SAVE_SLOT4 -> NativeLibrary.SaveState(3)
|
||||
MENU_ACTION_SAVE_SLOT5 -> NativeLibrary.SaveState(4)
|
||||
MENU_ACTION_SAVE_SLOT6 -> NativeLibrary.SaveState(5)
|
||||
MENU_ACTION_LOAD_SLOT1 -> NativeLibrary.LoadState(0)
|
||||
MENU_ACTION_LOAD_SLOT2 -> NativeLibrary.LoadState(1)
|
||||
MENU_ACTION_LOAD_SLOT3 -> NativeLibrary.LoadState(2)
|
||||
|
||||
+1
-1
@@ -232,7 +232,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
fun saveTemporaryState() = NativeLibrary.SaveStateAs(temporaryStateFilePath, true)
|
||||
fun saveTemporaryState() = NativeLibrary.SaveStateAs(temporaryStateFilePath)
|
||||
|
||||
private val temporaryStateFilePath: String
|
||||
get() = "${requireContext().filesDir}${File.separator}temp.sav"
|
||||
|
||||
@@ -310,19 +310,17 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_eglBindAPI(J
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveState(JNIEnv*, jclass,
|
||||
jint slot,
|
||||
jboolean wait)
|
||||
jint slot)
|
||||
{
|
||||
HostThreadLock guard;
|
||||
State::Save(Core::System::GetInstance(), slot, wait);
|
||||
State::Save(Core::System::GetInstance(), slot);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SaveStateAs(JNIEnv* env, jclass,
|
||||
jstring path,
|
||||
jboolean wait)
|
||||
jstring path)
|
||||
{
|
||||
HostThreadLock guard;
|
||||
State::SaveAs(Core::System::GetInstance(), GetJString(env, path), wait);
|
||||
State::SaveAs(Core::System::GetInstance(), GetJString(env, path));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_LoadState(JNIEnv*, jclass,
|
||||
|
||||
+310
-341
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,6 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "Common/Buffer.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace Core
|
||||
@@ -81,13 +80,8 @@ struct StateExtendedHeader
|
||||
};
|
||||
|
||||
void Init(Core::System& system);
|
||||
|
||||
void Shutdown();
|
||||
|
||||
void EnableCompression(bool compression);
|
||||
|
||||
bool ReadHeader(const std::string& filename, StateHeader& header);
|
||||
|
||||
// Returns a string containing information of the savestate in the given slot
|
||||
// which can be presented to the user for identification purposes
|
||||
std::string GetInfoStringOfSlot(int slot, bool translate = true);
|
||||
@@ -97,17 +91,12 @@ u64 GetUnixTimeOfSlot(int slot);
|
||||
|
||||
// These don't happen instantly - they get scheduled as events.
|
||||
// ...But only if we're not in the main CPU thread.
|
||||
// If we're in the main CPU thread then they run immediately instead
|
||||
// because some things (like Lua) need them to run immediately.
|
||||
// Slots from 0-99.
|
||||
void Save(Core::System& system, int slot, bool wait = false);
|
||||
// If we're in the main CPU thread then they run immediately instead.
|
||||
void Save(Core::System& system, int slot);
|
||||
void Load(Core::System& system, int slot);
|
||||
|
||||
void SaveAs(Core::System& system, const std::string& filename, bool wait = false);
|
||||
void LoadAs(Core::System& system, const std::string& filename);
|
||||
|
||||
void SaveToBuffer(Core::System& system, Common::UniqueBuffer<u8>& buffer);
|
||||
void LoadFromBuffer(Core::System& system, Common::UniqueBuffer<u8>& buffer);
|
||||
void SaveAs(Core::System& system, std::string filename);
|
||||
void LoadAs(Core::System& system, std::string filename);
|
||||
|
||||
void LoadLastSaved(Core::System& system, int i = 1);
|
||||
void SaveFirstSaved(Core::System& system);
|
||||
|
||||
Reference in New Issue
Block a user