XashActivity: Better use onPause for saving configs only, as this method is unkillable. onStop will just stop engine.
This commit is contained in:
parent
323e314714
commit
3b5e5462b4
1 changed files with 33 additions and 4 deletions
|
@ -232,6 +232,13 @@ public class XashActivity extends Activity {
|
|||
@Override
|
||||
protected void onPause() {
|
||||
Log.v(TAG, "onPause()");
|
||||
|
||||
// let engine save all configs before exiting.
|
||||
nativeOnPause();
|
||||
|
||||
// wait until Xash will save all configs
|
||||
mSurface.engineThreadWait();
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
@ -246,11 +253,11 @@ public class XashActivity extends Activity {
|
|||
Log.v(TAG, "onStop()");
|
||||
|
||||
// let engine properly exit, instead of killing it's thread
|
||||
nativeQuitEvent();
|
||||
nativeOnStop();
|
||||
|
||||
// wait until Xash will exit
|
||||
mSurface.engineThreadJoin();
|
||||
|
||||
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
@ -279,7 +286,8 @@ public class XashActivity extends Activity {
|
|||
public static native void nativeBall(int id, byte ball, short xrel, short yrel);
|
||||
public static native void nativeJoyAdd( int id );
|
||||
public static native void nativeJoyDel( int id );
|
||||
public static native void nativeQuitEvent();
|
||||
public static native void nativeOnStop();
|
||||
public static native void nativeOnPause();
|
||||
|
||||
public static native int setenv(String key, String value, boolean overwrite);
|
||||
|
||||
|
@ -293,6 +301,10 @@ public class XashActivity extends Activity {
|
|||
mSurface.SwapBuffers();
|
||||
}
|
||||
|
||||
public static void engineThreadNotify() {
|
||||
mSurface.engineThreadNotify();
|
||||
}
|
||||
|
||||
public static Surface getNativeSurface() {
|
||||
return XashActivity.mSurface.getNativeSurface();
|
||||
}
|
||||
|
@ -649,7 +661,24 @@ View.OnKeyListener {
|
|||
catch(InterruptedException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void engineThreadWait()
|
||||
{
|
||||
Log.v(TAG, "engineThreadWait()");
|
||||
try
|
||||
{
|
||||
mEngThread.wait(); // wait until Xash will quit
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void engineThreadNotify()
|
||||
{
|
||||
Log.v(TAG, "engineThreadNotify()");
|
||||
mEngThread.notify(); // unblock
|
||||
}
|
||||
|
||||
// unused
|
||||
|
|
Loading…
Add table
Reference in a new issue