Merge "Allow DAP render-only mix to be matched to mmap-ed stream." into udc-dev
diff --git a/camera/ndk/include/camera/NdkCameraMetadataTags.h b/camera/ndk/include/camera/NdkCameraMetadataTags.h
index 1bd3603..bd679e5 100644
--- a/camera/ndk/include/camera/NdkCameraMetadataTags.h
+++ b/camera/ndk/include/camera/NdkCameraMetadataTags.h
@@ -4487,8 +4487,8 @@
* <p>The guaranteed stream combinations related to stream use case for a camera device with
* <a href="https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE">CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE</a>
* capability is documented in the camera device
- * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession">guideline</a>. The
- * application is strongly recommended to use one of the guaranteed stream combinations.
+ * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#stream-use-case-capability-additional-guaranteed-configurations">guideline</a>. The application is strongly recommended to use one of the guaranteed stream
+ * combinations.
* If the application creates a session with a stream combination not in the guaranteed
* list, or with mixed DEFAULT and non-DEFAULT use cases within the same session,
* the camera device may ignore some stream use cases due to hardware constraints
@@ -9866,9 +9866,10 @@
* </ul>
* <p><a href="https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#SCALER_AVAILABLE_STREAM_USE_CASES">CameraCharacteristics#SCALER_AVAILABLE_STREAM_USE_CASES</a>
* lists all of the supported stream use cases.</p>
- * <p>Refer to <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#createCaptureSession">CameraDevice#createCaptureSession</a> for the
- * mandatory stream combinations involving stream use cases, which can also be queried
- * via <a href="https://developer.android.com/reference/android/hardware/camera2/params/MandatoryStreamCombination.html">MandatoryStreamCombination</a>.</p>
+ * <p>Refer to
+ * <a href="https://developer.android.com/reference/android/hardware/camera2/CameraDevice.html#stream-use-case-capability-additional-guaranteed-configurations">CameraDevice#stream-use-case-capability-additional-guaranteed-configurations</a>
+ * for the mandatory stream combinations involving stream use cases, which can also be
+ * queried via <a href="https://developer.android.com/reference/android/hardware/camera2/params/MandatoryStreamCombination.html">MandatoryStreamCombination</a>.</p>
*/
ACAMERA_REQUEST_AVAILABLE_CAPABILITIES_STREAM_USE_CASE = 19,
@@ -10728,7 +10729,8 @@
* <p>This camera device does not have enough capabilities to qualify as a <code>FULL</code> device or
* better.</p>
* <p>Only the stream configurations listed in the <code>LEGACY</code> and <code>LIMITED</code> tables in the
- * {@link ACameraDevice_createCaptureSession createCaptureSession} documentation are guaranteed to be supported.</p>
+ * {@link ACameraDevice_createCaptureSession }
+ * documentation are guaranteed to be supported.</p>
* <p>All <code>LIMITED</code> devices support the <code>BACKWARDS_COMPATIBLE</code> capability, indicating basic
* support for color image capture. The only exception is that the device may
* alternatively support only the <code>DEPTH_OUTPUT</code> capability, if it can only output depth
@@ -10754,7 +10756,8 @@
/**
* <p>This camera device is capable of supporting advanced imaging applications.</p>
* <p>The stream configurations listed in the <code>FULL</code>, <code>LEGACY</code> and <code>LIMITED</code> tables in the
- * {@link ACameraDevice_createCaptureSession createCaptureSession} documentation are guaranteed to be supported.</p>
+ * {@link ACameraDevice_createCaptureSession }
+ * documentation are guaranteed to be supported.</p>
* <p>A <code>FULL</code> device will support below capabilities:</p>
* <ul>
* <li><code>BURST_CAPTURE</code> capability (ACAMERA_REQUEST_AVAILABLE_CAPABILITIES contains
@@ -10781,7 +10784,9 @@
/**
* <p>This camera device is running in backward compatibility mode.</p>
- * <p>Only the stream configurations listed in the <code>LEGACY</code> table in the {@link ACameraDevice_createCaptureSession createCaptureSession} documentation are supported.</p>
+ * <p>Only the stream configurations listed in the <code>LEGACY</code> table in the
+ * {@link ACameraDevice_createCaptureSession }
+ * documentation are supported.</p>
* <p>A <code>LEGACY</code> device does not support per-frame control, manual sensor control, manual
* post-processing, arbitrary cropping regions, and has relaxed performance constraints.
* No additional capabilities beyond <code>BACKWARD_COMPATIBLE</code> will ever be listed by a
@@ -10803,7 +10808,9 @@
* <p>This camera device is capable of YUV reprocessing and RAW data capture, in addition to
* FULL-level capabilities.</p>
* <p>The stream configurations listed in the <code>LEVEL_3</code>, <code>RAW</code>, <code>FULL</code>, <code>LEGACY</code> and
- * <code>LIMITED</code> tables in the {@link ACameraDevice_createCaptureSession createCaptureSession} documentation are guaranteed to be supported.</p>
+ * <code>LIMITED</code> tables in the
+ * {@link ACameraDevice_createCaptureSession }
+ * documentation are guaranteed to be supported.</p>
* <p>The following additional capabilities are guaranteed to be supported:</p>
* <ul>
* <li><code>YUV_REPROCESSING</code> capability (ACAMERA_REQUEST_AVAILABLE_CAPABILITIES contains
diff --git a/media/codec2/sfplugin/Codec2InfoBuilder.cpp b/media/codec2/sfplugin/Codec2InfoBuilder.cpp
index e18dd59..453a0d2 100644
--- a/media/codec2/sfplugin/Codec2InfoBuilder.cpp
+++ b/media/codec2/sfplugin/Codec2InfoBuilder.cpp
@@ -637,10 +637,6 @@
if (encoder) {
attrs |= MediaCodecInfo::kFlagIsEncoder;
}
- if (codec.quirkSet.find("attribute::enforce-xml-capabilities") !=
- codec.quirkSet.end()) {
- attrs |= MediaCodecInfo::kFlagIsEnforceXmlCapabilities;
- }
if (trait.owner == "software") {
attrs |= MediaCodecInfo::kFlagIsSoftwareOnly;
} else {
diff --git a/media/libmedia/MediaCodecInfo.cpp b/media/libmedia/MediaCodecInfo.cpp
index 3ebd13e..86ad997 100644
--- a/media/libmedia/MediaCodecInfo.cpp
+++ b/media/libmedia/MediaCodecInfo.cpp
@@ -102,111 +102,6 @@
return OK;
}
-static int32_t convertToIntNoSign(const AString &str) {
- char *end;
- unsigned long u = strtoul(str.c_str(), &end, 10);
- if (end == str.c_str() || *end != '\0') {
- // malformed integer
- return -1;
- }
- if (u > INT32_MAX) {
- // The number is too big
- return -1;
- }
- return static_cast<int32_t>(u);
-}
-
-static void parseSize(const AString &str, int32_t *width, int32_t *height) {
- ssize_t ix = str.find("x");
- if (ix == -1) {
- ix = str.find("*");
- if (ix == -1) {
- return;
- }
- }
- AString wStr(str, 0, ix);
- AString hStr(str, ix + 1, str.size() - ix - 1);
- *width = convertToIntNoSign(wStr);
- *height = convertToIntNoSign(hStr);
-}
-
-static void parseRange(const AString &str, int32_t *min, int32_t *max) {
- ssize_t ix = str.find("-");
- if (ix == -1) {
- return;
- }
- AString minStr(str, 0, ix);
- AString maxStr(str, ix + 1, str.size() - ix - 1);
- *min = convertToIntNoSign(minStr);
- *max = convertToIntNoSign(maxStr);
-}
-
-static void parseSizeRange(const AString &str, int32_t *minWidth, int32_t *minHeight,
- int32_t *maxWidth, int32_t *maxHeight) {
- ssize_t ix = str.find("-");
- if (ix == -1) {
- return;
- }
- AString minSize(str, 0, ix);
- AString maxSize(str, ix + 1, str.size() - ix - 1);
- parseSize(minSize, minWidth, minHeight);
- parseSize(maxSize, maxWidth, maxHeight);
-}
-
-
-bool MediaCodecInfo::Capabilities::isResolutionSupported(int32_t width, int32_t height) {
- AString blockSizeStr;
- AString blockCountStr;
- int32_t blockWidth = -1;
- int32_t blockHeight = -1;
- int32_t maxBlocks = -1;
- int32_t minBlocks = -1;
-
- if (mDetails->findString("block-size", &blockSizeStr)) {
- parseSize(blockSizeStr, &blockWidth, &blockHeight);
- }
- if (mDetails->findString("block-count-range", &blockCountStr)) {
- parseRange(blockCountStr, &minBlocks, &maxBlocks);
- }
- if (maxBlocks != -1 && blockWidth != -1 && blockHeight != -1) {
- if (maxBlocks < ((width + blockWidth - 1) / blockWidth) *
- ((height + blockHeight - 1) / blockHeight)) {
- return false;
- }
- }
-
- AString sizeRangeStr;
- int32_t maxWidth = -1;
- int32_t maxHeight = -1;
- int32_t minWidth = -1;
- int32_t minHeight = -1;
-
- if (mDetails->findString("size-range", &sizeRangeStr)) {
- parseSizeRange(sizeRangeStr, &minWidth, &minHeight, &maxWidth, &maxHeight);
- }
-
- if (maxWidth != -1 && maxHeight != -1) {
- // The logic is that the format is not supported if width or height is outside
- // of min-max limits, UNLESS codec allows to swap it and in this case format is
- // not supported if width is outside of min-max height or height is outside of
- // min-max width
- if (width < minWidth || height < minHeight ||
- width > maxWidth || height > maxHeight) {
- int32_t swappable = 0;
- if (!mDetails->findInt32("feature-can-swap-width-height", &swappable) ||
- swappable == 0) {
- return false;
- }
- if (width < minHeight || height < minWidth ||
- width > maxHeight || height > maxWidth) {
- return false;
- }
- }
- }
- return true;
-}
-
-
void MediaCodecInfo::CapabilitiesWriter::addDetail(
const char* key, const char* value) {
mCap->mDetails->setString(key, value);
diff --git a/media/libmedia/include/media/MediaCodecInfo.h b/media/libmedia/include/media/MediaCodecInfo.h
index 855bc28..54f565a 100644
--- a/media/libmedia/include/media/MediaCodecInfo.h
+++ b/media/libmedia/include/media/MediaCodecInfo.h
@@ -59,7 +59,6 @@
kFlagIsVendor = 1 << 1,
kFlagIsSoftwareOnly = 1 << 2,
kFlagIsHardwareAccelerated = 1 << 3,
- kFlagIsEnforceXmlCapabilities = 1 << 4,
};
struct Capabilities : public RefBase {
@@ -97,8 +96,6 @@
*/
const sp<AMessage> getDetails() const;
- bool isResolutionSupported(int32_t width, int32_t height);
-
protected:
Vector<ProfileLevel> mProfileLevels;
SortedVector<ProfileLevel> mProfileLevelsSorted;
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 54ca1ea..e0ebc11 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -2048,40 +2048,6 @@
return configure(format, nativeWindow, crypto, NULL, flags);
}
-bool MediaCodec::isResolutionSupported(const sp<AMessage>& format) {
- int32_t width = -1;
- int32_t height = -1;
- int32_t maxWidth = -1;
- int32_t maxHeight = -1;
- format->findInt32("width", &width);
- format->findInt32("height", &height);
- format->findInt32("max-width", &maxWidth);
- format->findInt32("max-height", &maxHeight);
- AString mediaType;
- if (!format->findString("mime", &mediaType)) {
- ALOGI("Can not check mediaFormat: No MIME set.");
- return true;
- }
- sp<MediaCodecInfo::Capabilities> caps = mCodecInfo->getCapabilitiesFor(mediaType.c_str());
- if (caps == NULL) {
- ALOGI("Can not get Capabilities for MIME %s.", mediaType.c_str());
- return true;
- }
- if (width != -1 && height != -1) {
- if (!caps->isResolutionSupported(width, height)) {
- ALOGD("Frame resolution (%dx%d) is beyond codec capabilities", width, height);
- return false;
- }
- }
- if (maxWidth != -1 && maxHeight != -1) {
- if (!caps->isResolutionSupported(maxWidth, maxHeight)) {
- ALOGD("Max frame resolution (%dx%d) is beyond codec capabilities", maxWidth, maxHeight);
- return false;
- }
- }
- return true;
-}
-
status_t MediaCodec::configure(
const sp<AMessage> &format,
const sp<Surface> &surface,
@@ -2169,24 +2135,7 @@
mediametrics_delete(nextMetricsHandle);
return BAD_VALUE;
}
- // For applications built with targetSdkVersion of Android U or later (or if MediaCodec's
- // caller is not an app) we enforce codec resolution capabilities if such enforcement is
- // required by 'enforce-xml-capabilities' attribute
- if (android_get_application_target_sdk_version() >= __ANDROID_API_U__) {
- if (mCodecInfo != nullptr &&
- (mCodecInfo->getAttributes() &
- MediaCodecInfo::kFlagIsEnforceXmlCapabilities)) {
- if (!isResolutionSupported(format)) {
- mErrorLog.log(LOG_TAG,
- base::StringPrintf("The input resolution of %dx%d is not "
- "supported for this codec; please query MediaCodecList "
- "for the supported formats including the resolution. See "
- "CodecCapabilities#isFormatSupported() and "
- "VideoCapabilities#isSizeSupported()", mWidth, mHeight));
- return BAD_VALUE;
- }
- }
- }
+
} else {
if (nextMetricsHandle != 0) {
int32_t channelCount;
diff --git a/media/libstagefright/include/media/stagefright/MediaCodec.h b/media/libstagefright/include/media/stagefright/MediaCodec.h
index 144ea53..52d7d3d 100644
--- a/media/libstagefright/include/media/stagefright/MediaCodec.h
+++ b/media/libstagefright/include/media/stagefright/MediaCodec.h
@@ -462,7 +462,6 @@
constexpr const char *asString(TunnelPeekState state, const char *default_string="?");
void updateTunnelPeek(const sp<AMessage> &msg);
void processRenderedFrames(const sp<AMessage> &msg);
- bool isResolutionSupported(const sp<AMessage> &format);
inline void initClientConfigParcel(ClientConfigParcel& clientConfig);
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
index 655512b..6b9757d 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp
@@ -183,7 +183,8 @@
for (size_t i = 0; i < size(); i++) {
const sp<AudioPolicyMix>& registeredMix = itemAt(i);
if (mix.mDeviceType == registeredMix->mDeviceType
- && mix.mDeviceAddress.compare(registeredMix->mDeviceAddress) == 0) {
+ && mix.mDeviceAddress.compare(registeredMix->mDeviceAddress) == 0
+ && is_mix_loopback(mix.mRouteFlags)) {
ALOGE("registerMix(): mix already registered for dev=0x%x addr=%s",
mix.mDeviceType, mix.mDeviceAddress.string());
return BAD_VALUE;
diff --git a/services/audiopolicy/tests/audiopolicymanager_tests.cpp b/services/audiopolicy/tests/audiopolicymanager_tests.cpp
index 935667f..5e58dbb 100644
--- a/services/audiopolicy/tests/audiopolicymanager_tests.cpp
+++ b/services/audiopolicy/tests/audiopolicymanager_tests.cpp
@@ -1337,13 +1337,14 @@
AUDIO_DEVICE_OUT_REMOTE_SUBMIX, "", audioConfig);
ASSERT_EQ(INVALID_OPERATION, ret);
- // The first time to register valid policy mixes should succeed.
+ // The first time to register valid loopback policy mix should succeed.
clearPolicyMix();
- ret = addPolicyMix(MIX_TYPE_PLAYERS, MIX_ROUTE_FLAG_RENDER,
- AUDIO_DEVICE_OUT_SPEAKER, "", audioConfig);
+ ret = addPolicyMix(MIX_TYPE_PLAYERS, MIX_ROUTE_FLAG_LOOP_BACK,
+ AUDIO_DEVICE_OUT_REMOTE_SUBMIX, "addr", audioConfig);
ASSERT_EQ(NO_ERROR, ret);
- // Registering the same policy mixes should fail.
- ret = mManager->registerPolicyMixes(mAudioMixes);
+ // Registering the render policy for the loopback address should succeed.
+ ret = addPolicyMix(MIX_TYPE_PLAYERS, MIX_ROUTE_FLAG_RENDER,
+ AUDIO_DEVICE_OUT_REMOTE_SUBMIX, "addr", audioConfig);
ASSERT_EQ(INVALID_OPERATION, ret);
}
diff --git a/services/camera/libcameraservice/api1/Camera2Client.cpp b/services/camera/libcameraservice/api1/Camera2Client.cpp
index 06ef88a..8348cd9 100644
--- a/services/camera/libcameraservice/api1/Camera2Client.cpp
+++ b/services/camera/libcameraservice/api1/Camera2Client.cpp
@@ -80,9 +80,7 @@
SharedParameters::Lock l(mParameters);
l.mParameters.state = Parameters::DISCONNECTED;
- if (forceSlowJpegMode) {
- l.mParameters.isSlowJpegModeForced = true;
- }
+ l.mParameters.isSlowJpegModeForced = forceSlowJpegMode;
}
status_t Camera2Client::initialize(sp<CameraProviderManager> manager, const String8& monitorTags) {
diff --git a/services/camera/libcameraservice/api1/client2/Parameters.cpp b/services/camera/libcameraservice/api1/client2/Parameters.cpp
index 23570c2..13dcbaa 100644
--- a/services/camera/libcameraservice/api1/client2/Parameters.cpp
+++ b/services/camera/libcameraservice/api1/client2/Parameters.cpp
@@ -43,6 +43,7 @@
int cameraFacing) :
cameraId(cameraId),
cameraFacing(cameraFacing),
+ isSlowJpegModeForced(false),
info(NULL),
mDefaultSceneMode(ANDROID_CONTROL_SCENE_MODE_DISABLED) {
}
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index cfe51c7..61c3298 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -1645,6 +1645,10 @@
bool stateSeen = false;
nsecs_t startTime = systemTime();
do {
+ if (mStatus == STATUS_ERROR) {
+ // Device in error state. Return right away.
+ break;
+ }
if (active == (mStatus == STATUS_ACTIVE) &&
(requestThreadInvocation || !mStatusIsInternal)) {
// Desired state is current
@@ -1674,6 +1678,11 @@
// they are not paused. This avoids intermediate pause signals from reconfigureCamera as it
// changes the status to active right after.
for (size_t i = startIndex; i < mRecentStatusUpdates.size(); i++) {
+ if (mRecentStatusUpdates[i].status == STATUS_ERROR) {
+ // Device in error state. Return right away.
+ stateSeen = true;
+ break;
+ }
if (active == (mRecentStatusUpdates[i].status == STATUS_ACTIVE) &&
(requestThreadInvocation || !mRecentStatusUpdates[i].isInternal)) {
stateSeen = true;
@@ -2365,6 +2374,9 @@
//present streams end up with outstanding buffers that will
//not get drained.
internalUpdateStatusLocked(STATUS_ACTIVE);
+
+ mCameraServiceProxyWrapper->logStreamConfigured(mId, mOperatingMode,
+ true /*internalReconfig*/, ns2ms(systemTime() - startTime));
} else if (rc == DEAD_OBJECT) {
// DEAD_OBJECT can be returned if either the consumer surface is
// abandoned, or the HAL has died.
@@ -2380,9 +2392,6 @@
ALOGE("%s: Failed to pause streaming: %d", __FUNCTION__, rc);
}
- mCameraServiceProxyWrapper->logStreamConfigured(mId, mOperatingMode, true /*internalReconfig*/,
- ns2ms(systemTime() - startTime));
-
if (markClientActive) {
mStatusTracker->markComponentActive(clientStatusId);
}
diff --git a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
index 3aff2ac..b58975f 100644
--- a/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
+++ b/services/camera/libcameraservice/utils/CameraServiceProxyWrapper.cpp
@@ -243,12 +243,12 @@
std::shared_ptr<CameraSessionStatsWrapper> sessionStats;
{
Mutex::Autolock l(mLock);
- sessionStats = mSessionStatsMap[id];
- if (sessionStats == nullptr) {
+ if (mSessionStatsMap.count(id) == 0) {
ALOGE("%s: SessionStatsMap should contain camera %s",
__FUNCTION__, id.c_str());
return;
}
+ sessionStats = mSessionStatsMap[id];
}
ALOGV("%s: id %s, operatingMode %d, internalConfig %d, latencyMs %d",
@@ -260,12 +260,12 @@
std::shared_ptr<CameraSessionStatsWrapper> sessionStats;
{
Mutex::Autolock l(mLock);
- sessionStats = mSessionStatsMap[id];
- if (sessionStats == nullptr) {
+ if (mSessionStatsMap.count(id) == 0) {
ALOGE("%s: SessionStatsMap should contain camera %s when logActive is called",
__FUNCTION__, id.c_str());
return;
}
+ sessionStats = mSessionStatsMap[id];
}
ALOGV("%s: id %s", __FUNCTION__, id.c_str());
@@ -280,13 +280,12 @@
std::shared_ptr<CameraSessionStatsWrapper> sessionStats;
{
Mutex::Autolock l(mLock);
- sessionStats = mSessionStatsMap[id];
- }
-
- if (sessionStats == nullptr) {
- ALOGE("%s: SessionStatsMap should contain camera %s when logIdle is called",
+ if (mSessionStatsMap.count(id) == 0) {
+ ALOGE("%s: SessionStatsMap should contain camera %s when logIdle is called",
__FUNCTION__, id.c_str());
- return;
+ return;
+ }
+ sessionStats = mSessionStatsMap[id];
}
ALOGV("%s: id %s, requestCount %" PRId64 ", resultErrorCount %" PRId64 ", deviceError %d"
diff --git a/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp b/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp
index ffd9f01..89e75b3 100644
--- a/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp
+++ b/services/camera/libcameraservice/utils/SessionConfigurationUtils.cpp
@@ -73,11 +73,11 @@
int32_t dynamicDepthKey =
SessionConfigurationUtils::getAppropriateModeTag(
- ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS);
+ ANDROID_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS, maxRes);
int32_t heicKey =
SessionConfigurationUtils::getAppropriateModeTag(
- ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS);
+ ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS, maxRes);
getStreamConfigurations(staticInfo, scalerKey, scm);
getStreamConfigurations(staticInfo, depthKey, scm);