use of android.os.ConditionVariable in project android_frameworks_base by ParanoidAndroid.
the class MediaPlayerPerformance method initializeMessageLooper.
private void initializeMessageLooper() {
final ConditionVariable startDone = new ConditionVariable();
new Thread() {
@Override
public void run() {
Looper.prepare();
Log.v(TAG, "start loopRun");
mLooper = Looper.myLooper();
mCamera = Camera.open(CAMERA_ID);
startDone.open();
Looper.loop();
Log.v(TAG, "initializeMessageLooper: quit.");
}
}.start();
if (!startDone.block(WAIT_FOR_COMMAND_TO_COMPLETE)) {
fail("initializeMessageLooper: start timeout");
}
}
use of android.os.ConditionVariable in project android_frameworks_base by ParanoidAndroid.
the class SyncRunner method scheduleFilterWake.
protected void scheduleFilterWake(Filter filter, int delay) {
// Close the wake condition
mWakeCondition.close();
// Schedule the wake-up
final Filter filterToSchedule = filter;
final ConditionVariable conditionToWake = mWakeCondition;
mWakeExecutor.schedule(new Runnable() {
@Override
public void run() {
filterToSchedule.unsetStatus(Filter.STATUS_SLEEPING);
conditionToWake.open();
}
}, delay, TimeUnit.MILLISECONDS);
}
use of android.os.ConditionVariable in project platform_frameworks_base by android.
the class MediaPlayerPerformance method initializeMessageLooper.
private void initializeMessageLooper() {
final ConditionVariable startDone = new ConditionVariable();
new Thread() {
@Override
public void run() {
Looper.prepare();
Log.v(TAG, "start loopRun");
mLooper = Looper.myLooper();
mCamera = Camera.open(CAMERA_ID);
startDone.open();
Looper.loop();
Log.v(TAG, "initializeMessageLooper: quit.");
}
}.start();
if (!startDone.block(WAIT_FOR_COMMAND_TO_COMPLETE)) {
fail("initializeMessageLooper: start timeout");
}
}
use of android.os.ConditionVariable in project platform_frameworks_base by android.
the class GLThreadManager method setConfigurationAndWait.
/**
* Configure the GL renderer for the given set of output surfaces, and block until
* this configuration has been applied.
*
* @param surfaces a collection of pairs of {@link android.view.Surface}s and their
* corresponding sizes to configure.
* @param collector a {@link CaptureCollector} to retrieve requests from.
*/
public void setConfigurationAndWait(Collection<Pair<Surface, Size>> surfaces, CaptureCollector collector) {
checkNotNull(collector, "collector must not be null");
Handler handler = mGLHandlerThread.getHandler();
final ConditionVariable condition = new ConditionVariable(/*closed*/
false);
ConfigureHolder configure = new ConfigureHolder(condition, surfaces, collector);
Message m = handler.obtainMessage(MSG_NEW_CONFIGURATION, /*arg1*/
0, /*arg2*/
0, configure);
handler.sendMessage(m);
// Block until configuration applied.
condition.block();
}
use of android.os.ConditionVariable in project platform_frameworks_base by android.
the class RequestThreadManager method configure.
/**
* Configure with the current list of output Surfaces.
*
* <p>
* This operation blocks until the configuration is complete.
* </p>
*
* <p>Using a {@code null} or empty {@code outputs} list is the equivalent of unconfiguring.</p>
*
* @param outputs a {@link java.util.Collection} of outputs to configure.
*/
public void configure(Collection<Pair<Surface, Size>> outputs) {
Handler handler = mRequestThread.waitAndGetHandler();
final ConditionVariable condition = new ConditionVariable(/*closed*/
false);
ConfigureHolder holder = new ConfigureHolder(condition, outputs);
handler.sendMessage(handler.obtainMessage(MSG_CONFIGURE_OUTPUTS, 0, 0, holder));
condition.block();
}
Aggregations