Merge "AudioPolicyManager: only modify surround formats for HDMI devices" into nyc-dev
diff --git a/camera/ndk/NdkCameraCaptureSession.cpp b/camera/ndk/NdkCameraCaptureSession.cpp
index ab93bd6..d6eff24 100644
--- a/camera/ndk/NdkCameraCaptureSession.cpp
+++ b/camera/ndk/NdkCameraCaptureSession.cpp
@@ -122,7 +122,16 @@
}
EXPORT
-camera_status_t ACameraCaptureSession_abortCaptures(ACameraCaptureSession*) {
+camera_status_t ACameraCaptureSession_abortCaptures(ACameraCaptureSession* session) {
ATRACE_CALL();
- return ACAMERA_OK;
+ if (session == nullptr) {
+ ALOGE("%s: Error: session is null", __FUNCTION__);
+ return ACAMERA_ERROR_INVALID_PARAMETER;
+ }
+
+ if (session->isClosed()) {
+ ALOGE("%s: session %p is already closed", __FUNCTION__, session);
+ return ACAMERA_ERROR_SESSION_CLOSED;
+ }
+ return session->abortCaptures();
}
diff --git a/camera/ndk/impl/ACameraCaptureSession.cpp b/camera/ndk/impl/ACameraCaptureSession.cpp
index b741e46..b9c159d 100644
--- a/camera/ndk/impl/ACameraCaptureSession.cpp
+++ b/camera/ndk/impl/ACameraCaptureSession.cpp
@@ -90,6 +90,24 @@
}
camera_status_t
+ACameraCaptureSession::abortCaptures() {
+ sp<CameraDevice> dev = getDeviceSp();
+ if (dev == nullptr) {
+ ALOGE("Error: Device associated with session %p has been closed!", this);
+ return ACAMERA_ERROR_SESSION_CLOSED;
+ }
+
+ camera_status_t ret;
+ dev->lockDeviceForSessionOps();
+ {
+ Mutex::Autolock _l(mSessionLock);
+ ret = dev->flushLocked(this);
+ }
+ dev->unlockDevice();
+ return ret;
+}
+
+camera_status_t
ACameraCaptureSession::setRepeatingRequest(
/*optional*/ACameraCaptureSession_captureCallbacks* cbs,
int numRequests, ACaptureRequest** requests,
diff --git a/camera/ndk/impl/ACameraCaptureSession.h b/camera/ndk/impl/ACameraCaptureSession.h
index f20b324..58428e6 100644
--- a/camera/ndk/impl/ACameraCaptureSession.h
+++ b/camera/ndk/impl/ACameraCaptureSession.h
@@ -77,6 +77,8 @@
camera_status_t stopRepeating();
+ camera_status_t abortCaptures();
+
camera_status_t setRepeatingRequest(
/*optional*/ACameraCaptureSession_captureCallbacks* cbs,
int numRequests, ACaptureRequest** requests,
@@ -104,7 +106,6 @@
const wp<CameraDevice> mDevice;
bool mIsClosed = false;
bool mClosedByApp = false;
- bool mIdle = true;
Mutex mSessionLock;
};
diff --git a/camera/ndk/impl/ACameraDevice.cpp b/camera/ndk/impl/ACameraDevice.cpp
index 6bca692..8f1115a 100644
--- a/camera/ndk/impl/ACameraDevice.cpp
+++ b/camera/ndk/impl/ACameraDevice.cpp
@@ -170,6 +170,7 @@
// set new session as current session
newSession->incStrong((void *) ACameraDevice_createCaptureSession);
mCurrentSession = newSession;
+ mFlushing = false;
*session = newSession;
return ACAMERA_OK;
}
@@ -389,6 +390,58 @@
}
camera_status_t
+CameraDevice::flushLocked(ACameraCaptureSession* session) {
+ camera_status_t ret = checkCameraClosedOrErrorLocked();
+ if (ret != ACAMERA_OK) {
+ ALOGE("Camera %s abort captures failed! ret %d", getId(), ret);
+ return ret;
+ }
+
+ // This should never happen because creating a new session will close
+ // previous one and thus reject any API call from previous session.
+ // But still good to check here in case something unexpected happen.
+ if (session != mCurrentSession) {
+ ALOGE("Camera %s session %p is not current active session!", getId(), session);
+ return ACAMERA_ERROR_INVALID_OPERATION;
+ }
+
+ if (mFlushing) {
+ ALOGW("Camera %s is already aborting captures", getId());
+ return ACAMERA_OK;
+ }
+
+ mFlushing = true;
+ // Send onActive callback to guarantee there is always active->ready transition
+ sp<AMessage> msg = new AMessage(kWhatSessionStateCb, mHandler);
+ msg->setPointer(kContextKey, session->mUserSessionCallback.context);
+ msg->setObject(kSessionSpKey, session);
+ msg->setPointer(kCallbackFpKey, (void*) session->mUserSessionCallback.onActive);
+ msg->post();
+
+ // If device is already idling, send callback and exit early
+ if (mIdle) {
+ sp<AMessage> msg = new AMessage(kWhatSessionStateCb, mHandler);
+ msg->setPointer(kContextKey, session->mUserSessionCallback.context);
+ msg->setObject(kSessionSpKey, session);
+ msg->setPointer(kCallbackFpKey, (void*) session->mUserSessionCallback.onReady);
+ msg->post();
+ mFlushing = false;
+ return ACAMERA_OK;
+ }
+
+ int64_t lastFrameNumber;
+ binder::Status remoteRet = mRemote->flush(&lastFrameNumber);
+ if (!remoteRet.isOk()) {
+ ALOGE("Abort captures fails in remote: %s", remoteRet.toString8().string());
+ return ACAMERA_ERROR_UNKNOWN;
+ }
+ if (mRepeatingSequenceId != REQUEST_ID_NONE) {
+ checkRepeatingSequenceCompleteLocked(mRepeatingSequenceId, lastFrameNumber);
+ }
+ return ACAMERA_OK;
+}
+
+camera_status_t
CameraDevice::waitUntilIdleLocked() {
camera_status_t ret = checkCameraClosedOrErrorLocked();
if (ret != ACAMERA_OK) {
@@ -1109,6 +1162,7 @@
msg->post();
}
dev->mIdle = true;
+ dev->mFlushing = false;
return ret;
}
diff --git a/camera/ndk/impl/ACameraDevice.h b/camera/ndk/impl/ACameraDevice.h
index 46243b9..fd51a81 100644
--- a/camera/ndk/impl/ACameraDevice.h
+++ b/camera/ndk/impl/ACameraDevice.h
@@ -96,6 +96,8 @@
camera_status_t stopRepeatingLocked();
+ camera_status_t flushLocked(ACameraCaptureSession*);
+
camera_status_t waitUntilIdleLocked();
@@ -152,13 +154,13 @@
std::atomic_bool mClosing;
inline bool isClosed() { return mClosing; }
- bool mInError;
- camera_status_t mError;
+ bool mInError = false;
+ camera_status_t mError = ACAMERA_OK;
void onCaptureErrorLocked(
int32_t errorCode,
const CaptureResultExtras& resultExtras);
- bool mIdle;
+ bool mIdle = true;
// This will avoid a busy session being deleted before it's back to idle state
sp<ACameraCaptureSession> mBusySession;
@@ -203,6 +205,7 @@
***********************************/
// The current active session
ACameraCaptureSession* mCurrentSession = nullptr;
+ bool mFlushing = false;
int mNextSessionId = 0;
// TODO: might need another looper/handler to handle callbacks from service
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index d6a9f53..aebe479 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -3945,15 +3945,14 @@
h264type.eProfile = static_cast<OMX_VIDEO_AVCPROFILETYPE>(profile);
h264type.eLevel = static_cast<OMX_VIDEO_AVCLEVELTYPE>(level);
- }
-
- // XXX
- if (h264type.eProfile != OMX_VIDEO_AVCProfileBaseline) {
- ALOGW("Use baseline profile instead of %d for AVC recording",
- h264type.eProfile);
+ } else {
+ // Use baseline profile for AVC recording if profile is not specified.
h264type.eProfile = OMX_VIDEO_AVCProfileBaseline;
}
+ ALOGI("setupAVCEncoderParameters with [profile: %s] [level: %s]",
+ asString(h264type.eProfile), asString(h264type.eLevel));
+
if (h264type.eProfile == OMX_VIDEO_AVCProfileBaseline) {
h264type.nSliceHeaderSpacing = 0;
h264type.bUseHadamard = OMX_TRUE;
@@ -3971,6 +3970,23 @@
h264type.bDirect8x8Inference = OMX_FALSE;
h264type.bDirectSpatialTemporal = OMX_FALSE;
h264type.nCabacInitIdc = 0;
+ } else if (h264type.eProfile == OMX_VIDEO_AVCProfileMain ||
+ h264type.eProfile == OMX_VIDEO_AVCProfileHigh) {
+ h264type.nSliceHeaderSpacing = 0;
+ h264type.bUseHadamard = OMX_TRUE;
+ h264type.nRefFrames = 2;
+ h264type.nBFrames = 1;
+ h264type.nPFrames = setPFramesSpacing(iFrameInterval, frameRate);
+ h264type.nAllowedPictureTypes =
+ OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP | OMX_VIDEO_PictureTypeB;
+ h264type.nRefIdx10ActiveMinus1 = 0;
+ h264type.nRefIdx11ActiveMinus1 = 0;
+ h264type.bEntropyCodingCABAC = OMX_TRUE;
+ h264type.bWeightedPPrediction = OMX_TRUE;
+ h264type.bconstIpred = OMX_TRUE;
+ h264type.bDirect8x8Inference = OMX_TRUE;
+ h264type.bDirectSpatialTemporal = OMX_TRUE;
+ h264type.nCabacInitIdc = 1;
}
if (h264type.nBFrames != 0) {
diff --git a/media/mediaserver/Android.mk b/media/mediaserver/Android.mk
index 2cec5d2..1738df8 100644
--- a/media/mediaserver/Android.mk
+++ b/media/mediaserver/Android.mk
@@ -5,6 +5,7 @@
LOCAL_SRC_FILES := register.cpp
LOCAL_MODULE := libregistermsext
LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS := -Werror -Wall
include $(BUILD_STATIC_LIBRARY)
endif
@@ -39,4 +40,6 @@
LOCAL_INIT_RC := mediaserver.rc
+LOCAL_CFLAGS := -Werror -Wall
+
include $(BUILD_EXECUTABLE)
diff --git a/radio/Android.mk b/radio/Android.mk
index ecbb8fd..0377328 100644
--- a/radio/Android.mk
+++ b/radio/Android.mk
@@ -36,4 +36,6 @@
LOCAL_MODULE:= libradio
+LOCAL_CFLAGS := -Werror -Wall
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/soundtrigger/Android.mk b/soundtrigger/Android.mk
index d91c4c2..c794cc1 100644
--- a/soundtrigger/Android.mk
+++ b/soundtrigger/Android.mk
@@ -35,4 +35,6 @@
LOCAL_MODULE:= libsoundtrigger
+LOCAL_CFLAGS := -Werror -Wall
+
include $(BUILD_SHARED_LIBRARY)
diff --git a/tools/resampler_tools/Android.mk b/tools/resampler_tools/Android.mk
index b58e4cd..bba5199 100644
--- a/tools/resampler_tools/Android.mk
+++ b/tools/resampler_tools/Android.mk
@@ -12,6 +12,6 @@
LOCAL_MODULE := fir
+LOCAL_CFLAGS := -Werror -Wall
+
include $(BUILD_HOST_EXECUTABLE)
-
-