mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-19 19:35:41 -04:00
Android: Defer rotation request until after start
Fixes messed-up state when orientation is set.
This commit is contained in:
@ -49,7 +49,7 @@ public class AndroidHostInterface {
|
||||
|
||||
public native boolean isEmulationThreadRunning();
|
||||
|
||||
public native boolean runEmulationThread(EmulationActivity emulationActivity, Surface surface, String filename, boolean resumeState, String state_filename);
|
||||
public native boolean runEmulationThread(EmulationActivity emulationActivity, String filename, boolean resumeState, String state_filename);
|
||||
|
||||
public native boolean isEmulationThreadPaused();
|
||||
|
||||
|
@ -123,6 +123,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
|
||||
public void onEmulationStarted() {
|
||||
runOnUiThread(() -> {
|
||||
updateRequestedOrientation();
|
||||
updateOrientation();
|
||||
});
|
||||
}
|
||||
@ -196,8 +197,9 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
@Override
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
// Once we get a surface, we can boot.
|
||||
AndroidHostInterface.getInstance().surfaceChanged(holder.getSurface(), format, width, height);
|
||||
|
||||
if (mEmulationThread != null) {
|
||||
AndroidHostInterface.getInstance().surfaceChanged(holder.getSurface(), format, width, height);
|
||||
updateOrientation();
|
||||
|
||||
if (mApplySettingsOnSurfaceRestored) {
|
||||
@ -212,18 +214,15 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
final boolean resumeState = getIntent().getBooleanExtra("resumeState", false);
|
||||
final String bootSaveStatePath = getIntent().getStringExtra("saveStatePath");
|
||||
|
||||
mEmulationThread = EmulationThread.create(this, holder.getSurface(), bootPath, resumeState, bootSaveStatePath);
|
||||
mEmulationThread = EmulationThread.create(this, bootPath, resumeState, bootSaveStatePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
if (!AndroidHostInterface.getInstance().isEmulationThreadRunning())
|
||||
return;
|
||||
|
||||
Log.i("EmulationActivity", "Surface destroyed");
|
||||
|
||||
// Save the resume state in case we never get back again...
|
||||
if (!mStopRequested)
|
||||
if (AndroidHostInterface.getInstance().isEmulationThreadRunning() && !mStopRequested)
|
||||
AndroidHostInterface.getInstance().saveResumeState(true);
|
||||
|
||||
AndroidHostInterface.getInstance().surfaceChanged(null, 0, 0, 0);
|
||||
@ -231,9 +230,9 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
Log.i("EmulationActivity", "OnCreate");
|
||||
|
||||
// we might be coming from a third-party launcher if the host interface isn't setup
|
||||
@ -255,7 +254,6 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
mContentView.requestFocus();
|
||||
|
||||
// Sort out rotation.
|
||||
updateRequestedOrientation();
|
||||
updateOrientation();
|
||||
updateSustainedPerformanceMode();
|
||||
|
||||
|
@ -8,24 +8,22 @@ import androidx.annotation.NonNull;
|
||||
|
||||
public class EmulationThread extends Thread {
|
||||
private EmulationActivity emulationActivity;
|
||||
private Surface surface;
|
||||
private String filename;
|
||||
private boolean resumeState;
|
||||
private String stateFilename;
|
||||
|
||||
private EmulationThread(EmulationActivity emulationActivity, Surface surface, String filename, boolean resumeState, String stateFilename) {
|
||||
private EmulationThread(EmulationActivity emulationActivity, String filename, boolean resumeState, String stateFilename) {
|
||||
super("EmulationThread");
|
||||
this.emulationActivity = emulationActivity;
|
||||
this.surface = surface;
|
||||
this.filename = filename;
|
||||
this.resumeState = resumeState;
|
||||
this.stateFilename = stateFilename;
|
||||
}
|
||||
|
||||
public static EmulationThread create(EmulationActivity emulationActivity, Surface surface, String filename, boolean resumeState, String stateFilename) {
|
||||
public static EmulationThread create(EmulationActivity emulationActivity, String filename, boolean resumeState, String stateFilename) {
|
||||
Log.i("EmulationThread", String.format("Starting emulation thread (%s)...", filename));
|
||||
|
||||
EmulationThread thread = new EmulationThread(emulationActivity, surface, filename, resumeState, stateFilename);
|
||||
EmulationThread thread = new EmulationThread(emulationActivity, filename, resumeState, stateFilename);
|
||||
thread.start();
|
||||
return thread;
|
||||
}
|
||||
@ -38,7 +36,7 @@ public class EmulationThread extends Thread {
|
||||
Log.i("EmulationThread", "Failed to set priority for emulation thread: " + e.getMessage());
|
||||
}
|
||||
|
||||
AndroidHostInterface.getInstance().runEmulationThread(emulationActivity, surface, filename, resumeState, stateFilename);
|
||||
AndroidHostInterface.getInstance().runEmulationThread(emulationActivity, filename, resumeState, stateFilename);
|
||||
Log.i("EmulationThread", "Emulation thread exiting.");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user