Merge "codec2 hidl plugin: fix FilterWrapper param issues"
diff --git a/media/codec2/TEST_MAPPING b/media/codec2/TEST_MAPPING
index c6728c8..2b96055 100644
--- a/media/codec2/TEST_MAPPING
+++ b/media/codec2/TEST_MAPPING
@@ -37,6 +37,17 @@
]
},
{
+ "name": "CtsMediaEncoderTestCases",
+ "options": [
+ {
+ "include-annotation": "android.platform.test.annotations.Presubmit"
+ },
+ {
+ "exclude-annotation": "android.platform.test.annotations.RequiresDevice"
+ }
+ ]
+ },
+ {
"name": "CtsMediaPlayerTestCases",
"options": [
{
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index 44a2c5b..5389339 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -1213,11 +1213,25 @@
std::initializer_list<C2Param::Index> indices {
colorAspectsRequestIndex.withStream(0u),
};
- c2_status_t c2err = comp->query(
- { &usage, &maxInputSize, &prepend },
- indices,
- C2_DONT_BLOCK,
- ¶ms);
+ int32_t colorTransferRequest = 0;
+ if (config->mDomain & (Config::IS_IMAGE | Config::IS_VIDEO)
+ && !sdkParams->findInt32("color-transfer-request", &colorTransferRequest)) {
+ colorTransferRequest = 0;
+ }
+ c2_status_t c2err = C2_OK;
+ if (colorTransferRequest != 0) {
+ c2err = comp->query(
+ { &usage, &maxInputSize, &prepend },
+ indices,
+ C2_DONT_BLOCK,
+ ¶ms);
+ } else {
+ c2err = comp->query(
+ { &usage, &maxInputSize, &prepend },
+ {},
+ C2_DONT_BLOCK,
+ ¶ms);
+ }
if (c2err != C2_OK && c2err != C2_BAD_INDEX) {
ALOGE("Failed to query component interface: %d", c2err);
return UNKNOWN_ERROR;
@@ -1360,11 +1374,6 @@
colorTransferRequestParam = std::move(param);
}
}
- int32_t colorTransferRequest = 0;
- if (config->mDomain & (Config::IS_IMAGE | Config::IS_VIDEO)
- && !sdkParams->findInt32("color-transfer-request", &colorTransferRequest)) {
- colorTransferRequest = 0;
- }
if (colorTransferRequest != 0) {
if (colorTransferRequestParam && *colorTransferRequestParam) {
diff --git a/media/libaudioclient/AudioTrackShared.cpp b/media/libaudioclient/AudioTrackShared.cpp
index da27dc8..e3b79b2 100644
--- a/media/libaudioclient/AudioTrackShared.cpp
+++ b/media/libaudioclient/AudioTrackShared.cpp
@@ -490,6 +490,8 @@
status_t AudioTrackClientProxy::waitStreamEndDone(const struct timespec *requested)
{
struct timespec total; // total elapsed time spent waiting
+ struct timespec before;
+ bool beforeIsValid = false;
total.tv_sec = 0;
total.tv_nsec = 0;
audio_track_cblk_t* cblk = mCblk;
@@ -570,17 +572,38 @@
}
int32_t old = android_atomic_and(~CBLK_FUTEX_WAKE, &cblk->mFutex);
if (!(old & CBLK_FUTEX_WAKE)) {
+ if (!beforeIsValid) {
+ clock_gettime(CLOCK_MONOTONIC, &before);
+ beforeIsValid = true;
+ }
errno = 0;
(void) syscall(__NR_futex, &cblk->mFutex,
mClientInServer ? FUTEX_WAIT_PRIVATE : FUTEX_WAIT, old & ~CBLK_FUTEX_WAKE, ts);
- switch (errno) {
+ status_t error = errno; // clock_gettime can affect errno
+ {
+ struct timespec after;
+ clock_gettime(CLOCK_MONOTONIC, &after);
+ total.tv_sec += after.tv_sec - before.tv_sec;
+ // Use auto instead of long to avoid the google-runtime-int warning.
+ auto deltaNs = after.tv_nsec - before.tv_nsec;
+ if (deltaNs < 0) {
+ deltaNs += 1000000000;
+ total.tv_sec--;
+ }
+ if ((total.tv_nsec += deltaNs) >= 1000000000) {
+ total.tv_nsec -= 1000000000;
+ total.tv_sec++;
+ }
+ before = after;
+ }
+ switch (error) {
case 0: // normal wakeup by server, or by binderDied()
case EWOULDBLOCK: // benign race condition with server
case EINTR: // wait was interrupted by signal or other spurious wakeup
case ETIMEDOUT: // time-out expired
break;
default:
- status = errno;
+ status = error;
ALOGE("%s unexpected error %s", __func__, strerror(status));
goto end;
}
diff --git a/media/libstagefright/SimpleDecodingSource.cpp b/media/libstagefright/SimpleDecodingSource.cpp
index 771dfea..55aa86b 100644
--- a/media/libstagefright/SimpleDecodingSource.cpp
+++ b/media/libstagefright/SimpleDecodingSource.cpp
@@ -318,18 +318,23 @@
}
size_t cpLen = min(in_buf->range_length(), in_buffer->capacity());
memcpy(in_buffer->base(), (uint8_t *)in_buf->data() + in_buf->range_offset(),
- cpLen );
+ cpLen);
if (mIsVorbis) {
int32_t numPageSamples;
if (!in_buf->meta_data().findInt32(kKeyValidSamples, &numPageSamples)) {
numPageSamples = -1;
}
- memcpy(in_buffer->base() + cpLen, &numPageSamples, sizeof(numPageSamples));
+ if (cpLen + sizeof(numPageSamples) <= in_buffer->capacity()) {
+ memcpy(in_buffer->base() + cpLen, &numPageSamples, sizeof(numPageSamples));
+ cpLen += sizeof(numPageSamples);
+ } else {
+ ALOGW("Didn't have enough space to copy kKeyValidSamples");
+ }
}
res = mCodec->queueInputBuffer(
- in_ix, 0 /* offset */, in_buf->range_length() + (mIsVorbis ? 4 : 0),
+ in_ix, 0 /* offset */, cpLen,
timestampUs, 0 /* flags */);
if (res != OK) {
ALOGI("[%s] failed to queue input buffer #%zu", mComponentName.c_str(), in_ix);
diff --git a/media/libstagefright/TEST_MAPPING b/media/libstagefright/TEST_MAPPING
index 7d4e168..53181cc 100644
--- a/media/libstagefright/TEST_MAPPING
+++ b/media/libstagefright/TEST_MAPPING
@@ -42,6 +42,17 @@
]
},
{
+ "name": "CtsMediaEncoderTestCases",
+ "options": [
+ {
+ "include-annotation": "android.platform.test.annotations.Presubmit"
+ },
+ {
+ "exclude-annotation": "android.platform.test.annotations.RequiresDevice"
+ }
+ ]
+ },
+ {
"name": "CtsMediaPlayerTestCases",
"options": [
{
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index fb043a4..0b6b1fb 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -363,16 +363,18 @@
std::string cameraId(id.c_str());
hardware::camera::common::V1_0::CameraResourceCost cost;
status_t res = mCameraProviderManager->getResourceCost(cameraId, &cost);
- SystemCameraKind deviceKind = SystemCameraKind::PUBLIC;
if (res != OK) {
ALOGE("Failed to query device resource cost: %s (%d)", strerror(-res), res);
return;
}
+ SystemCameraKind deviceKind = SystemCameraKind::PUBLIC;
res = mCameraProviderManager->getSystemCameraKind(cameraId, &deviceKind);
if (res != OK) {
ALOGE("Failed to query device kind: %s (%d)", strerror(-res), res);
return;
}
+ std::vector<std::string> physicalCameraIds;
+ mCameraProviderManager->isLogicalCamera(cameraId, &physicalCameraIds);
std::set<String8> conflicting;
for (size_t i = 0; i < cost.conflictingDevices.size(); i++) {
conflicting.emplace(String8(cost.conflictingDevices[i].c_str()));
@@ -381,7 +383,7 @@
{
Mutex::Autolock lock(mCameraStatesLock);
mCameraStates.emplace(id, std::make_shared<CameraState>(id, cost.resourceCost,
- conflicting, deviceKind));
+ conflicting, deviceKind, physicalCameraIds));
}
if (mFlashlight->hasFlashUnit(id)) {
@@ -3690,9 +3692,10 @@
// ----------------------------------------------------------------------------
CameraService::CameraState::CameraState(const String8& id, int cost,
- const std::set<String8>& conflicting, SystemCameraKind systemCameraKind) : mId(id),
+ const std::set<String8>& conflicting, SystemCameraKind systemCameraKind,
+ const std::vector<std::string>& physicalCameras) : mId(id),
mStatus(StatusInternal::NOT_PRESENT), mCost(cost), mConflicting(conflicting),
- mSystemCameraKind(systemCameraKind) {}
+ mSystemCameraKind(systemCameraKind), mPhysicalCameras(physicalCameras) {}
CameraService::CameraState::~CameraState() {}
@@ -3731,6 +3734,11 @@
return mSystemCameraKind;
}
+bool CameraService::CameraState::containsPhysicalCamera(const std::string& physicalCameraId) const {
+ return std::find(mPhysicalCameras.begin(), mPhysicalCameras.end(), physicalCameraId)
+ != mPhysicalCameras.end();
+}
+
bool CameraService::CameraState::addUnavailablePhysicalId(const String8& physicalId) {
Mutex::Autolock lock(mStatusLock);
auto result = mUnavailablePhysicalIds.insert(physicalId);
@@ -4349,18 +4357,9 @@
std::list<String16> retList;
Mutex::Autolock lock(mCameraStatesLock);
for (const auto& state : mCameraStates) {
- std::vector<std::string> physicalCameraIds;
- if (!mCameraProviderManager->isLogicalCamera(state.first.c_str(), &physicalCameraIds)) {
- // This is not a logical multi-camera.
- continue;
+ if (state.second->containsPhysicalCamera(physicalCameraId.c_str())) {
+ retList.emplace_back(String16(state.first));
}
- if (std::find(physicalCameraIds.begin(), physicalCameraIds.end(), physicalCameraId.c_str())
- == physicalCameraIds.end()) {
- // cameraId is not a physical camera of this logical multi-camera.
- continue;
- }
-
- retList.emplace_back(String16(state.first));
}
return retList;
}
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 69e753b..d5feeeb 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -571,7 +571,7 @@
* returned in the HAL's camera_info struct for each device.
*/
CameraState(const String8& id, int cost, const std::set<String8>& conflicting,
- SystemCameraKind deviceKind);
+ SystemCameraKind deviceKind, const std::vector<std::string>& physicalCameras);
virtual ~CameraState();
/**
@@ -629,6 +629,12 @@
SystemCameraKind getSystemCameraKind() const;
/**
+ * Return whether this camera is a logical multi-camera and has a
+ * particular physical sub-camera.
+ */
+ bool containsPhysicalCamera(const std::string& physicalCameraId) const;
+
+ /**
* Add/Remove the unavailable physical camera ID.
*/
bool addUnavailablePhysicalId(const String8& physicalId);
@@ -649,6 +655,7 @@
mutable Mutex mStatusLock;
CameraParameters mShimParams;
const SystemCameraKind mSystemCameraKind;
+ const std::vector<std::string> mPhysicalCameras; // Empty if not a logical multi-camera
}; // class CameraState
// Observer for UID lifecycle enforcing that UIDs in idle