Merge "Camera: Avoid flushing uninitialized devices"
diff --git a/include/media/MediaExtractorPluginHelper.h b/include/media/MediaExtractorPluginHelper.h
index c817b30..a659660 100644
--- a/include/media/MediaExtractorPluginHelper.h
+++ b/include/media/MediaExtractorPluginHelper.h
@@ -129,11 +129,13 @@
mSource = source->mSource;
}
- ssize_t readAt(off64_t offset, void *data, size_t size) {
+ virtual ~DataSourceHelper() {}
+
+ virtual ssize_t readAt(off64_t offset, void *data, size_t size) {
return mSource->readAt(mSource->handle, offset, data, size);
}
- status_t getSize(off64_t *size) {
+ virtual status_t getSize(off64_t *size) {
return mSource->getSize(mSource->handle, size);
}
@@ -141,7 +143,7 @@
return mSource->getUri(mSource->handle, uriString, bufferSize);
}
- uint32_t flags() {
+ virtual uint32_t flags() {
return mSource->flags(mSource->handle);
}
diff --git a/media/extractors/mp4/MPEG4Extractor.cpp b/media/extractors/mp4/MPEG4Extractor.cpp
index f52d451..9d2f5d2 100644
--- a/media/extractors/mp4/MPEG4Extractor.cpp
+++ b/media/extractors/mp4/MPEG4Extractor.cpp
@@ -198,13 +198,14 @@
// possibly wrapping multiple times to cover all tracks, i.e.
// Each CachedRangedDataSource caches the sampletable metadata for a single track.
-struct CachedRangedDataSource : public DataSourceHelper {
+class CachedRangedDataSource : public DataSourceHelper {
+public:
explicit CachedRangedDataSource(DataSourceHelper *source);
virtual ~CachedRangedDataSource();
- virtual ssize_t readAt(off64_t offset, void *data, size_t size);
- virtual status_t getSize(off64_t *size);
- virtual uint32_t flags();
+ ssize_t readAt(off64_t offset, void *data, size_t size) override;
+ status_t getSize(off64_t *size) override;
+ uint32_t flags() override;
status_t setCachedRange(off64_t offset, size_t size, bool assumeSourceOwnershipOnSuccess);
@@ -236,7 +237,7 @@
CachedRangedDataSource::~CachedRangedDataSource() {
clearCache();
if (mOwnsDataSource) {
- delete (CachedRangedDataSource*)mSource;
+ delete mSource;
}
}
@@ -366,7 +367,6 @@
mMoofFound(false),
mMdatFound(false),
mDataSource(source),
- mCachedSource(NULL),
mInitCheck(NO_INIT),
mHeaderTimescale(0),
mIsQT(false),
@@ -393,9 +393,6 @@
}
mPssh.clear();
- if (mCachedSource != mDataSource) {
- delete mCachedSource;
- }
delete mDataSource;
}
@@ -909,8 +906,8 @@
if (cachedSource->setCachedRange(
*offset, chunk_size,
- mCachedSource != NULL /* assume ownership on success */) == OK) {
- mDataSource = mCachedSource = cachedSource;
+ true /* assume ownership on success */) == OK) {
+ mDataSource = cachedSource;
} else {
delete cachedSource;
}
diff --git a/media/extractors/mp4/MPEG4Extractor.h b/media/extractors/mp4/MPEG4Extractor.h
index ca273e0..b1e04c7 100644
--- a/media/extractors/mp4/MPEG4Extractor.h
+++ b/media/extractors/mp4/MPEG4Extractor.h
@@ -33,7 +33,6 @@
struct AMessage;
struct CDataSource;
class DataSourceHelper;
-struct CachedRangedDataSource;
class SampleTable;
class String8;
namespace heif {
@@ -99,7 +98,6 @@
Vector<Trex> mTrex;
DataSourceHelper *mDataSource;
- CachedRangedDataSource *mCachedSource;
status_t mInitCheck;
uint32_t mHeaderTimescale;
bool mIsQT;
diff --git a/media/libheif/include/HeifDecoderAPI.h b/media/libheif/include/HeifDecoderAPI.h
index 5183c39..aa10f33 100644
--- a/media/libheif/include/HeifDecoderAPI.h
+++ b/media/libheif/include/HeifDecoderAPI.h
@@ -74,7 +74,7 @@
int32_t mRotationAngle; // Rotation angle, clockwise, should be multiple of 90
uint32_t mBytesPerPixel; // Number of bytes for one pixel
uint32_t mIccSize; // Number of bytes in mIccData
- std::unique_ptr<uint8_t> mIccData; // Actual ICC data, memory is owned by this structure
+ std::unique_ptr<uint8_t[]> mIccData; // Actual ICC data, memory is owned by this structure
};
/*
diff --git a/media/libstagefright/FrameDecoder.cpp b/media/libstagefright/FrameDecoder.cpp
index c0e65e8..c62c05a 100644
--- a/media/libstagefright/FrameDecoder.cpp
+++ b/media/libstagefright/FrameDecoder.cpp
@@ -501,10 +501,15 @@
return ERROR_MALFORMED;
}
- int32_t width, height, stride;
- CHECK(outputFormat->findInt32("width", &width));
- CHECK(outputFormat->findInt32("height", &height));
- CHECK(outputFormat->findInt32("stride", &stride));
+ int32_t width, height, stride, srcFormat;
+ if (!outputFormat->findInt32("width", &width) ||
+ !outputFormat->findInt32("height", &height) ||
+ !outputFormat->findInt32("stride", &stride) ||
+ !outputFormat->findInt32("color-format", &srcFormat)) {
+ ALOGE("format missing dimension or color: %s",
+ outputFormat->debugString().c_str());
+ return ERROR_MALFORMED;
+ }
int32_t crop_left, crop_top, crop_right, crop_bottom;
if (!outputFormat->findRect("crop", &crop_left, &crop_top, &crop_right, &crop_bottom)) {
@@ -523,9 +528,6 @@
addFrame(frameMem);
VideoFrame* frame = static_cast<VideoFrame*>(frameMem->pointer());
- int32_t srcFormat;
- CHECK(outputFormat->findInt32("color-format", &srcFormat));
-
ColorConverter converter((OMX_COLOR_FORMATTYPE)srcFormat, dstFormat());
uint32_t standard, range, transfer;
diff --git a/media/libstagefright/foundation/AString.cpp b/media/libstagefright/foundation/AString.cpp
index c6ef75f..a8adff5 100644
--- a/media/libstagefright/foundation/AString.cpp
+++ b/media/libstagefright/foundation/AString.cpp
@@ -125,12 +125,10 @@
}
void AString::clear() {
- if (mData && mData != kEmptyString) {
+ if (mData != kEmptyString) {
free(mData);
- mData = NULL;
+ mData = (char *)kEmptyString;
}
-
- mData = (char *)kEmptyString;
mSize = 0;
mAllocSize = 1;
}
diff --git a/media/libstagefright/foundation/include/media/stagefright/foundation/ADebug.h b/media/libstagefright/foundation/include/media/stagefright/foundation/ADebug.h
index bac8fa9..a8b88fd 100644
--- a/media/libstagefright/foundation/include/media/stagefright/foundation/ADebug.h
+++ b/media/libstagefright/foundation/include/media/stagefright/foundation/ADebug.h
@@ -63,38 +63,21 @@
__FILE__ ":" LITERAL_TO_STRING(__LINE__) \
" CHECK(" #condition ") failed.")
-#define MAKE_COMPARATOR(suffix,op) \
- template<class A, class B> \
- AString Compare_##suffix(const A &a, const B &b) { \
- AString res; \
- if (!(a op b)) { \
- res.append(a); \
- res.append(" vs. "); \
- res.append(b); \
- } \
- return res; \
- }
-
-MAKE_COMPARATOR(EQ,==)
-MAKE_COMPARATOR(NE,!=)
-MAKE_COMPARATOR(LE,<=)
-MAKE_COMPARATOR(GE,>=)
-MAKE_COMPARATOR(LT,<)
-MAKE_COMPARATOR(GT,>)
-
#ifdef CHECK_OP
#undef CHECK_OP
#endif
#define CHECK_OP(x,y,suffix,op) \
do { \
- AString ___res = Compare_##suffix(x, y); \
- if (!___res.empty()) { \
+ const auto &a = x; \
+ const auto &b = y; \
+ if (!(a op b)) { \
AString ___full = \
__FILE__ ":" LITERAL_TO_STRING(__LINE__) \
" CHECK_" #suffix "( " #x "," #y ") failed: "; \
- ___full.append(___res); \
- \
+ ___full.append(a); \
+ ___full.append(" vs. "); \
+ ___full.append(b); \
LOG_ALWAYS_FATAL("%s", ___full.c_str()); \
} \
} while (false)