Created
October 2, 2015 16:05
-
-
Save ruslo/564dfa44e87ae3f32e84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Callback from SurfaceTexture.OnFrameAvailableListener. Is called each time a new | |
* camera frame for the SurfaceTexture is available. | |
*/ | |
@Override | |
public void onFrameAvailable(SurfaceTexture) { | |
synchronized (lock) { | |
frameNotification = true; | |
lock.notify(); | |
} | |
} | |
/** | |
* Thread run loop. Will run until terminate() is called. | |
*/ | |
@Override | |
public void run() { | |
Log.i(TAG, "starting thread CameraProcThread"); | |
while (running) { | |
boolean frameAvailable = false; | |
synchronized (lock) { | |
lock.wait(); | |
if (frameNotification) { | |
// Do release lock as soon as possible so if one more | |
// call to onFrameAvailable occurs there will be no need | |
// to wait. | |
frameAvailable = true; | |
frameNotification = false; | |
} | |
} | |
if (frameAvailable) { | |
processFrame(); | |
} | |
} | |
Log.i(TAG, "stopped thread CameraProcThread"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment