|
|
@ -38,6 +38,10 @@ abstract class CameraController implements CameraPreview.SurfaceCallback { |
|
|
|
|
|
|
|
|
|
|
|
protected int mDisplayOffset; |
|
|
|
protected int mDisplayOffset; |
|
|
|
protected int mDeviceOrientation; |
|
|
|
protected int mDeviceOrientation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean mScheduledForStart = false; |
|
|
|
|
|
|
|
protected boolean mScheduledForStop = false; |
|
|
|
|
|
|
|
protected boolean mScheduledForRestart = false; |
|
|
|
protected int mState = STATE_STOPPED; |
|
|
|
protected int mState = STATE_STOPPED; |
|
|
|
|
|
|
|
|
|
|
|
protected WorkerHandler mHandler; |
|
|
|
protected WorkerHandler mHandler; |
|
|
@ -84,11 +88,13 @@ abstract class CameraController implements CameraPreview.SurfaceCallback { |
|
|
|
// Starts the preview asynchronously.
|
|
|
|
// Starts the preview asynchronously.
|
|
|
|
final void start() { |
|
|
|
final void start() { |
|
|
|
LOG.i("Start:", "posting runnable. State:", ss()); |
|
|
|
LOG.i("Start:", "posting runnable. State:", ss()); |
|
|
|
|
|
|
|
mScheduledForStart = true; |
|
|
|
mHandler.post(new Runnable() { |
|
|
|
mHandler.post(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
LOG.i("Start:", "executing. State:", ss()); |
|
|
|
LOG.i("Start:", "executing. State:", ss()); |
|
|
|
|
|
|
|
mScheduledForStart = false; |
|
|
|
if (mState >= STATE_STARTING) return; |
|
|
|
if (mState >= STATE_STARTING) return; |
|
|
|
mState = STATE_STARTING; |
|
|
|
mState = STATE_STARTING; |
|
|
|
LOG.i("Start:", "about to call onStart()", ss()); |
|
|
|
LOG.i("Start:", "about to call onStart()", ss()); |
|
|
@ -108,11 +114,13 @@ abstract class CameraController implements CameraPreview.SurfaceCallback { |
|
|
|
// Stops the preview asynchronously.
|
|
|
|
// Stops the preview asynchronously.
|
|
|
|
final void stop() { |
|
|
|
final void stop() { |
|
|
|
LOG.i("Stop:", "posting runnable. State:", ss()); |
|
|
|
LOG.i("Stop:", "posting runnable. State:", ss()); |
|
|
|
|
|
|
|
mScheduledForStop = true; |
|
|
|
mHandler.post(new Runnable() { |
|
|
|
mHandler.post(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
LOG.i("Stop:", "executing. State:", ss()); |
|
|
|
LOG.i("Stop:", "executing. State:", ss()); |
|
|
|
|
|
|
|
mScheduledForStop = false; |
|
|
|
if (mState <= STATE_STOPPED) return; |
|
|
|
if (mState <= STATE_STOPPED) return; |
|
|
|
mState = STATE_STOPPING; |
|
|
|
mState = STATE_STOPPING; |
|
|
|
LOG.i("Stop:", "about to call onStop()"); |
|
|
|
LOG.i("Stop:", "about to call onStop()"); |
|
|
@ -148,11 +156,13 @@ abstract class CameraController implements CameraPreview.SurfaceCallback { |
|
|
|
// Forces a restart.
|
|
|
|
// Forces a restart.
|
|
|
|
protected final void restart() { |
|
|
|
protected final void restart() { |
|
|
|
LOG.i("Restart:", "posting runnable"); |
|
|
|
LOG.i("Restart:", "posting runnable"); |
|
|
|
|
|
|
|
mScheduledForRestart = true; |
|
|
|
mHandler.post(new Runnable() { |
|
|
|
mHandler.post(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
LOG.i("Restart:", "executing. Needs stopping:", mState > STATE_STOPPED, ss()); |
|
|
|
LOG.i("Restart:", "executing. Needs stopping:", mState > STATE_STOPPED, ss()); |
|
|
|
|
|
|
|
mScheduledForRestart = false; |
|
|
|
// Don't stop if stopped.
|
|
|
|
// Don't stop if stopped.
|
|
|
|
if (mState > STATE_STOPPED) { |
|
|
|
if (mState > STATE_STOPPED) { |
|
|
|
mState = STATE_STOPPING; |
|
|
|
mState = STATE_STOPPING; |
|
|
|