Merge "Camera2/3: Create JPEG stream unconditionally." into jb-mr2-dev
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index 34bae29..df25d7b 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -278,7 +278,7 @@
void deferMessage(const sp<AMessage> &msg);
void processDeferredMessages();
- void sendFormatChange();
+ void sendFormatChange(const sp<AMessage> &reply);
void signalError(
OMX_ERRORTYPE error = OMX_ErrorUndefined,
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index 64e3885..cf41cf2 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -2229,7 +2229,7 @@
}
}
-void ACodec::sendFormatChange() {
+void ACodec::sendFormatChange(const sp<AMessage> &reply) {
sp<AMessage> notify = mNotify->dup();
notify->setInt32("what", kWhatOutputFormatChanged);
@@ -2294,14 +2294,12 @@
rect.nTop + rect.nHeight - 1);
if (mNativeWindow != NULL) {
- android_native_rect_t crop;
- crop.left = rect.nLeft;
- crop.top = rect.nTop;
- crop.right = rect.nLeft + rect.nWidth;
- crop.bottom = rect.nTop + rect.nHeight;
-
- CHECK_EQ(0, native_window_set_crop(
- mNativeWindow.get(), &crop));
+ reply->setRect(
+ "crop",
+ rect.nLeft,
+ rect.nTop,
+ rect.nLeft + rect.nWidth,
+ rect.nTop + rect.nHeight);
}
}
break;
@@ -3057,8 +3055,11 @@
break;
}
+ sp<AMessage> reply =
+ new AMessage(kWhatOutputBufferDrained, mCodec->id());
+
if (!mCodec->mSentFormat) {
- mCodec->sendFormatChange();
+ mCodec->sendFormatChange(reply);
}
info->mData->setRange(rangeOffset, rangeLength);
@@ -3081,9 +3082,6 @@
notify->setBuffer("buffer", info->mData);
notify->setInt32("flags", flags);
- sp<AMessage> reply =
- new AMessage(kWhatOutputBufferDrained, mCodec->id());
-
reply->setPointer("buffer-id", info->mBufferID);
notify->setMessage("reply", reply);
@@ -3127,6 +3125,13 @@
mCodec->findBufferByID(kPortIndexOutput, bufferID, &index);
CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_DOWNSTREAM);
+ android_native_rect_t crop;
+ if (msg->findRect("crop",
+ &crop.left, &crop.top, &crop.right, &crop.bottom)) {
+ CHECK_EQ(0, native_window_set_crop(
+ mCodec->mNativeWindow.get(), &crop));
+ }
+
int32_t render;
if (mCodec->mNativeWindow != NULL
&& msg->findInt32("render", &render) && render != 0
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 6422b23..97f66f4 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -1330,13 +1330,11 @@
track->mResetDone = false;
track->mPresentationCompleteFrames = 0;
mActiveTracks.add(track);
- if (track->mainBuffer() != mMixBuffer) {
- sp<EffectChain> chain = getEffectChain_l(track->sessionId());
- if (chain != 0) {
- ALOGV("addTrack_l() starting track on chain %p for session %d", chain.get(),
- track->sessionId());
- chain->incActiveTrackCnt();
- }
+ sp<EffectChain> chain = getEffectChain_l(track->sessionId());
+ if (chain != 0) {
+ ALOGV("addTrack_l() starting track on chain %p for session %d", chain.get(),
+ track->sessionId());
+ chain->incActiveTrackCnt();
}
status = NO_ERROR;
diff --git a/services/camera/libcameraservice/Camera3Device.cpp b/services/camera/libcameraservice/Camera3Device.cpp
index c7edb76..bc4db91 100644
--- a/services/camera/libcameraservice/Camera3Device.cpp
+++ b/services/camera/libcameraservice/Camera3Device.cpp
@@ -170,6 +170,7 @@
mHal3Device = device;
mStatus = STATUS_IDLE;
mNextStreamId = 0;
+ mNeedConfig = true;
return OK;
}
@@ -582,6 +583,7 @@
}
*id = mNextStreamId++;
+ mNeedConfig = true;
// Continue captures if active at start
if (wasActive) {
@@ -707,6 +709,7 @@
// fall through since we want to still list the stream as deleted.
}
mDeletedStreams.add(deletedStream);
+ mNeedConfig = true;
return res;
}
@@ -1007,6 +1010,11 @@
return INVALID_OPERATION;
}
+ if (!mNeedConfig) {
+ ALOGV("%s: Skipping config, no stream changes", __FUNCTION__);
+ return OK;
+ }
+
// Start configuring the streams
camera3_stream_configuration config;
@@ -1091,6 +1099,7 @@
// Finish configuring the streams lazily on first reference
mStatus = STATUS_ACTIVE;
+ mNeedConfig = false;
return OK;
}
diff --git a/services/camera/libcameraservice/Camera3Device.h b/services/camera/libcameraservice/Camera3Device.h
index 7a8c22a..faa42b9 100644
--- a/services/camera/libcameraservice/Camera3Device.h
+++ b/services/camera/libcameraservice/Camera3Device.h
@@ -149,6 +149,7 @@
StreamSet mOutputStreams;
sp<camera3::Camera3Stream> mInputStream;
int mNextStreamId;
+ bool mNeedConfig;
// Need to hold on to stream references until configure completes.
Vector<sp<camera3::Camera3StreamInterface> > mDeletedStreams;