Loading services/camera/libcameraservice/device3/Camera3Device.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -2336,6 +2336,9 @@ bool Camera3Device::reconfigureCamera(const CameraMetadata& sessionParams, int c // deadlocks (http://b/143513518) nsecs_t maxExpectedDuration = getExpectedInFlightDuration(); // Make sure status tracker is flushed mStatusTracker->flushPendingStates(); Mutex::Autolock l(mLock); if (checkAbandonedStreamsLocked()) { ALOGW("%s: Abandoned stream detected, session parameters can't be applied correctly!", Loading services/camera/libcameraservice/device3/StatusTracker.cpp +39 −9 Original line number Diff line number Diff line Loading @@ -34,7 +34,8 @@ StatusTracker::StatusTracker(wp<Camera3Device> parent) : mParent(parent), mNextComponentId(0), mIdleFence(new Fence()), mDeviceState(IDLE) { mDeviceState(IDLE), mFlushed(true) { } StatusTracker::~StatusTracker() { Loading Loading @@ -111,6 +112,15 @@ void StatusTracker::markComponent(int id, ComponentState state, const sp<Fence>& componentFence) { ALOGV("%s: Component %d is now %s", __FUNCTION__, id, state == IDLE ? "idle" : "active"); // If any component state changes, the status tracker is considered // not flushed. { Mutex::Autolock l(mFlushLock); mFlushed = false; } { Mutex::Autolock l(mPendingLock); StateChange newState = { Loading @@ -122,12 +132,21 @@ void StatusTracker::markComponent(int id, ComponentState state, mPendingChangeQueue.add(newState); mPendingChangeSignal.signal(); } } void StatusTracker::flushPendingStates() { Mutex::Autolock l(mFlushLock); while (!mFlushed && isRunning()) { mFlushCondition.waitRelative(mFlushLock, kWaitDuration); } } void StatusTracker::requestExit() { // First mark thread dead Thread::requestExit(); // Then exit any waits mPendingChangeSignal.signal(); mFlushCondition.signal(); } StatusTracker::ComponentState StatusTracker::getDeviceStateLocked() { Loading Loading @@ -227,6 +246,17 @@ bool StatusTracker::threadLoop() { } mStateTransitions.clear(); // After all pending changes are cleared and notified, mark the tracker // as flushed. { Mutex::Autolock fl(mFlushLock); Mutex::Autolock pl(mPendingLock); if (mPendingChangeQueue.size() == 0) { mFlushed = true; mFlushCondition.signal(); } } return true; } Loading services/camera/libcameraservice/device3/StatusTracker.h +9 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,10 @@ class StatusTracker: public Thread { void dumpActiveComponents(); // Flush all pending states inflight in the tracker, and return upon // completion. void flushPendingStates(); virtual void requestExit(); protected: Loading Loading @@ -113,6 +117,11 @@ class StatusTracker: public Thread { // Current overall device state ComponentState mDeviceState; // For flushing all pending states transitions bool mFlushed; Mutex mFlushLock; Condition mFlushCondition; // Private to threadLoop // Determine current overall device state Loading Loading
services/camera/libcameraservice/device3/Camera3Device.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -2336,6 +2336,9 @@ bool Camera3Device::reconfigureCamera(const CameraMetadata& sessionParams, int c // deadlocks (http://b/143513518) nsecs_t maxExpectedDuration = getExpectedInFlightDuration(); // Make sure status tracker is flushed mStatusTracker->flushPendingStates(); Mutex::Autolock l(mLock); if (checkAbandonedStreamsLocked()) { ALOGW("%s: Abandoned stream detected, session parameters can't be applied correctly!", Loading
services/camera/libcameraservice/device3/StatusTracker.cpp +39 −9 Original line number Diff line number Diff line Loading @@ -34,7 +34,8 @@ StatusTracker::StatusTracker(wp<Camera3Device> parent) : mParent(parent), mNextComponentId(0), mIdleFence(new Fence()), mDeviceState(IDLE) { mDeviceState(IDLE), mFlushed(true) { } StatusTracker::~StatusTracker() { Loading Loading @@ -111,6 +112,15 @@ void StatusTracker::markComponent(int id, ComponentState state, const sp<Fence>& componentFence) { ALOGV("%s: Component %d is now %s", __FUNCTION__, id, state == IDLE ? "idle" : "active"); // If any component state changes, the status tracker is considered // not flushed. { Mutex::Autolock l(mFlushLock); mFlushed = false; } { Mutex::Autolock l(mPendingLock); StateChange newState = { Loading @@ -122,12 +132,21 @@ void StatusTracker::markComponent(int id, ComponentState state, mPendingChangeQueue.add(newState); mPendingChangeSignal.signal(); } } void StatusTracker::flushPendingStates() { Mutex::Autolock l(mFlushLock); while (!mFlushed && isRunning()) { mFlushCondition.waitRelative(mFlushLock, kWaitDuration); } } void StatusTracker::requestExit() { // First mark thread dead Thread::requestExit(); // Then exit any waits mPendingChangeSignal.signal(); mFlushCondition.signal(); } StatusTracker::ComponentState StatusTracker::getDeviceStateLocked() { Loading Loading @@ -227,6 +246,17 @@ bool StatusTracker::threadLoop() { } mStateTransitions.clear(); // After all pending changes are cleared and notified, mark the tracker // as flushed. { Mutex::Autolock fl(mFlushLock); Mutex::Autolock pl(mPendingLock); if (mPendingChangeQueue.size() == 0) { mFlushed = true; mFlushCondition.signal(); } } return true; } Loading
services/camera/libcameraservice/device3/StatusTracker.h +9 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,10 @@ class StatusTracker: public Thread { void dumpActiveComponents(); // Flush all pending states inflight in the tracker, and return upon // completion. void flushPendingStates(); virtual void requestExit(); protected: Loading Loading @@ -113,6 +117,11 @@ class StatusTracker: public Thread { // Current overall device state ComponentState mDeviceState; // For flushing all pending states transitions bool mFlushed; Mutex mFlushLock; Condition mFlushCondition; // Private to threadLoop // Determine current overall device state Loading