Merge "codec2 codecs: always specify range of buffers" into sc-dev
diff --git a/media/codec2/components/avc/C2SoftAvcEnc.cpp b/media/codec2/components/avc/C2SoftAvcEnc.cpp
index 0b121ad..d65ffa5 100644
--- a/media/codec2/components/avc/C2SoftAvcEnc.cpp
+++ b/media/codec2/components/avc/C2SoftAvcEnc.cpp
@@ -393,6 +393,61 @@
C2P<C2StreamPictureQuantizationTuning::output> &me) {
(void)mayBlock;
(void)me;
+
+ // TODO: refactor with same algorithm in the SetQp()
+ int32_t iMin = DEFAULT_I_QP_MIN, pMin = DEFAULT_P_QP_MIN, bMin = DEFAULT_B_QP_MIN;
+ int32_t iMax = DEFAULT_I_QP_MAX, pMax = DEFAULT_P_QP_MAX, bMax = DEFAULT_B_QP_MAX;
+
+ for (size_t i = 0; i < me.v.flexCount(); ++i) {
+ const C2PictureQuantizationStruct &layer = me.v.m.values[i];
+
+ if (layer.type_ == C2Config::picture_type_t(I_FRAME)) {
+ iMax = layer.max;
+ iMin = layer.min;
+ ALOGV("iMin %d iMax %d", iMin, iMax);
+ } else if (layer.type_ == C2Config::picture_type_t(P_FRAME)) {
+ pMax = layer.max;
+ pMin = layer.min;
+ ALOGV("pMin %d pMax %d", pMin, pMax);
+ } else if (layer.type_ == C2Config::picture_type_t(B_FRAME)) {
+ bMax = layer.max;
+ bMin = layer.min;
+ ALOGV("bMin %d bMax %d", bMin, bMax);
+ }
+ }
+
+ ALOGV("PictureQuantizationSetter(entry): i %d-%d p %d-%d b %d-%d",
+ iMin, iMax, pMin, pMax, bMin, bMax);
+
+ // ensure we have legal values
+ iMax = std::clamp(iMax, CODEC_QP_MIN, CODEC_QP_MAX);
+ iMin = std::clamp(iMin, CODEC_QP_MIN, CODEC_QP_MAX);
+ pMax = std::clamp(pMax, CODEC_QP_MIN, CODEC_QP_MAX);
+ pMin = std::clamp(pMin, CODEC_QP_MIN, CODEC_QP_MAX);
+ bMax = std::clamp(bMax, CODEC_QP_MIN, CODEC_QP_MAX);
+ bMin = std::clamp(bMin, CODEC_QP_MIN, CODEC_QP_MAX);
+
+ // put them back into the structure
+ for (size_t i = 0; i < me.v.flexCount(); ++i) {
+ const C2PictureQuantizationStruct &layer = me.v.m.values[i];
+
+ if (layer.type_ == C2Config::picture_type_t(I_FRAME)) {
+ me.set().m.values[i].max = iMax;
+ me.set().m.values[i].min = iMin;
+ }
+ if (layer.type_ == C2Config::picture_type_t(P_FRAME)) {
+ me.set().m.values[i].max = pMax;
+ me.set().m.values[i].min = pMin;
+ }
+ if (layer.type_ == C2Config::picture_type_t(B_FRAME)) {
+ me.set().m.values[i].max = bMax;
+ me.set().m.values[i].min = bMin;
+ }
+ }
+
+ ALOGV("PictureQuantizationSetter(exit): i %d-%d p %d-%d b %d-%d",
+ iMin, iMax, pMin, pMax, bMin, bMax);
+
return C2R::Ok();
}
@@ -765,10 +820,11 @@
s_qp_ip.e_cmd = IVE_CMD_VIDEO_CTL;
s_qp_ip.e_sub_cmd = IVE_CMD_CTL_SET_QP;
- // these are the ones we're going to set, so want them to default ....
- // to the DEFAULT values for the codec instea dof CODEC_ bounding
- int32_t iMin = INT32_MIN, pMin = INT32_MIN, bMin = INT32_MIN;
- int32_t iMax = INT32_MAX, pMax = INT32_MAX, bMax = INT32_MAX;
+ // TODO: refactor with same algorithm in the PictureQuantizationSetter()
+ int32_t iMin = DEFAULT_I_QP_MIN, pMin = DEFAULT_P_QP_MIN, bMin = DEFAULT_B_QP_MIN;
+ int32_t iMax = DEFAULT_I_QP_MAX, pMax = DEFAULT_P_QP_MAX, bMax = DEFAULT_B_QP_MAX;
+
+ IntfImpl::Lock lock = mIntf->lock();
std::shared_ptr<C2StreamPictureQuantizationTuning::output> qp =
mIntf->getPictureQuantization_l();
@@ -790,22 +846,6 @@
}
}
- // INT32_{MIN,MAX} means unspecified, so use the codec's default
- if (iMax == INT32_MAX) iMax = DEFAULT_I_QP_MAX;
- if (iMin == INT32_MIN) iMin = DEFAULT_I_QP_MIN;
- if (pMax == INT32_MAX) pMax = DEFAULT_P_QP_MAX;
- if (pMin == INT32_MIN) pMin = DEFAULT_P_QP_MIN;
- if (bMax == INT32_MAX) bMax = DEFAULT_B_QP_MAX;
- if (bMin == INT32_MIN) bMin = DEFAULT_B_QP_MIN;
-
- // ensure we have legal values
- iMax = std::clamp(iMax, CODEC_QP_MIN, CODEC_QP_MAX);
- iMin = std::clamp(iMin, CODEC_QP_MIN, CODEC_QP_MAX);
- pMax = std::clamp(pMax, CODEC_QP_MIN, CODEC_QP_MAX);
- pMin = std::clamp(pMin, CODEC_QP_MIN, CODEC_QP_MAX);
- bMax = std::clamp(bMax, CODEC_QP_MIN, CODEC_QP_MAX);
- bMin = std::clamp(bMin, CODEC_QP_MIN, CODEC_QP_MAX);
-
s_qp_ip.u4_i_qp_max = iMax;
s_qp_ip.u4_i_qp_min = iMin;
s_qp_ip.u4_p_qp_max = pMax;
@@ -818,7 +858,7 @@
s_qp_ip.u4_p_qp = std::clamp(DEFAULT_P_QP, pMin, pMax);
s_qp_ip.u4_b_qp = std::clamp(DEFAULT_B_QP, bMin, bMax);
- ALOGV("setting QP: i %d-%d p %d-%d b %d-%d", iMin, iMax, pMin, pMax, bMin, bMax);
+ ALOGV("setQp(): i %d-%d p %d-%d b %d-%d", iMin, iMax, pMin, pMax, bMin, bMax);
s_qp_ip.u4_timestamp_high = -1;
diff --git a/media/codec2/components/avc/C2SoftAvcEnc.h b/media/codec2/components/avc/C2SoftAvcEnc.h
index baf33e2..1fecd9e 100644
--- a/media/codec2/components/avc/C2SoftAvcEnc.h
+++ b/media/codec2/components/avc/C2SoftAvcEnc.h
@@ -99,8 +99,10 @@
#define STRLENGTH 500
#define DEFAULT_CONSTRAINED_INTRA 0
-/** limits as specified by h264 */
-#define CODEC_QP_MIN 0
+/** limits as specified by h264
+ * (QP_MIN==4 is actually a limitation of this SW codec, not the H.264 standard)
+ **/
+#define CODEC_QP_MIN 4
#define CODEC_QP_MAX 51
diff --git a/media/codec2/core/include/C2Buffer.h b/media/codec2/core/include/C2Buffer.h
index a5d6fbf..abe343b 100644
--- a/media/codec2/core/include/C2Buffer.h
+++ b/media/codec2/core/include/C2Buffer.h
@@ -898,6 +898,12 @@
* Obtains a linear writeable block of given |capacity| and |usage|. If successful, the
* block is stored in |block|. Otherwise, |block| is set to 'nullptr'.
*
+ * \note The returned buffer may have a larger capacity than requested. In this case the
+ * larger (returned) capacity may be fully used.
+ *
+ * \note There is no guarantee on the alignedness of the returned block. The only guarantee is
+ * that its capacity is equal to or larger than the requested capacity.
+ *
* \param capacity the size of requested block.
* \param usage the memory usage info for the requested block. Returned blocks will be
* optimized for this usage, but may be used with any usage. One exception:
@@ -926,6 +932,12 @@
* Obtains a circular writeable block of given |capacity| and |usage|. If successful, the
* block is stored in |block|. Otherwise, |block| is set to 'nullptr'.
*
+ * \note The returned buffer may have a larger capacity than requested. In this case the
+ * larger (returned) capacity may be fully used.
+ *
+ * \note There is no guarantee on the alignedness of the returned block. The only guarantee is
+ * that its capacity is equal to or larger than the requested capacity.
+ *
* \param capacity the size of requested circular block. (note: the size of the obtained
* block could be slightly larger, e.g. to accommodate any system-required
* alignment)
@@ -956,6 +968,12 @@
* Obtains a 2D graphic block of given |width|, |height|, |format| and |usage|. If successful,
* the block is stored in |block|. Otherwise, |block| is set to 'nullptr'.
*
+ * \note The returned buffer may have a larger capacity (width and height) than requested. In
+ * this case the larger (returned) capacity may be fully used.
+ *
+ * \note There is no guarantee on the alignedness of the returned block. The only guarantee is
+ * that its capacity is equal to or larger than the requested capacity (width and height).
+ *
* \param width the width of requested block (the obtained block could be slightly larger, e.g.
* to accommodate any system-required alignment)
* \param height the height of requested block (the obtained block could be slightly larger,
@@ -1000,6 +1018,12 @@
* fence is signalled when the temporary restriction on fetch is lifted.
* e.g. more memory is available to fetch because some meomory or prior blocks were released.
*
+ * \note The returned buffer may have a larger capacity than requested. In this case the
+ * larger (returned) capacity may be fully used.
+ *
+ * \note There is no guarantee on the alignedness of the returned block. The only guarantee is
+ * that its capacity is equal to or larger than the requested capacity.
+ *
* \param capacity the size of requested block.
* \param usage the memory usage info for the requested block. Returned blocks will be
* optimized for this usage, but may be used with any usage. One exception:
@@ -1039,6 +1063,12 @@
* fence is signalled when the temporary restriction on fetch is lifted.
* e.g. more memory is available to fetch because some meomory or prior blocks were released.
*
+ * \note The returned buffer may have a larger capacity (width and height) than requested. In
+ * this case the larger (returned) capacity may be fully used.
+ *
+ * \note There is no guarantee on the alignedness of the returned block. The only guarantee is
+ * that its capacity is equal to or larger than the requested capacity (width and height).
+ *
* \param width the width of requested block (the obtained block could be slightly larger, e.g.
* to accommodate any system-required alignment)
* \param height the height of requested block (the obtained block could be slightly larger,
diff --git a/media/codec2/core/include/C2Config.h b/media/codec2/core/include/C2Config.h
index 7caa457..f5d6529 100644
--- a/media/codec2/core/include/C2Config.h
+++ b/media/codec2/core/include/C2Config.h
@@ -574,7 +574,6 @@
PROFILE_MPEGH_HIGH, ///< MPEG-H High
PROFILE_MPEGH_LC, ///< MPEG-H Low-complexity
PROFILE_MPEGH_BASELINE, ///< MPEG-H Baseline
-
};
enum C2Config::level_t : uint32_t {
diff --git a/media/codec2/hidl/plugin/samples/SampleFilterPlugin.cpp b/media/codec2/hidl/plugin/samples/SampleFilterPlugin.cpp
index 7de3503..b942be7 100644
--- a/media/codec2/hidl/plugin/samples/SampleFilterPlugin.cpp
+++ b/media/codec2/hidl/plugin/samples/SampleFilterPlugin.cpp
@@ -626,6 +626,14 @@
}
LOG(VERBOSE) << "work #" << workCount << ": flags=" << work->input.flags
<< " timestamp=" << work->input.ordinal.timestamp.peek();;
+
+ std::vector<C2Param *> configUpdate;
+ for (const std::unique_ptr<C2Param> ¶m : work->input.configUpdate) {
+ configUpdate.push_back(param.get());
+ }
+ std::vector<std::unique_ptr<C2SettingResult>> failures;
+ mIntf->config_vb(configUpdate, C2_MAY_BLOCK, &failures);
+
std::shared_ptr<C2StreamHdrStaticInfo::input> hdrStaticInfo =
mIntf->getHdrStaticMetadata();
uint32_t dataspace = mIntf->getDataSpace();
diff --git a/media/codec2/vndk/C2AllocatorBlob.cpp b/media/codec2/vndk/C2AllocatorBlob.cpp
index 6340cba..8cfa1d7 100644
--- a/media/codec2/vndk/C2AllocatorBlob.cpp
+++ b/media/codec2/vndk/C2AllocatorBlob.cpp
@@ -178,6 +178,8 @@
return C2_CORRUPTED;
}
+ // Note: the BLOB allocator does not support padding as this functionality is expected
+ // to be provided by the gralloc implementation.
std::shared_ptr<C2GraphicAllocation> graphicAllocation;
c2_status_t status = mC2AllocatorGralloc->newGraphicAllocation(
capacity, kLinearBufferHeight, kLinearBufferFormat, usage, &graphicAllocation);
diff --git a/media/codec2/vndk/C2AllocatorIon.cpp b/media/codec2/vndk/C2AllocatorIon.cpp
index a8528df..77b265a 100644
--- a/media/codec2/vndk/C2AllocatorIon.cpp
+++ b/media/codec2/vndk/C2AllocatorIon.cpp
@@ -417,15 +417,16 @@
buffer = -1;
}
}
- return new Impl(ionFd, allocSize, bufferFd, buffer, id, ret);
-
+ // the padding is not usable so deduct it from the advertised capacity
+ return new Impl(ionFd, allocSize - sPadding, bufferFd, buffer, id, ret);
} else {
ret = ion_alloc_fd(ionFd, allocSize, align, heapMask, flags, &bufferFd);
ALOGV("ion_alloc_fd(ionFd = %d, size = %zu, align = %zu, prot = %d, flags = %d) "
"returned (%d) ; bufferFd = %d",
ionFd, allocSize, align, heapMask, flags, ret, bufferFd);
- return new ImplV2(ionFd, allocSize, bufferFd, id, ret);
+ // the padding is not usable so deduct it from the advertised capacity
+ return new ImplV2(ionFd, allocSize - sPadding, bufferFd, id, ret);
}
}
diff --git a/media/codec2/vndk/C2DmaBufAllocator.cpp b/media/codec2/vndk/C2DmaBufAllocator.cpp
index 6d8552a..1aa3d69 100644
--- a/media/codec2/vndk/C2DmaBufAllocator.cpp
+++ b/media/codec2/vndk/C2DmaBufAllocator.cpp
@@ -111,8 +111,27 @@
virtual bool equals(const std::shared_ptr<C2LinearAllocation>& other) const override;
// internal methods
- C2DmaBufAllocation(BufferAllocator& alloc, size_t size, C2String heap_name, unsigned flags,
- C2Allocator::id_t id);
+
+ /**
+ * Constructs an allocation via a new allocation.
+ *
+ * @param alloc allocator
+ * @param allocSize size used for the allocator
+ * @param capacity capacity advertised to the client
+ * @param heap_name name of the dmabuf heap (device)
+ * @param flags flags
+ * @param id allocator id
+ */
+ C2DmaBufAllocation(BufferAllocator& alloc, size_t allocSize, size_t capacity,
+ C2String heap_name, unsigned flags, C2Allocator::id_t id);
+
+ /**
+ * Constructs an allocation by wrapping an existing allocation.
+ *
+ * @param size capacity advertised to the client
+ * @param shareFd dmabuf fd of the wrapped allocation
+ * @param id allocator id
+ */
C2DmaBufAllocation(size_t size, int shareFd, C2Allocator::id_t id);
c2_status_t status() const;
@@ -246,19 +265,19 @@
}
}
-C2DmaBufAllocation::C2DmaBufAllocation(BufferAllocator& alloc, size_t size, C2String heap_name,
- unsigned flags, C2Allocator::id_t id)
- : C2LinearAllocation(size), mHandle(-1, 0) {
+C2DmaBufAllocation::C2DmaBufAllocation(BufferAllocator& alloc, size_t allocSize, size_t capacity,
+ C2String heap_name, unsigned flags, C2Allocator::id_t id)
+ : C2LinearAllocation(capacity), mHandle(-1, 0) {
int bufferFd = -1;
int ret = 0;
- bufferFd = alloc.Alloc(heap_name, size, flags);
+ bufferFd = alloc.Alloc(heap_name, allocSize, flags);
if (bufferFd < 0) {
ret = bufferFd;
}
// this may be a non-working handle if bufferFd is negative
- mHandle = C2HandleBuf(bufferFd, size);
+ mHandle = C2HandleBuf(bufferFd, capacity);
mId = id;
mInit = c2_status_t(c2_map_errno<ENOMEM, EACCES, EINVAL>(ret));
}
@@ -381,7 +400,7 @@
size_t allocSize = (size_t)capacity + sPadding;
// TODO: should we align allocation size to mBlockSize to reflect the true allocation size?
std::shared_ptr<C2DmaBufAllocation> alloc = std::make_shared<C2DmaBufAllocation>(
- mBufferAllocator, allocSize, heap_name, flags, getId());
+ mBufferAllocator, allocSize, allocSize - sPadding, heap_name, flags, getId());
ret = alloc->status();
if (ret == C2_OK) {
*allocation = alloc;
diff --git a/media/libmediatranscoding/TranscodingThermalPolicy.cpp b/media/libmediatranscoding/TranscodingThermalPolicy.cpp
index 9984abe..88f445c 100644
--- a/media/libmediatranscoding/TranscodingThermalPolicy.cpp
+++ b/media/libmediatranscoding/TranscodingThermalPolicy.cpp
@@ -17,6 +17,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "TranscodingThermalPolicy"
+#include <media/TranscodingDefs.h>
#include <media/TranscodingThermalPolicy.h>
#include <media/TranscodingUidPolicy.h>
#include <utils/Log.h>
diff --git a/media/libmediatranscoding/TranscodingUidPolicy.cpp b/media/libmediatranscoding/TranscodingUidPolicy.cpp
index 0a1ffbc..f33c54c 100644
--- a/media/libmediatranscoding/TranscodingUidPolicy.cpp
+++ b/media/libmediatranscoding/TranscodingUidPolicy.cpp
@@ -21,6 +21,7 @@
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <inttypes.h>
+#include <media/TranscodingDefs.h>
#include <media/TranscodingUidPolicy.h>
#include <utils/Log.h>
diff --git a/media/libmediatranscoding/include/media/TranscodingDefs.h b/media/libmediatranscoding/include/media/TranscodingDefs.h
index 8e02dd2..55e5ad5 100644
--- a/media/libmediatranscoding/include/media/TranscodingDefs.h
+++ b/media/libmediatranscoding/include/media/TranscodingDefs.h
@@ -20,6 +20,9 @@
#include <aidl/android/media/ITranscodingClientCallback.h>
#include <aidl/android/media/TranscodingRequestParcel.h>
+// Transcoding uses some APIs available on API31+.
+#define __TRANSCODING_MIN_API__ 31
+
namespace android {
using ClientIdType = uintptr_t;
diff --git a/media/libmediatranscoding/include/media/TranscodingRequest.h b/media/libmediatranscoding/include/media/TranscodingRequest.h
index d38fc59..b66ccf8 100644
--- a/media/libmediatranscoding/include/media/TranscodingRequest.h
+++ b/media/libmediatranscoding/include/media/TranscodingRequest.h
@@ -24,9 +24,6 @@
using ::aidl::android::media::TranscodingRequestParcel;
-// TODO: replace __ANDROID_API_FUTURE__with 31 when it's official (b/178144708)
-#define __TRANSCODING_MIN_API__ __ANDROID_API_FUTURE__
-
// Helper class for duplicating a TranscodingRequestParcel
class TranscodingRequest : public TranscodingRequestParcel {
public:
diff --git a/media/libmediatranscoding/include/media/TranscodingUidPolicy.h b/media/libmediatranscoding/include/media/TranscodingUidPolicy.h
index dcb22df..4dde5a6 100644
--- a/media/libmediatranscoding/include/media/TranscodingUidPolicy.h
+++ b/media/libmediatranscoding/include/media/TranscodingUidPolicy.h
@@ -28,9 +28,6 @@
#include <unordered_map>
#include <unordered_set>
-// TODO: replace __ANDROID_API_FUTURE__with 31 when it's official (b/178144708)
-#define __TRANSCODING_MIN_API__ __ANDROID_API_FUTURE__
-
struct AActivityManager_UidImportanceListener;
namespace android {
diff --git a/media/libmediatranscoding/transcoder/VideoTrackTranscoder.cpp b/media/libmediatranscoding/transcoder/VideoTrackTranscoder.cpp
index b43efcb..7272a74 100644
--- a/media/libmediatranscoding/transcoder/VideoTrackTranscoder.cpp
+++ b/media/libmediatranscoding/transcoder/VideoTrackTranscoder.cpp
@@ -268,8 +268,7 @@
return AMEDIA_ERROR_INVALID_PARAMETER;
}
-// TODO: replace __ANDROID_API_FUTURE__with 31 when it's official (b/178144708)
-#define __TRANSCODING_MIN_API__ __ANDROID_API_FUTURE__
+#define __TRANSCODING_MIN_API__ 31
AMediaCodec* encoder;
if (__builtin_available(android __TRANSCODING_MIN_API__, *)) {
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index 9665c58..5be8ef5 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -608,6 +608,32 @@
return NULL;
}
+bool MtpDevice::setDevicePropValueStr(MtpProperty* property) {
+ if (property == nullptr)
+ return false;
+
+ std::lock_guard<std::mutex> lg(mMutex);
+
+ if (property->getDataType() != MTP_TYPE_STR) {
+ return false;
+ }
+
+ mRequest.reset();
+ mRequest.setParameter(1, property->getPropertyCode());
+
+ mData.reset();
+ mData.putString(property->getCurrentValue().str);
+
+ if (sendRequest(MTP_OPERATION_SET_DEVICE_PROP_VALUE) && sendData()) {
+ MtpResponseCode ret = readResponse();
+ if (ret != MTP_RESPONSE_OK) {
+ ALOGW("%s: Response=0x%04X\n", __func__, ret);
+ return false;
+ }
+ }
+ return true;
+}
+
MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format) {
std::lock_guard<std::mutex> lg(mMutex);
diff --git a/media/mtp/MtpDevice.h b/media/mtp/MtpDevice.h
index 01bc3db..b1b30e4 100644
--- a/media/mtp/MtpDevice.h
+++ b/media/mtp/MtpDevice.h
@@ -112,6 +112,7 @@
MtpObjectPropertyList* getObjectPropsSupported(MtpObjectFormat format);
MtpProperty* getDevicePropDesc(MtpDeviceProperty code);
+ bool setDevicePropValueStr(MtpProperty* property);
MtpProperty* getObjectPropDesc(MtpObjectProperty code, MtpObjectFormat format);
// Reads value of |property| for |handle|. Returns true on success.
diff --git a/media/mtp/MtpFfsHandle.cpp b/media/mtp/MtpFfsHandle.cpp
index 4d50d66..2ffd775 100644
--- a/media/mtp/MtpFfsHandle.cpp
+++ b/media/mtp/MtpFfsHandle.cpp
@@ -518,7 +518,8 @@
}
}
if (short_packet) {
- if (cancelEvents(mIobuf[i].iocb.data(), ioevs, short_i, mIobuf[i].actual, false)) {
+ if (cancelEvents(mIobuf[i].iocb.data(), ioevs, short_i, mIobuf[i].actual,
+ mBatchCancel)) {
write_error = true;
}
}
diff --git a/media/mtp/MtpPacket.cpp b/media/mtp/MtpPacket.cpp
index 3b298a9..f069a83 100644
--- a/media/mtp/MtpPacket.cpp
+++ b/media/mtp/MtpPacket.cpp
@@ -157,7 +157,7 @@
request->endpoint,
request->buffer,
request->buffer_length,
- 1000);
+ 5000);
request->actual_length = result;
return result;
}
diff --git a/media/mtp/MtpProperty.cpp b/media/mtp/MtpProperty.cpp
index 5c02a0d..98a2ad3 100644
--- a/media/mtp/MtpProperty.cpp
+++ b/media/mtp/MtpProperty.cpp
@@ -240,6 +240,16 @@
mCurrentValue.str = NULL;
}
+void MtpProperty::setCurrentValue(const char* string) {
+ free(mCurrentValue.str);
+ if (string) {
+ MtpStringBuffer buffer(string);
+ mCurrentValue.str = strdup(buffer);
+ }
+ else
+ mCurrentValue.str = NULL;
+}
+
void MtpProperty::setCurrentValue(MtpDataPacket& packet) {
free(mCurrentValue.str);
mCurrentValue.str = NULL;
diff --git a/media/mtp/MtpProperty.h b/media/mtp/MtpProperty.h
index bfd5f7f..36d7360 100644
--- a/media/mtp/MtpProperty.h
+++ b/media/mtp/MtpProperty.h
@@ -91,6 +91,7 @@
void setDefaultValue(const uint16_t* string);
void setCurrentValue(const uint16_t* string);
+ void setCurrentValue(const char* string);
void setCurrentValue(MtpDataPacket& packet);
const MtpPropertyValue& getCurrentValue() { return mCurrentValue; }
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index becbe6e..6fcf119 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -794,18 +794,28 @@
struct stat sstat;
uint64_t finalsize;
bool transcode = android::base::GetBoolProperty("sys.fuse.transcode_mtp", false);
+ bool filePathAccess = true;
ALOGD("Mtp transcode = %d", transcode);
- mfr.fd = mDatabase->openFilePath(filePath, transcode);
- // Doing this here because we want to update fileLength only for this case and leave the
- // regular path as unchanged as possible.
- if (mfr.fd >= 0) {
+
+ // For performance reasons, only attempt a ContentResolver open when transcode is required.
+ // This is fine as long as we don't transcode by default on the device. If we suddenly
+ // transcode by default, we'll need to ensure that MTP doesn't transcode by default and we
+ // might need to make a binder call to avoid transcoding or come up with a better strategy.
+ if (transcode) {
+ mfr.fd = mDatabase->openFilePath(filePath, true);
fstat(mfr.fd, &sstat);
finalsize = sstat.st_size;
fileLength = finalsize;
- } else {
- ALOGW("Mtp open via IMtpDatabase failed for %s. Falling back to the original",
- filePath);
+ if (mfr.fd < 0) {
+ ALOGW("Mtp open via IMtpDatabase failed for %s. Falling back to the original",
+ filePath);
+ filePathAccess = true;
+ } else {
+ filePathAccess = false;
+ }
+ }
+ if (filePathAccess) {
mfr.fd = open(filePath, O_RDONLY);
if (mfr.fd < 0) {
return MTP_RESPONSE_GENERAL_ERROR;
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index d3492d9..b267d88 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -558,7 +558,8 @@
mStatus(NO_INIT),
mMaxDisableWaitCnt(1), // set by configure(), should be >= 1
mDisableWaitCnt(0), // set by process() and updateState()
- mOffloaded(false)
+ mOffloaded(false),
+ mAddedToHal(false)
#ifdef FLOAT_EFFECT_CHAIN
, mSupportsFloat(false)
#endif
@@ -1080,7 +1081,12 @@
{
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
(mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
+ if (mAddedToHal) {
+ return;
+ }
+
(void)getCallback()->addEffectToHal(mEffectInterface);
+ mAddedToHal = true;
}
}
@@ -1176,7 +1182,12 @@
{
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
(mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
+ if (!mAddedToHal) {
+ return NO_ERROR;
+ }
+
getCallback()->removeEffectFromHal(mEffectInterface);
+ mAddedToHal = false;
}
return NO_ERROR;
}
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index 661881e..a727e04 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -286,6 +286,7 @@
// sending disable command.
uint32_t mDisableWaitCnt; // current process() calls count during disable period.
bool mOffloaded; // effect is currently offloaded to the audio DSP
+ bool mAddedToHal; // effect has been added to the audio HAL
#ifdef FLOAT_EFFECT_CHAIN
bool mSupportsFloat; // effect supports float processing
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 1bbc2ba..7045128 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -2652,7 +2652,8 @@
if (OK != res) {
ALOGE("%s: Failed to append dynamic depth tags: %s (%d)", __FUNCTION__,
strerror(-res), res);
- return res;
+ // Allow filtering of small JPEG sizes to succeed even if dynamic depth
+ // tags fail to generate.
}
return OK;
diff --git a/services/mediatranscoding/MediaTranscodingService.cpp b/services/mediatranscoding/MediaTranscodingService.cpp
index 8b64134..e387800 100644
--- a/services/mediatranscoding/MediaTranscodingService.cpp
+++ b/services/mediatranscoding/MediaTranscodingService.cpp
@@ -24,6 +24,7 @@
#include <cutils/properties.h>
#include <media/TranscoderWrapper.h>
#include <media/TranscodingClientManager.h>
+#include <media/TranscodingDefs.h>
#include <media/TranscodingLogger.h>
#include <media/TranscodingResourcePolicy.h>
#include <media/TranscodingSessionController.h>
diff --git a/services/oboeservice/AAudioServiceEndpointMMAP.cpp b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
index 117218a..a08098c 100644
--- a/services/oboeservice/AAudioServiceEndpointMMAP.cpp
+++ b/services/oboeservice/AAudioServiceEndpointMMAP.cpp
@@ -237,6 +237,12 @@
result = AAUDIO_ERROR_INTERNAL;
goto error;
}
+ // Call to HAL to make sure the transport FD was able to be closed by binder.
+ // This is a tricky workaround for a problem in Binder.
+ // TODO:[b/192048842] When that problem is fixed we may be able to remove or change this code.
+ struct audio_mmap_position position;
+ mMmapStream->getMmapPosition(&position);
+
mFramesPerBurst = mMmapBufferinfo.burst_size_frames;
setFormat(config.format);
setSampleRate(config.sample_rate);