Merge "Abort read() after CameraSource has stopped" into pi-dev

gugelfrei
TreeHugger Robot 6 years ago committed by Android (Google) Code Review
commit 29ac15a480

@ -217,6 +217,7 @@ CameraSource::CameraSource(
mNumFramesReceived(0),
mLastFrameTimestampUs(0),
mStarted(false),
mEos(false),
mNumFramesEncoded(0),
mTimeBetweenFrameCaptureUs(0),
mFirstFrameTimeUs(0),
@ -880,6 +881,7 @@ status_t CameraSource::reset() {
{
Mutex::Autolock autoLock(mLock);
mStarted = false;
mEos = false;
mStopSystemTimeUs = -1;
mFrameAvailableCondition.signal();
@ -1075,7 +1077,7 @@ status_t CameraSource::read(
{
Mutex::Autolock autoLock(mLock);
while (mStarted && mFramesReceived.empty()) {
while (mStarted && !mEos && mFramesReceived.empty()) {
if (NO_ERROR !=
mFrameAvailableCondition.waitRelative(mLock,
mTimeBetweenFrameCaptureUs * 1000LL + CAMERA_SOURCE_TIMEOUT_NS)) {
@ -1091,6 +1093,9 @@ status_t CameraSource::read(
if (!mStarted) {
return OK;
}
if (mFramesReceived.empty()) {
return ERROR_END_OF_STREAM;
}
frame = *mFramesReceived.begin();
mFramesReceived.erase(mFramesReceived.begin());
@ -1129,6 +1134,8 @@ bool CameraSource::shouldSkipFrameLocked(int64_t timestampUs) {
if (mStopSystemTimeUs != -1 && timestampUs >= mStopSystemTimeUs) {
ALOGV("Drop Camera frame at %lld stop time: %lld us",
(long long)timestampUs, (long long)mStopSystemTimeUs);
mEos = true;
mFrameAvailableCondition.signal();
return true;
}

@ -204,6 +204,7 @@ protected:
int32_t mNumFramesReceived;
int64_t mLastFrameTimestampUs;
bool mStarted;
bool mEos;
int32_t mNumFramesEncoded;
// Time between capture of two frames.

Loading…
Cancel
Save