Merge "Avoid "android.media.mediacodec.log-session-id" print redundancy" into main
diff --git a/media/codec2/hal/client/GraphicBufferAllocator.cpp b/media/codec2/hal/client/GraphicBufferAllocator.cpp
index bbef1b5..7045537 100644
--- a/media/codec2/hal/client/GraphicBufferAllocator.cpp
+++ b/media/codec2/hal/client/GraphicBufferAllocator.cpp
@@ -62,14 +62,12 @@
return ::ndk::ScopedAStatus::ok();
}
-::ndk::ScopedAStatus GraphicBufferAllocator::getWaitableFds(
- IGraphicBufferAllocator::WaitableFds* _aidl_return) {
- int allocFd;
- int statusFd;
- c2_status_t ret = mGraphicsTracker->getWaitableFds(&allocFd, &statusFd);
+::ndk::ScopedAStatus GraphicBufferAllocator::getWaitableFd(
+ ::ndk::ScopedFileDescriptor* _aidl_return) {
+ int pipeFd;
+ c2_status_t ret = mGraphicsTracker->getWaitableFd(&pipeFd);
if (ret == C2_OK) {
- _aidl_return->allocEvent.set(allocFd);
- _aidl_return->statusEvent.set(statusFd);
+ _aidl_return->set(pipeFd);
return ::ndk::ScopedAStatus::ok();
}
return ::ndk::ScopedAStatus::fromServiceSpecificError(ret);
diff --git a/media/codec2/hal/client/GraphicsTracker.cpp b/media/codec2/hal/client/GraphicsTracker.cpp
index 5a2cb86..2424f7b 100644
--- a/media/codec2/hal/client/GraphicsTracker.cpp
+++ b/media/codec2/hal/client/GraphicsTracker.cpp
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <sys/eventfd.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <media/stagefright/foundation/ADebug.h>
#include <private/android/AHardwareBufferHelpers.h>
@@ -25,6 +26,9 @@
namespace {
+static constexpr int kMaxDequeueMin = 1;
+static constexpr int kMaxDequeueMax = ::android::BufferQueueDefs::NUM_BUFFER_SLOTS - 2;
+
c2_status_t retrieveAHardwareBufferId(const C2ConstGraphicBlock &blk, uint64_t *bid) {
// TODO
(void)blk;
@@ -139,21 +143,26 @@
mDequeueable{maxDequeueCount},
mTotalDequeued{0}, mTotalCancelled{0}, mTotalDropped{0}, mTotalReleased{0},
mInConfig{false}, mStopped{false} {
- if (maxDequeueCount <= 0) {
- mMaxDequeue = kDefaultMaxDequeue;
- mMaxDequeueRequested = kDefaultMaxDequeue;
- mMaxDequeueCommitted = kDefaultMaxDequeue;
- mDequeueable = kDefaultMaxDequeue;
+ if (maxDequeueCount < kMaxDequeueMin) {
+ mMaxDequeue = kMaxDequeueMin;
+ mMaxDequeueRequested = kMaxDequeueMin;
+ mMaxDequeueCommitted = kMaxDequeueMin;
+ mDequeueable = kMaxDequeueMin;
+ } else if(maxDequeueCount > kMaxDequeueMax) {
+ mMaxDequeue = kMaxDequeueMax;
+ mMaxDequeueRequested = kMaxDequeueMax;
+ mMaxDequeueCommitted = kMaxDequeueMax;
+ mDequeueable = kMaxDequeueMax;
}
- int allocEventFd = ::eventfd(mDequeueable, EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE);
- int statusEventFd = ::eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
+ int pipefd[2] = { -1, -1};
+ int ret = ::pipe2(pipefd, O_CLOEXEC | O_NONBLOCK);
- mAllocEventFd.reset(allocEventFd);
- mStopEventFd.reset(statusEventFd);
+ mReadPipeFd.reset(pipefd[0]);
+ mWritePipeFd.reset(pipefd[1]);
mEventQueueThread = std::thread([this](){processEvent();});
- CHECK(allocEventFd >= 0 && statusEventFd >= 0);
+ CHECK(ret >= 0);
CHECK(mEventQueueThread.joinable());
}
@@ -161,7 +170,6 @@
stop();
if (mEventQueueThread.joinable()) {
std::unique_lock<std::mutex> l(mEventLock);
- mStopEventThread = true;
l.unlock();
mEventCv.notify_one();
mEventQueueThread.join();
@@ -231,6 +239,11 @@
c2_status_t GraphicsTracker::configureMaxDequeueCount(int maxDequeueCount) {
std::shared_ptr<BufferCache> cache;
+ if (maxDequeueCount < kMaxDequeueMin || maxDequeueCount > kMaxDequeueMax) {
+ ALOGE("max dequeue count %d is not valid", maxDequeueCount);
+ return C2_BAD_VALUE;
+ }
+
// max dequeue count which can be committed to IGBP.
// (Sometimes maxDequeueCount cannot be committed if the number of
// dequeued buffer count is bigger.)
@@ -347,89 +360,76 @@
void GraphicsTracker::stop() {
bool expected = false;
+ std::unique_lock<std::mutex> l(mEventLock);
bool updated = mStopped.compare_exchange_strong(expected, true);
if (updated) {
- uint64_t val = 1ULL;
- int ret = ::write(mStopEventFd.get(), &val, 8);
- if (ret < 0) {
- // EINTR maybe
- std::unique_lock<std::mutex> l(mEventLock);
- mStopRequest = true;
- l.unlock();
- mEventCv.notify_one();
- ALOGW("stop() status update pending");
- }
+ int writeFd = mWritePipeFd.release();
+ ::close(writeFd);
}
}
void GraphicsTracker::writeIncDequeueable(int inc) {
- uint64_t val = inc;
- int ret = ::write(mAllocEventFd.get(), &val, 8);
- if (ret < 0) {
- // EINTR due to signal handling maybe, this should be rare
+ CHECK(inc > 0 && inc < kMaxDequeueMax);
+ thread_local char buf[kMaxDequeueMax];
+ int diff = 0;
+ {
std::unique_lock<std::mutex> l(mEventLock);
- mIncDequeueable += inc;
- l.unlock();
- mEventCv.notify_one();
- ALOGW("updating dequeueable to eventfd pending");
+ if (mStopped) {
+ return;
+ }
+ CHECK(mWritePipeFd.get() >= 0);
+ int ret = ::write(mWritePipeFd.get(), buf, inc);
+ if (ret == inc) {
+ return;
+ }
+ diff = ret < 0 ? inc : inc - ret;
+
+ // Partial write or EINTR. This will not happen in a real scenario.
+ mIncDequeueable += diff;
+ if (mIncDequeueable > 0) {
+ l.unlock();
+ mEventCv.notify_one();
+ ALOGW("updating dequeueable to pipefd pending");
+ }
}
}
void GraphicsTracker::processEvent() {
- // This is for write() failure of eventfds.
- // write() failure other than EINTR should not happen.
- int64_t acc = 0;
- bool stopRequest = false;
- bool stopCommitted = false;
-
+ // This is for partial/failed writes to the writing end.
+ // This may not happen in the real scenario.
+ thread_local char buf[kMaxDequeueMax];
while (true) {
- {
- std::unique_lock<std::mutex> l(mEventLock);
- acc += mIncDequeueable;
- mIncDequeueable = 0;
- stopRequest |= mStopRequest;
- mStopRequest = false;
- if (acc == 0 && stopRequest == stopCommitted) {
- if (mStopEventThread) {
- break;
+ std::unique_lock<std::mutex> l(mEventLock);
+ if (mStopped) {
+ break;
+ }
+ if (mIncDequeueable > 0) {
+ int inc = mIncDequeueable > kMaxDequeueMax ? kMaxDequeueMax : mIncDequeueable;
+ int ret = ::write(mWritePipeFd.get(), buf, inc);
+ int written = ret <= 0 ? 0 : ret;
+ mIncDequeueable -= written;
+ if (mIncDequeueable > 0) {
+ l.unlock();
+ if (ret < 0) {
+ ALOGE("write to writing end failed %d", errno);
+ } else {
+ ALOGW("partial write %d(%d)", inc, written);
}
- mEventCv.wait(l);
continue;
}
}
-
- if (acc > 0) {
- int ret = ::write(mAllocEventFd.get(), &acc, 8);
- if (ret > 0) {
- acc = 0;
- }
- }
- if (stopRequest && !stopCommitted) {
- uint64_t val = 1ULL;
- int ret = ::write(mStopEventFd.get(), &val, 8);
- if (ret > 0) {
- stopCommitted = true;
- }
- }
- if (mStopEventThread) {
- break;
- }
+ mEventCv.wait(l);
}
}
-c2_status_t GraphicsTracker::getWaitableFds(int *allocFd, int *statusFd) {
- *allocFd = ::dup(mAllocEventFd.get());
- *statusFd = ::dup(mStopEventFd.get());
-
- if (*allocFd < 0 || *statusFd < 0) {
- if (*allocFd >= 0) {
- ::close(*allocFd);
- *allocFd = -1;
+c2_status_t GraphicsTracker::getWaitableFd(int *pipeFd) {
+ *pipeFd = ::dup(mReadPipeFd.get());
+ if (*pipeFd < 0) {
+ if (mReadPipeFd.get() < 0) {
+ return C2_BAD_STATE;
}
- if (*statusFd >= 0) {
- ::close(*statusFd);
- *statusFd = -1;
- }
+ // dup error
+ ALOGE("dup() for the reading end failed %d", errno);
return C2_NO_MEMORY;
}
return C2_OK;
@@ -438,8 +438,8 @@
c2_status_t GraphicsTracker::requestAllocate(std::shared_ptr<BufferCache> *cache) {
std::lock_guard<std::mutex> l(mLock);
if (mDequeueable > 0) {
- uint64_t val;
- int ret = ::read(mAllocEventFd.get(), &val, 8);
+ char buf[1];
+ int ret = ::read(mReadPipeFd.get(), buf, 1);
if (ret < 0) {
if (errno == EINTR) {
// Do we really need to care for cancel due to signal handling?
@@ -452,6 +452,10 @@
}
CHECK(errno != 0);
}
+ if (ret == 0) {
+ // writing end is closed
+ return C2_BAD_STATE;
+ }
mDequeueable--;
*cache = mBufferCache;
return C2_OK;
diff --git a/media/codec2/hal/client/include/codec2/aidl/GraphicBufferAllocator.h b/media/codec2/hal/client/include/codec2/aidl/GraphicBufferAllocator.h
index f9c8aca..902c53f 100644
--- a/media/codec2/hal/client/include/codec2/aidl/GraphicBufferAllocator.h
+++ b/media/codec2/hal/client/include/codec2/aidl/GraphicBufferAllocator.h
@@ -38,8 +38,8 @@
::ndk::ScopedAStatus deallocate(int64_t in_id, bool* _aidl_return) override;
- ::ndk::ScopedAStatus getWaitableFds(
- IGraphicBufferAllocator::WaitableFds* _aidl_return) override;
+ ::ndk::ScopedAStatus getWaitableFd(
+ ::ndk::ScopedFileDescriptor* _aidl_return) override;
/**
* Configuring Surface/BufferQueue for the interface.
diff --git a/media/codec2/hal/client/include/codec2/aidl/GraphicsTracker.h b/media/codec2/hal/client/include/codec2/aidl/GraphicsTracker.h
index 681b7e8..1fd9049 100644
--- a/media/codec2/hal/client/include/codec2/aidl/GraphicsTracker.h
+++ b/media/codec2/hal/client/include/codec2/aidl/GraphicsTracker.h
@@ -142,15 +142,15 @@
void onReleased(uint32_t generation);
/**
- * Get waitable fds for events.(allocate is ready, end of life cycle)
+ * Get waitable fd for events.(allocate is ready, end of life cycle)
*
- * @param[out] allocFd eventFd which signals being ready to allocate
- * @param[out] statusFd eventFd which signals end of life cycle.
- * When signaled no more allocate is possible.
+ * @param[out] pipeFd a file descriptor created from pipe2()
+ * in order for notifying being ready to allocate
+ *
* @return C2_OK
* C2_NO_MEMORY Max # of fd reached.(not really a memory issue)
*/
- c2_status_t getWaitableFds(int *allocFd, int *statusFd);
+ c2_status_t getWaitableFd(int *pipeFd);
/**
* Ends to use the class. after the call, allocate will fail.
@@ -158,8 +158,6 @@
void stop();
private:
- static constexpr int kDefaultMaxDequeue = 2;
-
struct BufferCache;
struct BufferItem {
@@ -246,21 +244,30 @@
std::mutex mLock; // locks for data synchronization
std::mutex mConfigLock; // locks for configuration change.
+ // NOTE: pipe2() creates two file descriptors for allocatable events
+ // and irrecoverable error events notification.
+ //
+ // A byte will be written to the writing end whenever a buffer is ready to
+ // dequeue/allocate. A byte will be read from the reading end whenever
+ // an allocate/dequeue event happens.
+ //
+ // The writing end will be closed when the end-of-lifecycle event was met.
+ //
+ // The reading end will be shared to the remote processes. Remote processes
+ // use ::poll() to check whether a buffer is ready to allocate/ready.
+ // Also ::poll() will let remote processes know the end-of-lifecycle event
+ // by returning POLLHUP event from the reading end.
+ ::android::base::unique_fd mReadPipeFd; // The reading end file descriptor
+ ::android::base::unique_fd mWritePipeFd; // The writing end file descriptor
+
std::atomic<bool> mStopped;
-
- ::android::base::unique_fd mAllocEventFd; // eventfd in semaphore mode which
- // mirrors mDqueueable.
- ::android::base::unique_fd mStopEventFd; // eventfd which indicates the life
- // cycle of the class being stopped.
-
std::thread mEventQueueThread; // Thread to handle interrupted
- // writes to eventfd{s}.
+ // writes to the writing end.
std::mutex mEventLock;
std::condition_variable mEventCv;
bool mStopEventThread;
int mIncDequeueable; // pending # of write to increase dequeueable eventfd
- bool mStopRequest; // pending write to statusfd
private:
explicit GraphicsTracker(int maxDequeueCount);
diff --git a/media/codec2/vndk/C2AllocatorGralloc.cpp b/media/codec2/vndk/C2AllocatorGralloc.cpp
index 0803dc3..e04c637 100644
--- a/media/codec2/vndk/C2AllocatorGralloc.cpp
+++ b/media/codec2/vndk/C2AllocatorGralloc.cpp
@@ -238,6 +238,130 @@
}
};
+class C2HandleAhwb : public C2Handle {
+private:
+ // TODO: remove extradata and use AHardwareBuffer directly.
+ struct ExtraData {
+ uint32_t width;
+ uint32_t height;
+ uint32_t format;
+ uint32_t usage_lo;
+ uint32_t usage_hi;
+ uint32_t stride;
+ uint32_t origId_lo;
+ uint32_t origId_hi;
+ uint32_t magic;
+ };
+
+ enum {
+ NUM_INTS = sizeof(ExtraData) / sizeof(int),
+ };
+ const static uint32_t MAGIC = '\xc2hw\x00';
+
+ static
+ const ExtraData* GetExtraData(const C2Handle *const handle) {
+ if (handle == nullptr
+ || native_handle_is_invalid(handle)
+ || handle->numInts < NUM_INTS) {
+ return nullptr;
+ }
+ return reinterpret_cast<const ExtraData*>(
+ &handle->data[handle->numFds + handle->numInts - NUM_INTS]);
+ }
+
+ static
+ ExtraData *GetExtraData(C2Handle *const handle) {
+ return const_cast<ExtraData *>(GetExtraData(const_cast<const C2Handle *const>(handle)));
+ }
+
+public:
+ void getOrigId(uint64_t *origId) const {
+ const ExtraData *ed = GetExtraData(this);
+ *origId = unsigned(ed->origId_lo) | uint64_t(unsigned(ed->origId_hi)) << 32;
+ }
+
+ static bool IsValid(const C2Handle *const o) {
+ if (o == nullptr) { // null handle is always valid
+ return true;
+ }
+ const ExtraData *xd = GetExtraData(o);
+ // we cannot validate width/height/format/usage without accessing gralloc driver
+ return xd != nullptr && xd->magic == MAGIC;
+ }
+
+ static C2HandleAhwb* WrapAndMoveNativeHandle(
+ const native_handle_t *const handle,
+ uint32_t width, uint32_t height, uint32_t format, uint64_t usage,
+ uint32_t stride, uint64_t origId) {
+ //CHECK(handle != nullptr);
+ if (native_handle_is_invalid(handle) || handle->numInts >
+ int((INT_MAX - handle->version) / sizeof(int)) - NUM_INTS - handle->numFds) {
+ return nullptr;
+ }
+ ExtraData xd = {
+ width, height, format, uint32_t(usage & 0xFFFFFFFF), uint32_t(usage >> 32),
+ stride, uint32_t(origId & 0xFFFFFFFF), uint32_t(origId >> 32), MAGIC
+ };
+ native_handle_t *res = native_handle_create(handle->numFds, handle->numInts + NUM_INTS);
+ if (res != nullptr) {
+ memcpy(&res->data, &handle->data, sizeof(int) * (handle->numFds + handle->numInts));
+ *GetExtraData(res) = xd;
+ }
+ return reinterpret_cast<C2HandleAhwb *>(res);
+ }
+
+ static C2HandleAhwb* WrapNativeHandle(
+ const native_handle_t *const handle,
+ uint32_t width, uint32_t height, uint32_t format, uint64_t usage,
+ uint32_t stride, uint64_t origId) {
+ if (handle == nullptr) {
+ return nullptr;
+ }
+ native_handle_t *clone = native_handle_clone(handle);
+ if (clone == nullptr) {
+ return nullptr;
+ }
+ C2HandleAhwb *res = WrapAndMoveNativeHandle(
+ clone, width, height, format, usage, stride, origId);
+ if (res == nullptr) {
+ native_handle_close(clone);
+ }
+ native_handle_delete(clone);
+ return res;
+ }
+
+ static native_handle_t* UnwrapNativeHandle(
+ const C2Handle *const handle) {
+ const ExtraData *xd = GetExtraData(handle);
+ if (xd == nullptr || xd->magic != MAGIC) {
+ return nullptr;
+ }
+ native_handle_t *res = native_handle_create(handle->numFds, handle->numInts - NUM_INTS);
+ if (res != nullptr) {
+ memcpy(&res->data, &handle->data, sizeof(int) * (res->numFds + res->numInts));
+ }
+ return res;
+ }
+
+ static const C2HandleAhwb* Import(
+ const C2Handle *const handle,
+ uint32_t *width, uint32_t *height, uint32_t *format,
+ uint64_t *usage, uint32_t *stride,
+ uint64_t *origId) {
+ const ExtraData *xd = GetExtraData(handle);
+ if (xd == nullptr) {
+ return nullptr;
+ }
+ *width = xd->width;
+ *height = xd->height;
+ *format = xd->format;
+ *usage = xd->usage_lo | (uint64_t(xd->usage_hi) << 32);
+ *stride = xd->stride;
+ *origId = xd->origId_lo | (uint64_t(xd->origId_hi) << 32);
+ return reinterpret_cast<const C2HandleAhwb *>(handle);
+ }
+};
+
static
c2_status_t Gralloc4Mapper_lock(native_handle_t *handle, uint64_t usage, const Rect& bounds,
C2PlanarLayout *layout, uint8_t **addr) {
@@ -319,172 +443,21 @@
return C2_OK;
}
-} // unnamed namespace
-
-
-native_handle_t *UnwrapNativeCodec2GrallocHandle(const C2Handle *const handle) {
- return C2HandleGralloc::UnwrapNativeHandle(handle);
-}
-
-C2Handle *WrapNativeCodec2GrallocHandle(
- const native_handle_t *const handle,
- uint32_t width, uint32_t height, uint32_t format, uint64_t usage, uint32_t stride,
- uint32_t generation, uint64_t igbp_id, uint32_t igbp_slot) {
- return C2HandleGralloc::WrapNativeHandle(handle, width, height, format, usage, stride,
- generation, igbp_id, igbp_slot);
-}
-
-bool MigrateNativeCodec2GrallocHandle(
- native_handle_t *handle,
- uint32_t generation, uint64_t igbp_id, uint32_t igbp_slot) {
- return C2HandleGralloc::MigrateNativeHandle(handle, generation, igbp_id, igbp_slot);
-}
-
-
-class C2AllocationGralloc : public C2GraphicAllocation {
-public:
- virtual ~C2AllocationGralloc() override;
-
- virtual c2_status_t map(
- C2Rect c2Rect, C2MemoryUsage usage, C2Fence *fence,
- C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) override;
- virtual c2_status_t unmap(
- uint8_t **addr /* nonnull */, C2Rect rect, C2Fence *fence /* nullable */) override;
- virtual C2Allocator::id_t getAllocatorId() const override { return mAllocatorId; }
- virtual const C2Handle *handle() const override { return mLockedHandle ? : mHandle; }
- virtual bool equals(const std::shared_ptr<const C2GraphicAllocation> &other) const override;
-
- // internal methods
- // |handle| will be moved.
-
- C2AllocationGralloc(
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t layerCount,
- uint64_t grallocUsage, uint32_t stride,
- hidl_handle &hidlHandle,
- const C2HandleGralloc *const handle,
- C2Allocator::id_t allocatorId);
- int dup() const;
- c2_status_t status() const;
-
-private:
- const uint32_t mWidth;
- const uint32_t mHeight;
- const uint32_t mFormat;
- const uint32_t mLayerCount;
- const uint64_t mGrallocUsage;
- const uint32_t mStride;
- const hidl_handle mHidlHandle;
- const C2HandleGralloc *mHandle;
- buffer_handle_t mBuffer;
- const C2HandleGralloc *mLockedHandle;
- bool mLocked;
- C2Allocator::id_t mAllocatorId;
- std::mutex mMappedLock;
-};
-
-C2AllocationGralloc::C2AllocationGralloc(
- uint32_t width, uint32_t height,
- uint32_t format, uint32_t layerCount,
- uint64_t grallocUsage, uint32_t stride,
- hidl_handle &hidlHandle,
- const C2HandleGralloc *const handle,
- C2Allocator::id_t allocatorId)
- : C2GraphicAllocation(width, height),
- mWidth(width),
- mHeight(height),
- mFormat(format),
- mLayerCount(layerCount),
- mGrallocUsage(grallocUsage),
- mStride(stride),
- mHidlHandle(std::move(hidlHandle)),
- mHandle(handle),
- mBuffer(nullptr),
- mLockedHandle(nullptr),
- mLocked(false),
- mAllocatorId(allocatorId) {
-}
-
-C2AllocationGralloc::~C2AllocationGralloc() {
- if (mBuffer && mLocked) {
- // implementation ignores addresss and rect
- uint8_t* addr[C2PlanarLayout::MAX_NUM_PLANES] = {};
- unmap(addr, C2Rect(), nullptr);
- }
- if (mBuffer) {
- status_t err = GraphicBufferMapper::get().freeBuffer(mBuffer);
- if (err) {
- ALOGE("failed transaction: freeBuffer");
- }
- }
- if (mHandle) {
- native_handle_delete(
- const_cast<native_handle_t *>(reinterpret_cast<const native_handle_t *>(mHandle)));
- }
- if (mLockedHandle) {
- native_handle_delete(
- const_cast<native_handle_t *>(
- reinterpret_cast<const native_handle_t *>(mLockedHandle)));
- }
-}
-
-c2_status_t C2AllocationGralloc::map(
- C2Rect c2Rect, C2MemoryUsage usage, C2Fence *fence,
+static c2_status_t PopulatePlaneLayout(
+ buffer_handle_t buffer,
+ const Rect &rect,
+ uint32_t format,
+ uint64_t grallocUsage,
+ uint32_t stride,
C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
- const Rect rect{(int32_t)c2Rect.left, (int32_t)c2Rect.top,
- (int32_t)(c2Rect.left + c2Rect.width) /* right */,
- (int32_t)(c2Rect.top + c2Rect.height) /* bottom */};
-
- uint64_t grallocUsage = static_cast<C2AndroidMemoryUsage>(usage).asGrallocUsage();
- ALOGV("mapping buffer with usage %#llx => %#llx",
- (long long)usage.expected, (long long)grallocUsage);
-
- // TODO
- (void)fence;
-
- std::lock_guard<std::mutex> lock(mMappedLock);
- if (mBuffer && mLocked) {
- ALOGD("already mapped");
- return C2_DUPLICATE;
- }
- if (!layout || !addr) {
- ALOGD("wrong param");
- return C2_BAD_VALUE;
- }
-
- if (!mBuffer) {
- status_t err = GraphicBufferMapper::get().importBuffer(
- mHidlHandle.getNativeHandle(), mWidth, mHeight, mLayerCount,
- mFormat, mGrallocUsage, mStride, &mBuffer);
- if (err) {
- ALOGE("failed transaction: importBuffer");
- return C2_CORRUPTED;
- }
- if (mBuffer == nullptr) {
- ALOGD("importBuffer returned null buffer");
- return C2_CORRUPTED;
- }
- uint32_t generation = 0;
- uint64_t igbp_id = 0;
- uint32_t igbp_slot = 0;
- if (mHandle) {
- mHandle->getIgbpData(&generation, &igbp_id, &igbp_slot);
- }
-
- mLockedHandle = C2HandleGralloc::WrapAndMoveNativeHandle(
- mBuffer, mWidth, mHeight, mFormat, mGrallocUsage,
- mStride, generation, igbp_id, igbp_slot);
- }
-
// 'NATIVE' on Android means LITTLE_ENDIAN
constexpr C2PlaneInfo::endianness_t kEndianness = C2PlaneInfo::NATIVE;
// Try to resolve IMPLEMENTATION_DEFINED format to accurate format if
// possible.
- uint32_t format = mFormat;
uint32_t fourCc;
if (format == HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED &&
- !GraphicBufferMapper::get().getPixelFormatFourCC(mBuffer, &fourCc)) {
+ !GraphicBufferMapper::get().getPixelFormatFourCC(buffer, &fourCc)) {
switch (fourCc) {
case DRM_FORMAT_XBGR8888:
format = static_cast<uint32_t>(PixelFormat4::RGBX_8888);
@@ -505,7 +478,7 @@
void *pointer = nullptr;
// TODO: fence
status_t err = GraphicBufferMapper::get().lock(
- const_cast<native_handle_t *>(mBuffer), grallocUsage, rect, &pointer);
+ const_cast<native_handle_t *>(buffer), grallocUsage, rect, &pointer);
if (err) {
ALOGE("failed transaction: lock(RGBA_1010102)");
return C2_CORRUPTED;
@@ -521,7 +494,7 @@
layout->planes[C2PlanarLayout::PLANE_Y] = {
C2PlaneInfo::CHANNEL_Y, // channel
4, // colInc
- static_cast<int32_t>(4 * mStride), // rowInc
+ static_cast<int32_t>(4 * stride), // rowInc
1, // mColSampling
1, // mRowSampling
32, // allocatedDepth
@@ -534,7 +507,7 @@
layout->planes[C2PlanarLayout::PLANE_U] = {
C2PlaneInfo::CHANNEL_CB, // channel
4, // colInc
- static_cast<int32_t>(4 * mStride), // rowInc
+ static_cast<int32_t>(4 * stride), // rowInc
1, // mColSampling
1, // mRowSampling
32, // allocatedDepth
@@ -547,7 +520,7 @@
layout->planes[C2PlanarLayout::PLANE_V] = {
C2PlaneInfo::CHANNEL_CR, // channel
4, // colInc
- static_cast<int32_t>(4 * mStride), // rowInc
+ static_cast<int32_t>(4 * stride), // rowInc
1, // mColSampling
1, // mRowSampling
32, // allocatedDepth
@@ -560,7 +533,7 @@
layout->planes[C2PlanarLayout::PLANE_A] = {
C2PlaneInfo::CHANNEL_A, // channel
4, // colInc
- static_cast<int32_t>(4 * mStride), // rowInc
+ static_cast<int32_t>(4 * stride), // rowInc
1, // mColSampling
1, // mRowSampling
32, // allocatedDepth
@@ -580,7 +553,7 @@
void *pointer = nullptr;
// TODO: fence
status_t err = GraphicBufferMapper::get().lock(
- const_cast<native_handle_t*>(mBuffer), grallocUsage, rect, &pointer);
+ const_cast<native_handle_t*>(buffer), grallocUsage, rect, &pointer);
if (err) {
ALOGE("failed transaction: lock(RGBA_8888)");
return C2_CORRUPTED;
@@ -594,7 +567,7 @@
layout->planes[C2PlanarLayout::PLANE_R] = {
C2PlaneInfo::CHANNEL_R, // channel
4, // colInc
- static_cast<int32_t>(4 * mStride), // rowInc
+ static_cast<int32_t>(4 * stride), // rowInc
1, // mColSampling
1, // mRowSampling
8, // allocatedDepth
@@ -607,7 +580,7 @@
layout->planes[C2PlanarLayout::PLANE_G] = {
C2PlaneInfo::CHANNEL_G, // channel
4, // colInc
- static_cast<int32_t>(4 * mStride), // rowInc
+ static_cast<int32_t>(4 * stride), // rowInc
1, // mColSampling
1, // mRowSampling
8, // allocatedDepth
@@ -620,7 +593,7 @@
layout->planes[C2PlanarLayout::PLANE_B] = {
C2PlaneInfo::CHANNEL_B, // channel
4, // colInc
- static_cast<int32_t>(4 * mStride), // rowInc
+ static_cast<int32_t>(4 * stride), // rowInc
1, // mColSampling
1, // mRowSampling
8, // allocatedDepth
@@ -637,7 +610,7 @@
void *pointer = nullptr;
// TODO: fence
status_t err = GraphicBufferMapper::get().lock(
- const_cast<native_handle_t*>(mBuffer), grallocUsage, rect, &pointer);
+ const_cast<native_handle_t*>(buffer), grallocUsage, rect, &pointer);
if (err) {
ALOGE("failed transaction: lock(BLOB)");
return C2_CORRUPTED;
@@ -658,7 +631,7 @@
android_ycbcr ycbcrLayout;
status_t err = GraphicBufferMapper::get().lockYCbCr(
- const_cast<native_handle_t*>(mBuffer), grallocUsage, rect, &ycbcrLayout);
+ const_cast<native_handle_t*>(buffer), grallocUsage, rect, &ycbcrLayout);
if (err) {
ALOGE("failed transaction: lockYCbCr (err=%d)", err);
return C2_CORRUPTED;
@@ -728,20 +701,20 @@
// In Android T, P010 is relaxed to allow arbitrary stride for the Y and UV planes,
// try locking with the gralloc4 mapper first.
c2_status_t status = Gralloc4Mapper_lock(
- const_cast<native_handle_t*>(mBuffer), grallocUsage, rect, layout, addr);
+ const_cast<native_handle_t*>(buffer), grallocUsage, rect, layout, addr);
if (status == C2_OK) {
break;
}
void *pointer = nullptr;
status_t err = GraphicBufferMapper::get().lock(
- const_cast<native_handle_t *>(mBuffer), grallocUsage, rect, &pointer);
+ const_cast<native_handle_t *>(buffer), grallocUsage, rect, &pointer);
if (err) {
ALOGE("failed transaction: lock(YCBCR_P010)");
return C2_CORRUPTED;
}
addr[C2PlanarLayout::PLANE_Y] = (uint8_t *)pointer;
- addr[C2PlanarLayout::PLANE_U] = (uint8_t *)pointer + mStride * 2 * rect.height();
+ addr[C2PlanarLayout::PLANE_U] = (uint8_t *)pointer + stride * 2 * rect.height();
addr[C2PlanarLayout::PLANE_V] = addr[C2PlanarLayout::PLANE_U] + 2;
layout->type = C2PlanarLayout::TYPE_YUV;
layout->numPlanes = 3;
@@ -749,7 +722,7 @@
layout->planes[C2PlanarLayout::PLANE_Y] = {
C2PlaneInfo::CHANNEL_Y, // channel
2, // colInc
- static_cast<int32_t>(2 * mStride), // rowInc
+ static_cast<int32_t>(2 * stride), // rowInc
1, // mColSampling
1, // mRowSampling
16, // allocatedDepth
@@ -762,7 +735,7 @@
layout->planes[C2PlanarLayout::PLANE_U] = {
C2PlaneInfo::CHANNEL_CB, // channel
4, // colInc
- static_cast<int32_t>(2 * mStride), // rowInc
+ static_cast<int32_t>(2 * stride), // rowInc
2, // mColSampling
2, // mRowSampling
16, // allocatedDepth
@@ -775,7 +748,7 @@
layout->planes[C2PlanarLayout::PLANE_V] = {
C2PlaneInfo::CHANNEL_CR, // channel
4, // colInc
- static_cast<int32_t>(2 * mStride), // rowInc
+ static_cast<int32_t>(2 * stride), // rowInc
2, // mColSampling
2, // mRowSampling
16, // allocatedDepth
@@ -793,7 +766,7 @@
android_ycbcr ycbcrLayout;
if (isAtLeastT()) {
c2_status_t status = Gralloc4Mapper_lock(
- const_cast<native_handle_t*>(mBuffer), grallocUsage, rect, layout, addr);
+ const_cast<native_handle_t*>(buffer), grallocUsage, rect, layout, addr);
if (status == C2_OK) {
break;
}
@@ -801,7 +774,7 @@
// fallback to lockYCbCr
status_t err = GraphicBufferMapper::get().lockYCbCr(
- const_cast<native_handle_t*>(mBuffer), grallocUsage, rect, &ycbcrLayout);
+ const_cast<native_handle_t*>(buffer), grallocUsage, rect, &ycbcrLayout);
if (err == OK && ycbcrLayout.y && ycbcrLayout.cb && ycbcrLayout.cr
&& ycbcrLayout.ystride > 0
&& ycbcrLayout.cstride > 0
@@ -859,7 +832,7 @@
// unlock previous allocation if it was successful
if (err == OK) {
- err = GraphicBufferMapper::get().unlock(mBuffer);
+ err = GraphicBufferMapper::get().unlock(buffer);
if (err) {
ALOGE("failed transaction: unlock");
return C2_CORRUPTED;
@@ -868,9 +841,9 @@
void *pointer = nullptr;
err = GraphicBufferMapper::get().lock(
- const_cast<native_handle_t *>(mBuffer), grallocUsage, rect, &pointer);
+ const_cast<native_handle_t *>(buffer), grallocUsage, rect, &pointer);
if (err) {
- ALOGE("failed transaction: lock(??? %x)", mFormat);
+ ALOGE("failed transaction: lock(??? %x)", format);
return C2_CORRUPTED;
}
addr[0] = (uint8_t *)pointer;
@@ -881,7 +854,7 @@
// TODO: CHANNEL_UNKNOWN?
C2PlaneInfo::channel_t(0xFF), // channel
1, // colInc
- int32_t(mStride), // rowInc
+ int32_t(stride), // rowInc
1, // mColSampling
1, // mRowSampling
8, // allocatedDepth
@@ -894,9 +867,11 @@
break;
}
}
- mLocked = true;
+ return C2_OK;
+}
- // handle interleaved formats
+static void HandleInterleavedPlanes(
+ C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
if (layout->type == C2PlanarLayout::TYPE_YUV && layout->rootPlanes == 3) {
intptr_t uvOffset = addr[C2PlanarLayout::PLANE_V] - addr[C2PlanarLayout::PLANE_U];
intptr_t uvColInc = layout->planes[C2PlanarLayout::PLANE_U].colInc;
@@ -910,6 +885,174 @@
layout->planes[C2PlanarLayout::PLANE_U].offset = -uvOffset;
}
}
+}
+
+} // unnamed namespace
+
+
+native_handle_t *UnwrapNativeCodec2GrallocHandle(const C2Handle *const handle) {
+ return C2HandleGralloc::UnwrapNativeHandle(handle);
+}
+
+C2Handle *WrapNativeCodec2GrallocHandle(
+ const native_handle_t *const handle,
+ uint32_t width, uint32_t height, uint32_t format, uint64_t usage, uint32_t stride,
+ uint32_t generation, uint64_t igbp_id, uint32_t igbp_slot) {
+ return C2HandleGralloc::WrapNativeHandle(handle, width, height, format, usage, stride,
+ generation, igbp_id, igbp_slot);
+}
+
+bool MigrateNativeCodec2GrallocHandle(
+ native_handle_t *handle,
+ uint32_t generation, uint64_t igbp_id, uint32_t igbp_slot) {
+ return C2HandleGralloc::MigrateNativeHandle(handle, generation, igbp_id, igbp_slot);
+}
+
+
+
+class C2AllocationGralloc : public C2GraphicAllocation {
+public:
+ virtual ~C2AllocationGralloc() override;
+
+ virtual c2_status_t map(
+ C2Rect c2Rect, C2MemoryUsage usage, C2Fence *fence,
+ C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) override;
+ virtual c2_status_t unmap(
+ uint8_t **addr /* nonnull */, C2Rect rect, C2Fence *fence /* nullable */) override;
+ virtual C2Allocator::id_t getAllocatorId() const override { return mAllocatorId; }
+ virtual const C2Handle *handle() const override { return mLockedHandle ? : mHandle; }
+ virtual bool equals(const std::shared_ptr<const C2GraphicAllocation> &other) const override;
+
+ // internal methods
+ // |handle| will be moved.
+
+ C2AllocationGralloc(
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t layerCount,
+ uint64_t grallocUsage, uint32_t stride,
+ hidl_handle &hidlHandle,
+ const C2HandleGralloc *const handle,
+ C2Allocator::id_t allocatorId);
+ int dup() const;
+ c2_status_t status() const;
+
+private:
+ const uint32_t mWidth;
+ const uint32_t mHeight;
+ const uint32_t mFormat;
+ const uint32_t mLayerCount;
+ const uint64_t mGrallocUsage;
+ const uint32_t mStride;
+ const hidl_handle mHidlHandle;
+ const C2HandleGralloc *mHandle;
+ buffer_handle_t mBuffer;
+ const C2HandleGralloc *mLockedHandle;
+ bool mLocked;
+ C2Allocator::id_t mAllocatorId;
+ std::mutex mMappedLock;
+};
+
+C2AllocationGralloc::C2AllocationGralloc(
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t layerCount,
+ uint64_t grallocUsage, uint32_t stride,
+ hidl_handle &hidlHandle,
+ const C2HandleGralloc *const handle,
+ C2Allocator::id_t allocatorId)
+ : C2GraphicAllocation(width, height),
+ mWidth(width),
+ mHeight(height),
+ mFormat(format),
+ mLayerCount(layerCount),
+ mGrallocUsage(grallocUsage),
+ mStride(stride),
+ mHidlHandle(std::move(hidlHandle)),
+ mHandle(handle),
+ mBuffer(nullptr),
+ mLockedHandle(nullptr),
+ mLocked(false),
+ mAllocatorId(allocatorId) {
+}
+
+C2AllocationGralloc::~C2AllocationGralloc() {
+ if (mBuffer && mLocked) {
+ // implementation ignores address and rect
+ uint8_t* addr[C2PlanarLayout::MAX_NUM_PLANES] = {};
+ unmap(addr, C2Rect(), nullptr);
+ }
+ if (mBuffer) {
+ status_t err = GraphicBufferMapper::get().freeBuffer(mBuffer);
+ if (err) {
+ ALOGE("failed transaction: freeBuffer");
+ }
+ }
+ if (mHandle) {
+ native_handle_delete(
+ const_cast<native_handle_t *>(reinterpret_cast<const native_handle_t *>(mHandle)));
+ }
+ if (mLockedHandle) {
+ native_handle_delete(
+ const_cast<native_handle_t *>(
+ reinterpret_cast<const native_handle_t *>(mLockedHandle)));
+ }
+}
+
+c2_status_t C2AllocationGralloc::map(
+ C2Rect c2Rect, C2MemoryUsage usage, C2Fence *fence,
+ C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
+ const Rect rect{(int32_t)c2Rect.left, (int32_t)c2Rect.top,
+ (int32_t)(c2Rect.left + c2Rect.width) /* right */,
+ (int32_t)(c2Rect.top + c2Rect.height) /* bottom */};
+
+ uint64_t grallocUsage = static_cast<C2AndroidMemoryUsage>(usage).asGrallocUsage();
+ ALOGV("mapping buffer with usage %#llx => %#llx",
+ (long long)usage.expected, (long long)grallocUsage);
+
+ // TODO
+ (void)fence;
+
+ std::lock_guard<std::mutex> lock(mMappedLock);
+ if (mBuffer && mLocked) {
+ ALOGD("already mapped");
+ return C2_DUPLICATE;
+ }
+ if (!layout || !addr) {
+ ALOGD("wrong param");
+ return C2_BAD_VALUE;
+ }
+
+ if (!mBuffer) {
+ status_t err = GraphicBufferMapper::get().importBuffer(
+ mHidlHandle.getNativeHandle(), mWidth, mHeight, mLayerCount,
+ mFormat, mGrallocUsage, mStride, &mBuffer);
+ if (err) {
+ ALOGE("failed transaction: importBuffer");
+ return C2_CORRUPTED;
+ }
+ if (mBuffer == nullptr) {
+ ALOGD("importBuffer returned null buffer");
+ return C2_CORRUPTED;
+ }
+ uint32_t generation = 0;
+ uint64_t igbp_id = 0;
+ uint32_t igbp_slot = 0;
+ if (mHandle) {
+ mHandle->getIgbpData(&generation, &igbp_id, &igbp_slot);
+ }
+
+ mLockedHandle = C2HandleGralloc::WrapAndMoveNativeHandle(
+ mBuffer, mWidth, mHeight, mFormat, mGrallocUsage,
+ mStride, generation, igbp_id, igbp_slot);
+ }
+
+ c2_status_t ret = PopulatePlaneLayout(
+ mBuffer, rect, mFormat, grallocUsage, mStride, layout, addr);
+ if (ret != C2_OK) {
+ return ret;
+ }
+ mLocked = true;
+
+ HandleInterleavedPlanes(layout, addr);
ALOGV("C2AllocationGralloc::map: layout: type=%d numPlanes=%d rootPlanes=%d",
layout->type, layout->numPlanes, layout->rootPlanes);
@@ -1094,4 +1237,321 @@
return C2HandleGralloc::IsValid(o);
}
+
+native_handle_t *UnwrapNativeCodec2AhwbHandle(const C2Handle *const handle) {
+ return C2HandleAhwb::UnwrapNativeHandle(handle);
+}
+
+C2Handle *WrapNativeCodec2AhwbHandle(
+ const native_handle_t *const handle,
+ uint32_t width, uint32_t height, uint32_t format, uint64_t usage, uint32_t stride,
+ uint64_t origId) {
+ return C2HandleAhwb::WrapNativeHandle(handle, width, height, format, usage, stride,
+ origId);
+}
+
+class C2AllocationAhwb : public C2GraphicAllocation {
+public:
+ virtual ~C2AllocationAhwb() override;
+
+ virtual c2_status_t map(
+ C2Rect c2Rect, C2MemoryUsage usage, C2Fence *fence,
+ C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) override;
+ virtual c2_status_t unmap(
+ uint8_t **addr /* nonnull */, C2Rect rect, C2Fence *fence /* nullable */) override;
+ virtual C2Allocator::id_t getAllocatorId() const override { return mAllocatorId; }
+ virtual const C2Handle *handle() const override { return mLockedHandle ? : mHandle; }
+ virtual bool equals(const std::shared_ptr<const C2GraphicAllocation> &other) const override;
+
+ // internal methods
+ // |handle| will be moved.
+
+ C2AllocationAhwb(
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t layerCount,
+ uint64_t grallocUsage, uint32_t stride,
+ const C2HandleAhwb *const handle,
+ C2Allocator::id_t allocatorId);
+ int dup() const;
+ c2_status_t status() const;
+
+private:
+ const uint32_t mWidth;
+ const uint32_t mHeight;
+ const uint32_t mFormat;
+ const uint32_t mLayerCount;
+ const uint64_t mGrallocUsage;
+ const uint32_t mStride;
+ const native_handle_t *mRawHandle;
+ const C2HandleAhwb *mHandle;
+ buffer_handle_t mBuffer;
+ const C2HandleAhwb *mLockedHandle;
+ bool mLocked;
+ C2Allocator::id_t mAllocatorId;
+ std::mutex mMappedLock;
+};
+
+C2AllocationAhwb::C2AllocationAhwb(
+ uint32_t width, uint32_t height,
+ uint32_t format, uint32_t layerCount,
+ uint64_t grallocUsage, uint32_t stride,
+ const C2HandleAhwb *const handle,
+ C2Allocator::id_t allocatorId)
+ : C2GraphicAllocation(width, height),
+ mWidth(width),
+ mHeight(height),
+ mFormat(format),
+ mLayerCount(layerCount),
+ mGrallocUsage(grallocUsage),
+ mStride(stride),
+ mRawHandle(C2HandleAhwb::UnwrapNativeHandle(handle)),
+ mHandle(handle),
+ mBuffer(nullptr),
+ mLockedHandle(nullptr),
+ mLocked(false),
+ mAllocatorId(allocatorId) {
+}
+
+C2AllocationAhwb::~C2AllocationAhwb() {
+ if (mBuffer && mLocked) {
+ // implementation ignores address and rect
+ uint8_t* addr[C2PlanarLayout::MAX_NUM_PLANES] = {};
+ unmap(addr, C2Rect(), nullptr);
+ }
+ if (mBuffer) {
+ status_t err = GraphicBufferMapper::get().freeBuffer(mBuffer);
+ if (err) {
+ ALOGE("failed transaction: freeBuffer");
+ }
+ }
+ if (mRawHandle) {
+ native_handle_close(
+ const_cast<native_handle_t *>(
+ reinterpret_cast<const native_handle_t *>(mRawHandle)));
+ native_handle_delete(
+ const_cast<native_handle_t *>(
+ reinterpret_cast<const native_handle_t *>(mRawHandle)));
+ }
+ if (mHandle) {
+ native_handle_delete(
+ const_cast<native_handle_t *>(reinterpret_cast<const native_handle_t *>(mHandle)));
+ }
+ if (mLockedHandle) {
+ native_handle_delete(
+ const_cast<native_handle_t *>(
+ reinterpret_cast<const native_handle_t *>(mLockedHandle)));
+ }
+}
+
+c2_status_t C2AllocationAhwb::map(
+ C2Rect c2Rect, C2MemoryUsage usage, C2Fence *fence,
+ C2PlanarLayout *layout /* nonnull */, uint8_t **addr /* nonnull */) {
+ const Rect rect{(int32_t)c2Rect.left, (int32_t)c2Rect.top,
+ (int32_t)(c2Rect.left + c2Rect.width) /* right */,
+ (int32_t)(c2Rect.top + c2Rect.height) /* bottom */};
+
+ uint64_t grallocUsage = static_cast<C2AndroidMemoryUsage>(usage).asGrallocUsage();
+ ALOGV("mapping buffer with usage %#llx => %#llx",
+ (long long)usage.expected, (long long)grallocUsage);
+
+ // TODO
+ (void)fence;
+
+ std::lock_guard<std::mutex> lock(mMappedLock);
+ if (mBuffer && mLocked) {
+ ALOGD("already mapped");
+ return C2_DUPLICATE;
+ }
+ if (!layout || !addr) {
+ ALOGD("wrong param");
+ return C2_BAD_VALUE;
+ }
+
+ if (!mBuffer) {
+ // TODO: libui/libgui dependency removal (b/214400477)
+ status_t err = GraphicBufferMapper::get().importBuffer(
+ mRawHandle, mWidth, mHeight, mLayerCount,
+ mFormat, mGrallocUsage, mStride, &mBuffer);
+ if (err) {
+ ALOGE("failed transaction: importBuffer");
+ return C2_CORRUPTED;
+ }
+ if (mBuffer == nullptr) {
+ ALOGD("importBuffer returned null buffer");
+ return C2_CORRUPTED;
+ }
+ uint64_t origId = 0;
+ if (mHandle) {
+ mHandle->getOrigId(&origId);
+ }
+
+ mLockedHandle = C2HandleAhwb::WrapAndMoveNativeHandle(
+ mBuffer, mWidth, mHeight, mFormat, mGrallocUsage,
+ mStride, origId);
+ }
+
+ c2_status_t ret = PopulatePlaneLayout(
+ mBuffer, rect, mFormat, grallocUsage, mStride, layout, addr);
+ if (ret != C2_OK) {
+ return ret;
+ }
+ mLocked = true;
+
+ HandleInterleavedPlanes(layout, addr);
+
+ ALOGV("C2AllocationGralloc::map: layout: type=%d numPlanes=%d rootPlanes=%d",
+ layout->type, layout->numPlanes, layout->rootPlanes);
+ for (int i = 0; i < layout->numPlanes; ++i) {
+ const C2PlaneInfo &plane = layout->planes[i];
+ ALOGV("C2AllocationGralloc::map: plane[%d]: colInc=%d rowInc=%d rootIx=%u offset=%u",
+ i, plane.colInc, plane.rowInc, plane.rootIx, plane.offset);
+ }
+
+ return C2_OK;
+}
+
+c2_status_t C2AllocationAhwb::unmap(
+ uint8_t **addr, C2Rect rect, C2Fence *fence /* nullable */) {
+ // TODO: check addr and size, use fence
+ (void)addr;
+ (void)rect;
+ (void)fence;
+
+ std::lock_guard<std::mutex> lock(mMappedLock);
+ // TODO: fence
+ status_t err = GraphicBufferMapper::get().unlock(mBuffer);
+ if (err) {
+ ALOGE("failed transaction: unlock");
+ return C2_CORRUPTED;
+ }
+
+ mLocked = false;
+ return C2_OK;
+}
+
+bool C2AllocationAhwb::equals(const std::shared_ptr<const C2GraphicAllocation> &other) const {
+ return other && other->handle() == handle();
+}
+
+/* ===================================== AHARDWAREBUFFER ALLOCATOR ============================= */
+class C2AllocatorAhwb::Impl {
+public:
+ Impl(id_t id);
+
+ id_t getId() const {
+ return mTraits->id;
+ }
+
+ C2String getName() const {
+ return mTraits->name;
+ }
+
+ std::shared_ptr<const C2Allocator::Traits> getTraits() const {
+ return mTraits;
+ }
+
+ c2_status_t newGraphicAllocation(
+ uint32_t width, uint32_t height, uint32_t format, const C2MemoryUsage &usage,
+ std::shared_ptr<C2GraphicAllocation> *allocation);
+
+ c2_status_t priorGraphicAllocation(
+ const C2Handle *handle,
+ std::shared_ptr<C2GraphicAllocation> *allocation);
+
+ c2_status_t status() const { return mInit; }
+
+private:
+ std::shared_ptr<C2Allocator::Traits> mTraits;
+ c2_status_t mInit;
+};
+
+void _UnwrapNativeCodec2AhwbMetadata(
+ const C2Handle *const handle,
+ uint32_t *width, uint32_t *height, uint32_t *format,uint64_t *usage, uint32_t *stride,
+ uint64_t *origId) {
+ (void)C2HandleAhwb::Import(handle, width, height, format, usage, stride, origId);
+}
+
+C2AllocatorAhwb::Impl::Impl(id_t id)
+ : mInit(C2_OK) {
+ // TODO: get this from allocator
+ C2MemoryUsage minUsage = { 0, 0 }, maxUsage = { ~(uint64_t)0, ~(uint64_t)0 };
+ Traits traits = { "android.allocator.ahwb", id, C2Allocator::GRAPHIC, minUsage, maxUsage };
+ mTraits = std::make_shared<C2Allocator::Traits>(traits);
+}
+
+c2_status_t C2AllocatorAhwb::Impl::newGraphicAllocation(
+ uint32_t width, uint32_t height, uint32_t format, const C2MemoryUsage &usage,
+ std::shared_ptr<C2GraphicAllocation> *allocation) {
+ // TODO: for client side usage
+ // HAL side Ahwb allocation should be done via IGBA currently.
+ (void) width;
+ (void) height;
+ (void) format;
+ (void) usage;
+ (void) allocation;
+ return C2_OMITTED;
+}
+
+c2_status_t C2AllocatorAhwb::Impl::priorGraphicAllocation(
+ const C2Handle *handle,
+ std::shared_ptr<C2GraphicAllocation> *allocation) {
+
+ uint32_t width;
+ uint32_t height;
+ uint32_t format;
+ uint32_t layerCount = 1;
+ uint64_t grallocUsage;
+ uint32_t stride;
+ uint64_t origId;
+
+ const C2HandleAhwb *ahwbHandle = C2HandleAhwb::Import(
+ handle, &width, &height, &format, &grallocUsage, &stride, &origId);
+ if (ahwbHandle == nullptr) {
+ return C2_BAD_VALUE;
+ }
+
+ allocation->reset(new C2AllocationAhwb(
+ width, height, format, layerCount,
+ grallocUsage, stride, ahwbHandle, mTraits->id));
+ return C2_OK;
+}
+
+C2AllocatorAhwb::C2AllocatorAhwb(id_t id)
+ : mImpl(new Impl(id)) {}
+
+C2AllocatorAhwb::~C2AllocatorAhwb() { delete mImpl; }
+
+C2Allocator::id_t C2AllocatorAhwb::getId() const {
+ return mImpl->getId();
+}
+
+C2String C2AllocatorAhwb::getName() const {
+ return mImpl->getName();
+}
+
+std::shared_ptr<const C2Allocator::Traits> C2AllocatorAhwb::getTraits() const {
+ return mImpl->getTraits();
+}
+
+c2_status_t C2AllocatorAhwb::newGraphicAllocation(
+ uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
+ std::shared_ptr<C2GraphicAllocation> *allocation) {
+ return mImpl->newGraphicAllocation(width, height, format, usage, allocation);
+}
+
+c2_status_t C2AllocatorAhwb::priorGraphicAllocation(
+ const C2Handle *handle,
+ std::shared_ptr<C2GraphicAllocation> *allocation) {
+ return mImpl->priorGraphicAllocation(handle, allocation);
+}
+
+c2_status_t C2AllocatorAhwb::status() const {
+ return mImpl->status();
+}
+
+// static
+bool C2AllocatorAhwb::CheckHandle(const C2Handle* const o) {
+ return C2HandleAhwb::IsValid(o);
+}
} // namespace android
diff --git a/media/codec2/vndk/C2Fence.cpp b/media/codec2/vndk/C2Fence.cpp
index 0344fd3..b91ac6d 100644
--- a/media/codec2/vndk/C2Fence.cpp
+++ b/media/codec2/vndk/C2Fence.cpp
@@ -16,6 +16,9 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "C2FenceFactory"
+#include <poll.h>
+
+#include <android-base/unique_fd.h>
#include <cutils/native_handle.h>
#include <utils/Log.h>
#include <ui/Fence.h>
@@ -32,6 +35,7 @@
NULL_FENCE,
SURFACE_FENCE,
SYNC_FENCE,
+ PIPE_FENCE,
};
virtual c2_status_t wait(c2_nsecs_t timeoutNs) = 0;
@@ -353,6 +357,154 @@
return C2Fence(p);
}
+/**
+ * Fence implementation for notifying # of events available based on
+ * file descriptors created by pipe()/pipe2(). The writing end of the
+ * file descriptors is used to create the implementation.
+ * The implementation supports all C2Fence interface.
+ */
+class _C2FenceFactory::PipeFenceImpl: public C2Fence::Impl {
+private:
+ bool waitEvent(c2_nsecs_t timeoutNs, bool *hangUp, bool *event) const {
+ if (!mValid) {
+ *hangUp = true;
+ return true;
+ }
+
+ struct pollfd pfd;
+ pfd.fd = mPipeFd.get();
+ pfd.events = POLLIN;
+ pfd.revents = 0;
+ struct timespec ts;
+ if (timeoutNs >= 0) {
+ ts.tv_sec = int(timeoutNs / 1000000000);
+ ts.tv_nsec = timeoutNs;
+ } else {
+ ALOGD("polling for indefinite duration requested, but changed to wait for %d sec",
+ kPipeFenceWaitLimitSecs);
+ ts.tv_sec = kPipeFenceWaitLimitSecs;
+ ts.tv_nsec = 0;
+ }
+ int ret = ::ppoll(&pfd, 1, &ts, nullptr);
+ if (ret >= 0) {
+ if (pfd.revents) {
+ if (pfd.revents & ~POLLIN) {
+ // Mostly this means the writing end fd was closed.
+ *hangUp = true;
+ mValid = false;
+ ALOGD("PipeFenceImpl: pipe fd hangup or err event returned");
+ }
+ *event = true;
+ return true;
+ }
+ // event not ready yet.
+ return true;
+ }
+ if (errno == EINTR) {
+ // poll() was cancelled by signal or inner kernel status.
+ return false;
+ }
+ // Since poll error happened here, treat the error is irrecoverable.
+ ALOGE("PipeFenceImpl: poll() error %d", errno);
+ *hangUp = true;
+ mValid = false;
+ return true;
+ }
+
+public:
+ virtual c2_status_t wait(c2_nsecs_t timeoutNs) {
+ if (!mValid) {
+ return C2_BAD_STATE;
+ }
+ bool hangUp = false;
+ bool event = false;
+ if (waitEvent(timeoutNs, &hangUp, &event)) {
+ if (hangUp) {
+ return C2_BAD_STATE;
+ }
+ if (event) {
+ return C2_OK;
+ }
+ return C2_TIMED_OUT;
+ } else {
+ return C2_CANCELED;
+ }
+ }
+
+ virtual bool valid() const {
+ if (!mValid) {
+ return false;
+ }
+ bool hangUp = false;
+ bool event = false;
+ if (waitEvent(0, &hangUp, &event)) {
+ if (hangUp) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ virtual bool ready() const {
+ if (!mValid) {
+ return false;
+ }
+ bool hangUp = false;
+ bool event = false;
+ if (waitEvent(0, &hangUp, &event)) {
+ if (event) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ virtual int fd() const {
+ if (!mValid) {
+ return -1;
+ }
+ return ::dup(mPipeFd.get());
+ }
+
+ virtual bool isHW() const {
+ return false;
+ }
+
+ virtual type_t type() const {
+ return PIPE_FENCE;
+ }
+
+ virtual native_handle_t *createNativeHandle() const {
+ // This is not supported.
+ return nullptr;
+ }
+
+ virtual ~PipeFenceImpl() = default;
+
+ PipeFenceImpl(int fd) : mPipeFd(fd) {
+ mValid = (mPipeFd.get() >= 0);
+ }
+
+private:
+ friend struct _C2FenceFactory;
+ static constexpr int kPipeFenceWaitLimitSecs = 5;
+
+ mutable std::atomic<bool> mValid;
+ ::android::base::unique_fd mPipeFd;
+};
+
+C2Fence _C2FenceFactory::CreatePipeFence(int fd) {
+ std::shared_ptr<_C2FenceFactory::PipeFenceImpl> impl =
+ std::make_shared<_C2FenceFactory::PipeFenceImpl>(fd);
+ std::shared_ptr<C2Fence::Impl> p = std::static_pointer_cast<C2Fence::Impl>(impl);
+ if (!p) {
+ ALOGE("PipeFence creation failure");
+ } else if (!impl->mValid) {
+ p.reset();
+ }
+ return C2Fence(p);
+}
+
native_handle_t* _C2FenceFactory::CreateNativeHandle(const C2Fence& fence) {
return fence.mImpl? fence.mImpl->createNativeHandle() : nullptr;
}
diff --git a/media/codec2/vndk/include/C2AllocatorGralloc.h b/media/codec2/vndk/include/C2AllocatorGralloc.h
index 1da3e14..dfcdb8b 100644
--- a/media/codec2/vndk/include/C2AllocatorGralloc.h
+++ b/media/codec2/vndk/include/C2AllocatorGralloc.h
@@ -63,6 +63,36 @@
uint32_t *width, uint32_t *height, uint32_t *format, uint64_t *usage, uint32_t *stride,
uint32_t *generation, uint64_t *igbp_id, uint32_t *igbp_slot);
+/**
+ * Unwrap the native handle from a Codec2 handle allocated by C2AllocatorAhwb.
+ *
+ * @param handle a handle allocated by C2AllocatorAhwb. This includes handles returned for a
+ * graphic block allocation handle based on an AHardwareBuffer.
+ *
+ * @return a new NON-OWNING native handle that must be deleted using native_handle_delete.
+ */
+native_handle_t *UnwrapNativeCodec2AhwbHandle(const C2Handle *const handle);
+
+/**
+ * Wrap the gralloc handle and metadata based on AHardwareBuffer into Codec2 handle
+ * recognized by C2AllocatorAhwb.
+ *
+ * @return a new NON-OWNING C2Handle that must be closed and deleted using native_handle_close and
+ * native_handle_delete.
+ */
+C2Handle *WrapNativeCodec2AhwbHandle(
+ const native_handle_t *const handle,
+ uint32_t width, uint32_t height, uint32_t format, uint64_t usage, uint32_t stride,
+ uint64_t origId);
+
+/**
+ * \todo Get this from the buffer
+ */
+void _UnwrapNativeCodec2AhwbMetadata(
+ const C2Handle *const handle,
+ uint32_t *width, uint32_t *height, uint32_t *format, uint64_t *usage, uint32_t *stride,
+ uint64_t *origId);
+
class C2AllocatorGralloc : public C2Allocator {
public:
virtual id_t getId() const override;
@@ -97,6 +127,53 @@
Impl *mImpl;
};
+/**
+ * C2Allocator for AHardwareBuffer based allocation.
+ *
+ * C2Allocator interface is based on C2Handle, which is actually wrapped
+ * native_handle_t. This is based on extracted handle from AHardwareBuffer.
+ * Trying to recover an AHardwareBuffer from C2GraphicAllocation created by the
+ * allocator will creates a new AHardwareBuffer with a different unique Id, but
+ * it is identical and will use same memory by the handle.
+ *
+ * C2GraphicAllocation does not have the original AHardwareBuffer. But
+ * C2GraphicBlock and C2ConstGraphicBlock has the original AHardwareBuffer,
+ * which can be sent to the other processes.
+ *
+ * TODO: Bundle AHardwareBuffer for C2GraphicAllocation.
+ * TODO: Add support for C2AllocatorBlob.
+ */
+class C2AllocatorAhwb : public C2Allocator {
+public:
+ virtual id_t getId() const override;
+
+ virtual C2String getName() const override;
+
+ virtual std::shared_ptr<const Traits> getTraits() const override;
+
+ virtual c2_status_t newGraphicAllocation(
+ uint32_t width, uint32_t height, uint32_t format, C2MemoryUsage usage,
+ std::shared_ptr<C2GraphicAllocation> *allocation) override;
+
+ virtual c2_status_t priorGraphicAllocation(
+ const C2Handle *handle,
+ std::shared_ptr<C2GraphicAllocation> *allocation) override;
+
+ C2AllocatorAhwb(id_t id);
+
+ c2_status_t status() const;
+
+ virtual ~C2AllocatorAhwb() override;
+
+ virtual bool checkHandle(const C2Handle* const o) const override { return CheckHandle(o); }
+
+ static bool CheckHandle(const C2Handle* const o);
+
+private:
+ class Impl;
+ Impl *mImpl;
+};
+
} // namespace android
#endif // STAGEFRIGHT_CODEC2_ALLOCATOR_GRALLOC_H_
diff --git a/media/codec2/vndk/include/C2FenceFactory.h b/media/codec2/vndk/include/C2FenceFactory.h
index ef25c47..9b09980 100644
--- a/media/codec2/vndk/include/C2FenceFactory.h
+++ b/media/codec2/vndk/include/C2FenceFactory.h
@@ -39,6 +39,7 @@
class SurfaceFenceImpl;
class SyncFenceImpl;
+ class PipeFenceImpl;
/*
* Create C2Fence for BufferQueueBased blockpool.
@@ -66,6 +67,15 @@
*/
static C2Fence CreateMultipleFdSyncFence(const std::vector<int>& fenceFds);
+ /*
+ * Create C2Fence from an fd created by pipe()/pipe2() syscall.
+ *
+ * \param fd An fd representing the write end from a pair of
+ * file descriptors which are created by
+ * pipe()/pipe2() syscall.
+ */
+ static C2Fence CreatePipeFence(int fd);
+
/**
* Create a native handle from fence for marshalling
*
diff --git a/media/libaudioclient/tests/Android.bp b/media/libaudioclient/tests/Android.bp
index 1e8dcca..5b90158 100644
--- a/media/libaudioclient/tests/Android.bp
+++ b/media/libaudioclient/tests/Android.bp
@@ -114,7 +114,6 @@
"libnblog",
"libprocessgroup",
"libshmemcompat",
- "libxml2",
"mediametricsservice-aidl-cpp",
"packagemanager_aidl-cpp",
"shared-file-region-aidl-cpp",
diff --git a/media/libaudioclient/tests/audio_test_utils.cpp b/media/libaudioclient/tests/audio_test_utils.cpp
index 1e26ff6..ee5489b 100644
--- a/media/libaudioclient/tests/audio_test_utils.cpp
+++ b/media/libaudioclient/tests/audio_test_utils.cpp
@@ -26,25 +26,10 @@
#define WAIT_PERIOD_MS 10 // from AudioTrack.cpp
#define MAX_WAIT_TIME_MS 5000
-template <class T>
-constexpr void (*xmlDeleter)(T* t);
-template <>
-constexpr auto xmlDeleter<xmlDoc> = xmlFreeDoc;
-template <>
-constexpr auto xmlDeleter<xmlChar> = [](xmlChar* s) { xmlFree(s); };
-
-/** @return a unique_ptr with the correct deleter for the libxml2 object. */
-template <class T>
-constexpr auto make_xmlUnique(T* t) {
- // Wrap deleter in lambda to enable empty base optimization
- auto deleter = [](T* t) { xmlDeleter<T>(t); };
- return std::unique_ptr<T, decltype(deleter)>{t, deleter};
-}
-
void OnAudioDeviceUpdateNotifier::onAudioDeviceUpdate(audio_io_handle_t audioIo,
audio_port_handle_t deviceId) {
std::unique_lock<std::mutex> lock{mMutex};
- ALOGD("%s audioIo=%d deviceId=%d", __func__, audioIo, deviceId);
+ ALOGI("%s: audioIo=%d deviceId=%d", __func__, audioIo, deviceId);
mAudioIo = audioIo;
mDeviceId = deviceId;
mCondition.notify_all();
@@ -727,184 +712,17 @@
}
std::string dumpPortConfig(const audio_port_config& port) {
- std::ostringstream result;
- std::string deviceInfo;
- if (port.type == AUDIO_PORT_TYPE_DEVICE) {
- if (port.ext.device.type & AUDIO_DEVICE_BIT_IN) {
- InputDeviceConverter::maskToString(port.ext.device.type, deviceInfo);
- } else {
- OutputDeviceConverter::maskToString(port.ext.device.type, deviceInfo);
- }
- deviceInfo += std::string(", address = ") + port.ext.device.address;
- }
- result << "audio_port_handle_t = " << port.id << ", "
- << "Role = " << (port.role == AUDIO_PORT_ROLE_SOURCE ? "source" : "sink") << ", "
- << "Type = " << (port.type == AUDIO_PORT_TYPE_DEVICE ? "device" : "mix") << ", "
- << "deviceInfo = " << (port.type == AUDIO_PORT_TYPE_DEVICE ? deviceInfo : "") << ", "
- << "config_mask = 0x" << std::hex << port.config_mask << std::dec << ", ";
- if (port.config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) {
- result << "sample rate = " << port.sample_rate << ", ";
- }
- if (port.config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) {
- result << "channel mask = " << port.channel_mask << ", ";
- }
- if (port.config_mask & AUDIO_PORT_CONFIG_FORMAT) {
- result << "format = " << port.format << ", ";
- }
- result << "input flags = " << port.flags.input << ", ";
- result << "output flags = " << port.flags.output << ", ";
- result << "mix io handle = " << (port.type == AUDIO_PORT_TYPE_DEVICE ? 0 : port.ext.mix.handle)
- << "\n";
- return result.str();
+ auto aidlPortConfig = legacy2aidl_audio_port_config_AudioPortConfigFw(port);
+ return aidlPortConfig.ok() ? aidlPortConfig.value().toString()
+ : "Error while converting audio port config to AIDL";
}
std::string dumpPatch(const audio_patch& patch) {
- std::ostringstream result;
- result << "----------------- Dumping Patch ------------ \n";
- result << "Patch Handle: " << patch.id << ", sources: " << patch.num_sources
- << ", sink: " << patch.num_sinks << "\n";
- audio_port_v7 port;
- for (uint32_t i = 0; i < patch.num_sources; i++) {
- result << "----------------- Dumping Source Port Config @ index " << i
- << " ------------ \n";
- result << dumpPortConfig(patch.sources[i]);
- result << "----------------- Dumping Source Port for id " << patch.sources[i].id
- << " ------------ \n";
- getPortById(patch.sources[i].id, port);
- result << dumpPort(port);
- }
- for (uint32_t i = 0; i < patch.num_sinks; i++) {
- result << "----------------- Dumping Sink Port Config @ index " << i << " ------------ \n";
- result << dumpPortConfig(patch.sinks[i]);
- result << "----------------- Dumping Sink Port for id " << patch.sinks[i].id
- << " ------------ \n";
- getPortById(patch.sinks[i].id, port);
- result << dumpPort(port);
- }
- return result.str();
+ auto aidlPatch = legacy2aidl_audio_patch_AudioPatchFw(patch);
+ return aidlPatch.ok() ? aidlPatch.value().toString() : "Error while converting patch to AIDL";
}
std::string dumpPort(const audio_port_v7& port) {
- std::ostringstream result;
- std::string deviceInfo;
- if (port.type == AUDIO_PORT_TYPE_DEVICE) {
- if (port.ext.device.type & AUDIO_DEVICE_BIT_IN) {
- InputDeviceConverter::maskToString(port.ext.device.type, deviceInfo);
- } else {
- OutputDeviceConverter::maskToString(port.ext.device.type, deviceInfo);
- }
- deviceInfo += std::string(", address = ") + port.ext.device.address;
- }
- result << "audio_port_handle_t = " << port.id << ", "
- << "Role = " << (port.role == AUDIO_PORT_ROLE_SOURCE ? "source" : "sink") << ", "
- << "Type = " << (port.type == AUDIO_PORT_TYPE_DEVICE ? "device" : "mix") << ", "
- << "deviceInfo = " << (port.type == AUDIO_PORT_TYPE_DEVICE ? deviceInfo : "") << ", "
- << "Name = " << port.name << ", "
- << "num profiles = " << port.num_audio_profiles << ", "
- << "mix io handle = " << (port.type == AUDIO_PORT_TYPE_DEVICE ? 0 : port.ext.mix.handle)
- << ", ";
- for (int i = 0; i < port.num_audio_profiles; i++) {
- result << "AudioProfile = " << i << " {";
- result << "format = " << port.audio_profiles[i].format << ", ";
- result << "samplerates = ";
- for (int j = 0; j < port.audio_profiles[i].num_sample_rates; j++) {
- result << port.audio_profiles[i].sample_rates[j] << ", ";
- }
- result << "channelmasks = ";
- for (int j = 0; j < port.audio_profiles[i].num_channel_masks; j++) {
- result << "0x" << std::hex << port.audio_profiles[i].channel_masks[j] << std::dec
- << ", ";
- }
- result << "} ";
- }
- result << dumpPortConfig(port.active_config);
- return result.str();
-}
-
-std::string getXmlAttribute(const xmlNode* cur, const char* attribute) {
- auto charPtr = make_xmlUnique(xmlGetProp(cur, reinterpret_cast<const xmlChar*>(attribute)));
- if (charPtr == NULL) {
- return "";
- }
- std::string value(reinterpret_cast<const char*>(charPtr.get()));
- return value;
-}
-
-status_t parse_audio_policy_configuration_xml(std::vector<std::string>& attachedDevices,
- std::vector<MixPort>& mixPorts,
- std::vector<Route>& routes) {
- std::string path = audio_find_readable_configuration_file("audio_policy_configuration.xml");
- if (path.length() == 0) return UNKNOWN_ERROR;
- auto doc = make_xmlUnique(xmlParseFile(path.c_str()));
- if (doc == nullptr) return UNKNOWN_ERROR;
- xmlNode* root = xmlDocGetRootElement(doc.get());
- if (root == nullptr) return UNKNOWN_ERROR;
- if (xmlXIncludeProcess(doc.get()) < 0) return UNKNOWN_ERROR;
- mixPorts.clear();
- if (!xmlStrcmp(root->name, reinterpret_cast<const xmlChar*>("audioPolicyConfiguration"))) {
- std::string raw{getXmlAttribute(root, "version")};
- for (auto* child = root->xmlChildrenNode; child != nullptr; child = child->next) {
- if (!xmlStrcmp(child->name, reinterpret_cast<const xmlChar*>("modules"))) {
- xmlNode* root = child;
- for (auto* child = root->xmlChildrenNode; child != nullptr; child = child->next) {
- if (!xmlStrcmp(child->name, reinterpret_cast<const xmlChar*>("module"))) {
- xmlNode* root = child;
- for (auto* child = root->xmlChildrenNode; child != nullptr;
- child = child->next) {
- if (!xmlStrcmp(child->name,
- reinterpret_cast<const xmlChar*>("mixPorts"))) {
- xmlNode* root = child;
- for (auto* child = root->xmlChildrenNode; child != nullptr;
- child = child->next) {
- if (!xmlStrcmp(child->name,
- reinterpret_cast<const xmlChar*>("mixPort"))) {
- MixPort mixPort;
- xmlNode* root = child;
- mixPort.name = getXmlAttribute(root, "name");
- mixPort.role = getXmlAttribute(root, "role");
- mixPort.flags = getXmlAttribute(root, "flags");
- if (mixPort.role == "source") mixPorts.push_back(mixPort);
- }
- }
- } else if (!xmlStrcmp(child->name, reinterpret_cast<const xmlChar*>(
- "attachedDevices"))) {
- xmlNode* root = child;
- for (auto* child = root->xmlChildrenNode; child != nullptr;
- child = child->next) {
- if (!xmlStrcmp(child->name,
- reinterpret_cast<const xmlChar*>("item"))) {
- auto xmlValue = make_xmlUnique(xmlNodeListGetString(
- child->doc, child->xmlChildrenNode, 1));
- if (xmlValue == nullptr) {
- raw = "";
- } else {
- raw = reinterpret_cast<const char*>(xmlValue.get());
- }
- std::string& value = raw;
- attachedDevices.push_back(std::move(value));
- }
- }
- } else if (!xmlStrcmp(child->name,
- reinterpret_cast<const xmlChar*>("routes"))) {
- xmlNode* root = child;
- for (auto* child = root->xmlChildrenNode; child != nullptr;
- child = child->next) {
- if (!xmlStrcmp(child->name,
- reinterpret_cast<const xmlChar*>("route"))) {
- Route route;
- xmlNode* root = child;
- route.name = getXmlAttribute(root, "name");
- route.sources = getXmlAttribute(root, "sources");
- route.sink = getXmlAttribute(root, "sink");
- routes.push_back(route);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return OK;
+ auto aidlPort = legacy2aidl_audio_port_v7_AudioPortFw(port);
+ return aidlPort.ok() ? aidlPort.value().toString() : "Error while converting port to AIDL";
}
diff --git a/media/libaudioclient/tests/audio_test_utils.h b/media/libaudioclient/tests/audio_test_utils.h
index 90c30c2..76e4642 100644
--- a/media/libaudioclient/tests/audio_test_utils.h
+++ b/media/libaudioclient/tests/audio_test_utils.h
@@ -28,8 +28,6 @@
#include <thread>
#include <binder/MemoryDealer.h>
-#include <libxml/parser.h>
-#include <libxml/xinclude.h>
#include <media/AidlConversion.h>
#include <media/AudioRecord.h>
#include <media/AudioTrack.h>
@@ -48,9 +46,6 @@
std::string sink;
};
-status_t parse_audio_policy_configuration_xml(std::vector<std::string>& attachedDevices,
- std::vector<MixPort>& mixPorts,
- std::vector<Route>& routes);
status_t listAudioPorts(std::vector<audio_port_v7>& portsVec);
status_t listAudioPatches(std::vector<struct audio_patch>& patchesVec);
status_t getPortByAttributes(audio_port_role_t role, audio_port_type_t type,
diff --git a/media/libaudioclient/tests/audiorouting_tests.cpp b/media/libaudioclient/tests/audiorouting_tests.cpp
index 19d1abc..fa990b5 100644
--- a/media/libaudioclient/tests/audiorouting_tests.cpp
+++ b/media/libaudioclient/tests/audiorouting_tests.cpp
@@ -15,10 +15,13 @@
*/
//#define LOG_NDEBUG 0
+#define LOG_TAG "AudioRoutingTest"
+#include <string.h>
+
+#include <binder/ProcessState.h>
#include <cutils/properties.h>
#include <gtest/gtest.h>
-#include <string.h>
#include "audio_test_utils.h"
@@ -63,12 +66,16 @@
EXPECT_NE(0, ap->getAudioTrackHandle()->getFlags() & output_flags[i]);
audio_patch patch;
EXPECT_EQ(OK, getPatchForOutputMix(cb->mAudioIo, patch));
- for (auto j = 0; j < patch.num_sources; j++) {
- if (patch.sources[j].type == AUDIO_PORT_TYPE_MIX &&
- patch.sources[j].ext.mix.handle == cb->mAudioIo) {
- if ((patch.sources[j].flags.output & output_flags[i]) == 0) {
- ADD_FAILURE() << "expected output flag " << output_flags[i] << " is absent";
- std::cerr << dumpPortConfig(patch.sources[j]);
+ if (output_flags[i] != AUDIO_OUTPUT_FLAG_FAST) {
+ // A "normal" output can still have a FastMixer, depending on the buffer size.
+ // Thus, a fast track can be created on a mix port which does not have the FAST flag.
+ for (auto j = 0; j < patch.num_sources; j++) {
+ if (patch.sources[j].type == AUDIO_PORT_TYPE_MIX &&
+ patch.sources[j].ext.mix.handle == cb->mAudioIo) {
+ SCOPED_TRACE(dumpPortConfig(patch.sources[j]));
+ EXPECT_NE(0, patch.sources[j].flags.output & output_flags[i])
+ << "expected output flag "
+ << audio_output_flag_to_string(output_flags[i]) << " is absent";
}
}
}
@@ -259,3 +266,25 @@
captureA->stop();
playback->stop();
}
+
+class TestExecutionTracer : public ::testing::EmptyTestEventListener {
+ public:
+ void OnTestStart(const ::testing::TestInfo& test_info) override {
+ TraceTestState("Started", test_info);
+ }
+ void OnTestEnd(const ::testing::TestInfo& test_info) override {
+ TraceTestState("Completed", test_info);
+ }
+
+ private:
+ static void TraceTestState(const std::string& state, const ::testing::TestInfo& test_info) {
+ ALOGI("%s %s::%s", state.c_str(), test_info.test_suite_name(), test_info.name());
+ }
+};
+
+int main(int argc, char** argv) {
+ android::ProcessState::self()->startThreadPool();
+ ::testing::InitGoogleTest(&argc, argv);
+ ::testing::UnitTest::GetInstance()->listeners().Append(new TestExecutionTracer());
+ return RUN_ALL_TESTS();
+}
diff --git a/media/libaudiohal/impl/StreamHalAidl.cpp b/media/libaudiohal/impl/StreamHalAidl.cpp
index c058386..e74fc16 100644
--- a/media/libaudiohal/impl/StreamHalAidl.cpp
+++ b/media/libaudiohal/impl/StreamHalAidl.cpp
@@ -193,7 +193,7 @@
StreamDescriptor::Reply reply;
switch (state) {
case StreamDescriptor::State::ACTIVE:
- if (status_t status = pause(&reply); status != OK) return status;
+ RETURN_STATUS_IF_ERROR(pause(&reply));
if (reply.state != StreamDescriptor::State::PAUSED) {
ALOGE("%s: unexpected stream state: %s (expected PAUSED)",
__func__, toString(reply.state).c_str());
@@ -203,7 +203,7 @@
case StreamDescriptor::State::PAUSED:
case StreamDescriptor::State::DRAIN_PAUSED:
if (mIsInput) return flush();
- if (status_t status = flush(&reply); status != OK) return status;
+ RETURN_STATUS_IF_ERROR(flush(&reply));
if (reply.state != StreamDescriptor::State::IDLE) {
ALOGE("%s: unexpected stream state: %s (expected IDLE)",
__func__, toString(reply.state).c_str());
@@ -211,10 +211,8 @@
}
FALLTHROUGH_INTENDED;
case StreamDescriptor::State::IDLE:
- if (status_t status = sendCommand(makeHalCommand<HalCommand::Tag::standby>(),
- &reply, true /*safeFromNonWorkerThread*/); status != OK) {
- return status;
- }
+ RETURN_STATUS_IF_ERROR(sendCommand(makeHalCommand<HalCommand::Tag::standby>(),
+ &reply, true /*safeFromNonWorkerThread*/));
if (reply.state != StreamDescriptor::State::STANDBY) {
ALOGE("%s: unexpected stream state: %s (expected STANDBY)",
__func__, toString(reply.state).c_str());
@@ -244,10 +242,7 @@
const auto state = getState();
StreamDescriptor::Reply reply;
if (state == StreamDescriptor::State::STANDBY) {
- if (status_t status = sendCommand(makeHalCommand<HalCommand::Tag::start>(), &reply, true);
- status != OK) {
- return status;
- }
+ RETURN_STATUS_IF_ERROR(sendCommand(makeHalCommand<HalCommand::Tag::start>(), &reply, true));
return sendCommand(makeHalCommand<HalCommand::Tag::burst>(0), &reply, true);
}
@@ -264,10 +259,7 @@
ALOGV("%p %s::%s", this, getClassName().c_str(), __func__);
if (!mStream) return NO_INIT;
StreamDescriptor::Reply reply;
- if (status_t status = updateCountersIfNeeded(&reply); status != OK) {
- return status;
- }
-
+ RETURN_STATUS_IF_ERROR(updateCountersIfNeeded(&reply));
*latency = std::clamp(std::max<int32_t>(0, reply.latencyMs), 1, 3000);
ALOGW_IF(reply.latencyMs != static_cast<int32_t>(*latency),
"Suspicious latency value reported by HAL: %d, clamped to %u", reply.latencyMs,
@@ -279,11 +271,9 @@
ALOGV("%p %s::%s", this, getClassName().c_str(), __func__);
if (!mStream) return NO_INIT;
StreamDescriptor::Reply reply;
- if (status_t status = updateCountersIfNeeded(&reply); status != OK) {
- return status;
- }
- *frames = reply.observable.frames;
- *timestamp = reply.observable.timeNs;
+ RETURN_STATUS_IF_ERROR(updateCountersIfNeeded(&reply));
+ *frames = std::max<int64_t>(0, reply.observable.frames);
+ *timestamp = std::max<int64_t>(0, reply.observable.timeNs);
return OK;
}
@@ -292,12 +282,9 @@
if (!mStream) return NO_INIT;
StreamDescriptor::Reply reply;
// TODO: switch to updateCountersIfNeeded once we sort out mWorkerTid initialization
- if (status_t status = sendCommand(makeHalCommand<HalCommand::Tag::getStatus>(), &reply, true);
- status != OK) {
- return status;
- }
- *frames = reply.hardware.frames;
- *timestamp = reply.hardware.timeNs;
+ RETURN_STATUS_IF_ERROR(sendCommand(makeHalCommand<HalCommand::Tag::getStatus>(), &reply, true));
+ *frames = std::max<int64_t>(0, reply.hardware.frames);
+ *timestamp = std::max<int64_t>(0, reply.hardware.timeNs);
return OK;
}
@@ -305,10 +292,8 @@
ALOGV("%p %s::%s", this, getClassName().c_str(), __func__);
if (!mStream) return NO_INIT;
StreamDescriptor::Reply reply;
- if (status_t status = updateCountersIfNeeded(&reply); status != OK) {
- return status;
- }
- *frames = reply.xrunFrames;
+ RETURN_STATUS_IF_ERROR(updateCountersIfNeeded(&reply));
+ *frames = std::max<int32_t>(0, reply.xrunFrames);
return OK;
}
@@ -323,10 +308,7 @@
// stream state), however this scenario wasn't supported by the HIDL HAL.
if (getState() == StreamDescriptor::State::STANDBY) {
StreamDescriptor::Reply reply;
- if (status_t status = sendCommand(makeHalCommand<HalCommand::Tag::start>(), &reply);
- status != OK) {
- return status;
- }
+ RETURN_STATUS_IF_ERROR(sendCommand(makeHalCommand<HalCommand::Tag::start>(), &reply));
if (reply.state != StreamDescriptor::State::IDLE) {
ALOGE("%s: failed to get the stream out of standby, actual state: %s",
__func__, toString(reply.state).c_str());
@@ -345,9 +327,7 @@
}
}
StreamDescriptor::Reply reply;
- if (status_t status = sendCommand(burst, &reply); status != OK) {
- return status;
- }
+ RETURN_STATUS_IF_ERROR(sendCommand(burst, &reply));
*transferred = reply.fmqByteCount;
if (mIsInput) {
LOG_ALWAYS_FATAL_IF(*transferred > bytes,
@@ -385,11 +365,8 @@
if (state == StreamDescriptor::State::IDLE) {
StreamDescriptor::Reply localReply{};
StreamDescriptor::Reply* innerReply = reply ?: &localReply;
- if (status_t status =
- sendCommand(makeHalCommand<HalCommand::Tag::burst>(0), innerReply);
- status != OK) {
- return status;
- }
+ RETURN_STATUS_IF_ERROR(
+ sendCommand(makeHalCommand<HalCommand::Tag::burst>(0), innerReply));
if (innerReply->state != StreamDescriptor::State::ACTIVE) {
ALOGE("%s: unexpected stream state: %s (expected ACTIVE)",
__func__, toString(innerReply->state).c_str());
@@ -452,10 +429,7 @@
return BAD_VALUE;
}
int64_t aidlPosition = 0, aidlTimestamp = 0;
- if (status_t status = getHardwarePosition(&aidlPosition, &aidlTimestamp); status != OK) {
- return status;
- }
-
+ RETURN_STATUS_IF_ERROR(getHardwarePosition(&aidlPosition, &aidlTimestamp));
position->time_nanoseconds = aidlTimestamp;
position->position_frames = static_cast<int32_t>(aidlPosition);
return OK;
@@ -503,6 +477,11 @@
}
{
std::lock_guard l(mLock);
+ // Not every command replies with 'latencyMs' field filled out, substitute the last
+ // returned value in that case.
+ if (reply->latencyMs <= 0) {
+ reply->latencyMs = mLastReply.latencyMs;
+ }
mLastReply = *reply;
}
switch (reply->status) {
@@ -608,10 +587,8 @@
return BAD_VALUE;
}
int64_t aidlFrames = 0, aidlTimestamp = 0;
- if (status_t status = getObservablePosition(&aidlFrames, &aidlTimestamp); status != OK) {
- return OK;
- }
- *dspFrames = std::clamp<int64_t>(aidlFrames, 0, UINT32_MAX);
+ RETURN_STATUS_IF_ERROR(getObservablePosition(&aidlFrames, &aidlTimestamp));
+ *dspFrames = static_cast<uint32_t>(aidlFrames);
return OK;
}
@@ -680,10 +657,8 @@
return BAD_VALUE;
}
int64_t aidlFrames = 0, aidlTimestamp = 0;
- if (status_t status = getObservablePosition(&aidlFrames, &aidlTimestamp); status != OK) {
- return status;
- }
- *frames = std::max<int64_t>(0, aidlFrames);
+ RETURN_STATUS_IF_ERROR(getObservablePosition(&aidlFrames, &aidlTimestamp));
+ *frames = aidlFrames;
timestamp->tv_sec = aidlTimestamp / NANOS_PER_SECOND;
timestamp->tv_nsec = aidlTimestamp - timestamp->tv_sec * NANOS_PER_SECOND;
return OK;
@@ -901,9 +876,7 @@
return BAD_VALUE;
}
int32_t aidlXruns = 0;
- if (status_t status = getXruns(&aidlXruns); status != OK) {
- return status;
- }
+ RETURN_STATUS_IF_ERROR(getXruns(&aidlXruns));
*framesLost = std::max<int32_t>(0, aidlXruns);
return OK;
}
diff --git a/media/libaudiohal/impl/StreamHalAidl.h b/media/libaudiohal/impl/StreamHalAidl.h
index 3b369bd..4acc6ac 100644
--- a/media/libaudiohal/impl/StreamHalAidl.h
+++ b/media/libaudiohal/impl/StreamHalAidl.h
@@ -207,10 +207,13 @@
status_t getLatency(uint32_t *latency);
+ // Always returns non-negative values.
status_t getObservablePosition(int64_t *frames, int64_t *timestamp);
+ // Always returns non-negative values.
status_t getHardwarePosition(int64_t *frames, int64_t *timestamp);
+ // Always returns non-negative values.
status_t getXruns(int32_t *frames);
status_t transfer(void *buffer, size_t bytes, size_t *transferred);
diff --git a/media/libmedia/include/media/mediametadataretriever.h b/media/libmedia/include/media/mediametadataretriever.h
index 9074574..fba1a30 100644
--- a/media/libmedia/include/media/mediametadataretriever.h
+++ b/media/libmedia/include/media/mediametadataretriever.h
@@ -96,19 +96,13 @@
status_t setDataSource(
const sp<IDataSource>& dataSource, const char *mime = NULL);
sp<IMemory> getFrameAtTime(int64_t timeUs, int option,
- int colorFormat, bool metaOnly = false);
- sp<IMemory> getFrameAtTime(int64_t timeUs, int option,
- bool metaOnly = false);
+ int colorFormat = HAL_PIXEL_FORMAT_RGB_565, bool metaOnly = false);
sp<IMemory> getImageAtIndex(int index,
- int colorFormat, bool metaOnly = false, bool thumbnail = false);
- sp<IMemory> getImageAtIndex(int index,
- bool metaOnly = false, bool thumbnail = false);
+ int colorFormat = HAL_PIXEL_FORMAT_RGB_565, bool metaOnly = false, bool thumbnail = false);
sp<IMemory> getImageRectAtIndex(
int index, int colorFormat, int left, int top, int right, int bottom);
sp<IMemory> getFrameAtIndex(
- int index, int colorFormat, bool metaOnly = false);
- sp<IMemory> getFrameAtIndex(
- int index, bool metaOnly = false);
+ int index, int colorFormat = HAL_PIXEL_FORMAT_RGB_565, bool metaOnly = false);
sp<IMemory> extractAlbumArt();
const char* extractMetadata(int keyCode);
diff --git a/media/libmedia/mediametadataretriever.cpp b/media/libmedia/mediametadataretriever.cpp
index 427a3bd..2ae76b3 100644
--- a/media/libmedia/mediametadataretriever.cpp
+++ b/media/libmedia/mediametadataretriever.cpp
@@ -142,11 +142,6 @@
}
sp<IMemory> MediaMetadataRetriever::getFrameAtTime(
- int64_t timeUs, int option, bool metaOnly) {
- return getFrameAtTime(timeUs, option, HAL_PIXEL_FORMAT_RGB_565, metaOnly);
-}
-
-sp<IMemory> MediaMetadataRetriever::getFrameAtTime(
int64_t timeUs, int option, int colorFormat, bool metaOnly)
{
ALOGV("getFrameAtTime: time(%" PRId64 " us) option(%d) colorFormat(%d) metaOnly(%d)",
@@ -160,11 +155,6 @@
}
sp<IMemory> MediaMetadataRetriever::getImageAtIndex(
- int index, bool metaOnly, bool thumbnail) {
- return getImageAtIndex(index, HAL_PIXEL_FORMAT_RGB_565, metaOnly, thumbnail);
-}
-
-sp<IMemory> MediaMetadataRetriever::getImageAtIndex(
int index, int colorFormat, bool metaOnly, bool thumbnail) {
ALOGV("getImageAtIndex: index(%d) colorFormat(%d) metaOnly(%d) thumbnail(%d)",
index, colorFormat, metaOnly, thumbnail);
@@ -190,11 +180,6 @@
}
sp<IMemory> MediaMetadataRetriever::getFrameAtIndex(
- int index, bool metaOnly) {
- return getFrameAtIndex(index, HAL_PIXEL_FORMAT_RGB_565, metaOnly);
-}
-
-sp<IMemory> MediaMetadataRetriever::getFrameAtIndex(
int index, int colorFormat, bool metaOnly) {
ALOGV("getFrameAtIndex: index(%d), colorFormat(%d) metaOnly(%d)",
index, colorFormat, metaOnly);
diff --git a/media/libstagefright/tests/HEVC/AndroidTest.xml b/media/libstagefright/tests/HEVC/AndroidTest.xml
index 00bb3e5..8c7bb91 100644
--- a/media/libstagefright/tests/HEVC/AndroidTest.xml
+++ b/media/libstagefright/tests/HEVC/AndroidTest.xml
@@ -34,6 +34,6 @@
<test class="com.android.tradefed.testtype.GTest" >
<option name="native-test-device-path" value="/data/local/tmp" />
<option name="module-name" value="HEVCUtilsUnitTest" />
- <option name="native-test-flag" value="-P /sdcard/tests/HEVCUtilsUnitTest-1.0/" />
+ <option name="native-test-flag" value="-P /sdcard/test/HEVCUtilsUnitTest-1.0/" />
</test>
</configuration>
diff --git a/media/libstagefright/tests/HEVC/DynamicConfig.xml b/media/libstagefright/tests/HEVC/DynamicConfig.xml
index 517449c..9117c7b 100644
--- a/media/libstagefright/tests/HEVC/DynamicConfig.xml
+++ b/media/libstagefright/tests/HEVC/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/foundation/tests/HEVCUtils/HEVCUtilsUnitTest-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/libstagefright/tests/HEVC/HEVCUtilsUnitTest-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/libstagefright/tests/HEVC/README.md b/media/libstagefright/tests/HEVC/README.md
index fa0e99c..652c95b 100644
--- a/media/libstagefright/tests/HEVC/README.md
+++ b/media/libstagefright/tests/HEVC/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/HEVCUtilsUnitTest/HEVCUtilsUnitTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/foundation/tests/HEVCUtils/HEVCUtilsUnitTest.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/libstagefright/tests/HEVC/HEVCUtilsUnitTest-1.0.zip). Download, unzip and push these files into device for testing.
```
-adb push HEVCUtilsUnitTest /data/local/tmp/
+adb push HEVCUtilsUnitTest-1.0 /data/local/tmp/
```
usage: HEVCUtilsUnitTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/HEVCUtilsUnitTest -P /data/local/tmp/HEVCUtilsUnitTest/
+adb shell /data/local/tmp/HEVCUtilsUnitTest -P /data/local/tmp/HEVCUtilsUnitTest-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/libstagefright/tests/extractorFactory/DynamicConfig.xml b/media/libstagefright/tests/extractorFactory/DynamicConfig.xml
index 0258808..7bce77f 100644
--- a/media/libstagefright/tests/extractorFactory/DynamicConfig.xml
+++ b/media/libstagefright/tests/extractorFactory/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/extractors/tests/extractor-1.5.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/libstagefright/tests/extractorFactory/extractor-1.5.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/libstagefright/tests/extractorFactory/README.md b/media/libstagefright/tests/extractorFactory/README.md
index aaa71aa..aae247a 100644
--- a/media/libstagefright/tests/extractorFactory/README.md
+++ b/media/libstagefright/tests/extractorFactory/README.md
@@ -19,16 +19,16 @@
adb push ${OUT}/data/nativetest/ExtractorFactoryTest/ExtractorFactoryTest /data/local/tmp/
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/extractors/tests/extractor.zip).
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/libstagefright/tests/extractorFactory/extractor-1.5.zip).
Download, unzip and push these files into device for testing.
```
-adb push extractor /data/local/tmp/
+adb push extractor-1.5 /data/local/tmp/
```
usage: ExtractorFactoryTest -P \<path_to_res_folder\>
```
-adb shell /data/local/tmp/ExtractorFactoryTest -P /data/local/tmp/extractor/
+adb shell /data/local/tmp/ExtractorFactoryTest -P /data/local/tmp/extractor-1.5/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/libstagefright/tests/writer/DynamicConfig.xml b/media/libstagefright/tests/writer/DynamicConfig.xml
index e6dc502..7ba0b8c 100644
--- a/media/libstagefright/tests/writer/DynamicConfig.xml
+++ b/media/libstagefright/tests/writer/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/tests/writer/WriterTestRes-1.2.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/libstagefright/tests/writer/WriterTestRes-1.2.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/libstagefright/tests/writer/README.md b/media/libstagefright/tests/writer/README.md
index 0e54ca7..44b076b 100644
--- a/media/libstagefright/tests/writer/README.md
+++ b/media/libstagefright/tests/writer/README.md
@@ -19,15 +19,15 @@
adb push ${OUT}/data/nativetest/writerTest/writerTest /data/local/tmp/
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/tests/writer/WriterTestRes-1.1.zip).
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/libstagefright/tests/writer/WriterTestRes-1.2.zip).
Download and extract the folder. Push all the files in this folder to /data/local/tmp/ on the device.
```
-adb push WriterTestRes-1.1/. /data/local/tmp/WriterTestRes/
+adb push WriterTestRes-1.2 /data/local/tmp/
```
usage: writerTest -P \<path_to_res_folder\> -C <remove_output_file>
```
-adb shell /data/local/tmp/writerTest -P /data/local/tmp/WriterTestRes/ -C true
+adb shell /data/local/tmp/writerTest -P /data/local/tmp/WriterTestRes-1.2/ -C true
```
Alternatively, the test can also be run using atest command.
diff --git a/media/libstagefright/timedtext/test/AndroidTest.xml b/media/libstagefright/timedtext/test/AndroidTest.xml
index 0d5d79f..b536059 100644
--- a/media/libstagefright/timedtext/test/AndroidTest.xml
+++ b/media/libstagefright/timedtext/test/AndroidTest.xml
@@ -34,6 +34,6 @@
<test class="com.android.tradefed.testtype.GTest" >
<option name="native-test-device-path" value="/data/local/tmp" />
<option name="module-name" value="TimedTextUnitTest" />
- <option name="native-test-flag" value="-P /data/local/tmp/TimedTextUnitTest-1.0/" />
+ <option name="native-test-flag" value="-P /sdcard/test/TimedTextUnitTest-1.0/" />
</test>
</configuration>
diff --git a/media/libstagefright/timedtext/test/DynamicConfig.xml b/media/libstagefright/timedtext/test/DynamicConfig.xml
index e36277e..b3497bf 100644
--- a/media/libstagefright/timedtext/test/DynamicConfig.xml
+++ b/media/libstagefright/timedtext/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/timedtext/test/TimedTextUnitTest-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/libstagefright/timedtext/test/TimedTextUnitTest-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/libstagefright/timedtext/test/README.md b/media/libstagefright/timedtext/test/README.md
index 3a774bd..83b6873 100644
--- a/media/libstagefright/timedtext/test/README.md
+++ b/media/libstagefright/timedtext/test/README.md
@@ -22,16 +22,16 @@
adb push ${OUT}/data/nativetest/TimedTextUnitTest/TimedTextUnitTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/timedtext/test/TimedTextUnitTest.zip).
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/libstagefright/timedtext/test/TimedTextUnitTest-1.0.zip).
Download, unzip and push these files into device for testing.
```
-adb push TimedTextUnitTestRes/. /data/local/tmp/
+adb push TimedTextUnitTestRes-1.0 /data/local/tmp/
```
usage: TimedTextUnitTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/TimedTextUnitTest -P /data/local/tmp/TimedTextUnitTestRes/
+adb shell /data/local/tmp/TimedTextUnitTest -P /data/local/tmp/TimedTextUnitTestRes-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/codecs/amrnb/dec/test/DynamicConfig.xml b/media/module/codecs/amrnb/dec/test/DynamicConfig.xml
index de81c48..701a752 100644
--- a/media/module/codecs/amrnb/dec/test/DynamicConfig.xml
+++ b/media/module/codecs/amrnb/dec/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/amrnb/dec/test/AmrnbDecoderTest-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/amrnb/dec/test/AmrnbDecoderTest-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/codecs/amrnb/dec/test/README.md b/media/module/codecs/amrnb/dec/test/README.md
index e9073e4..41fb80a 100644
--- a/media/module/codecs/amrnb/dec/test/README.md
+++ b/media/module/codecs/amrnb/dec/test/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/AmrnbDecoderTest/AmrnbDecoderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/amrnb/dec/test/AmrnbDecoderTest.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/amrnb/dec/test/AmrnbDecoderTest-1.0.zip). Download, unzip and push these files into device for testing.
```
-adb push AmrnbDecoderTestRes/. /data/local/tmp/
+adb push AmrnbDecoderTest-1.0 /data/local/tmp/
```
usage: AmrnbDecoderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/AmrnbDecoderTest -P /data/local/tmp/AmrnbDecoderTestRes/
+adb shell /data/local/tmp/AmrnbDecoderTest -P /data/local/tmp/AmrnbDecoderTest-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/codecs/amrnb/enc/test/DynamicConfig.xml b/media/module/codecs/amrnb/enc/test/DynamicConfig.xml
index b22df38..713667a 100644
--- a/media/module/codecs/amrnb/enc/test/DynamicConfig.xml
+++ b/media/module/codecs/amrnb/enc/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/amrnb/enc/test/AmrnbEncoderTest-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/amrnb/enc/test/AmrnbEncoderTest-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/codecs/amrnb/enc/test/README.md b/media/module/codecs/amrnb/enc/test/README.md
index e9d2c95..f896bd1 100644
--- a/media/module/codecs/amrnb/enc/test/README.md
+++ b/media/module/codecs/amrnb/enc/test/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/AmrnbEncoderTest/AmrnbEncoderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/amrnb/enc/test/AmrnbEncoderTest.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/amrnb/enc/test/AmrnbEncoderTest-1.0.zip). Download, unzip and push these files into device for testing.
```
-adb push AmrnbEncoderTestRes/. /data/local/tmp/
+adb push AmrnbEncoderTest-1.0 /data/local/tmp/
```
usage: AmrnbEncoderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/AmrnbEncoderTest -P /data/local/tmp/AmrnbEncoderTestRes/
+adb shell /data/local/tmp/AmrnbEncoderTest -P /data/local/tmp/AmrnbEncoderTest-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/codecs/amrwb/dec/test/DynamicConfig.xml b/media/module/codecs/amrwb/dec/test/DynamicConfig.xml
index d41517f..506cc3d 100644
--- a/media/module/codecs/amrwb/dec/test/DynamicConfig.xml
+++ b/media/module/codecs/amrwb/dec/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/amrwb/test/AmrwbDecoderTest-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/amrwb/dec/test/AmrwbDecoderTest-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/codecs/amrwb/dec/test/README.md b/media/module/codecs/amrwb/dec/test/README.md
index a9d5c06..8e77456 100644
--- a/media/module/codecs/amrwb/dec/test/README.md
+++ b/media/module/codecs/amrwb/dec/test/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/AmrwbDecoderTest/AmrwbDecoderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/amrwb/test/AmrwbDecoderTest.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/amrwb/dec/test/AmrwbDecoderTest-1.0.zip). Download, unzip and push these files into device for testing.
```
-adb push AmrwbDecoderTestRes/. /data/local/tmp/
+adb push AmrwbDecoderTest-1.0 /data/local/tmp/
```
usage: AmrwbDecoderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/AmrwbDecoderTest -P /data/local/tmp/AmrwbDecoderTestRes/
+adb shell /data/local/tmp/AmrwbDecoderTest -P /data/local/tmp/AmrwbDecoderTest-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/codecs/amrwb/enc/test/DynamicConfig.xml b/media/module/codecs/amrwb/enc/test/DynamicConfig.xml
index 1cf5bf5..a0b6218 100644
--- a/media/module/codecs/amrwb/enc/test/DynamicConfig.xml
+++ b/media/module/codecs/amrwb/enc/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/amrwbenc/test/AmrwbEncoderTest-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/amrwb/enc/test/AmrwbEncoderTest-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/codecs/amrwb/enc/test/README.md b/media/module/codecs/amrwb/enc/test/README.md
index 78762cb..3b9cc39 100644
--- a/media/module/codecs/amrwb/enc/test/README.md
+++ b/media/module/codecs/amrwb/enc/test/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/AmrwbEncoderTest/AmrwbEncoderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/amrwbenc/test/AmrwbEncoderTest.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/amrwb/enc/test/AmrwbEncoderTest-1.0.zip). Download, unzip and push these files into device for testing.
```
-adb push AmrwbEncoderTestRes/. /data/local/tmp/
+adb push AmrwbEncoderTest-1.0 /data/local/tmp/
```
usage: AmrwbEncoderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/AmrwbEncoderTest -P /data/local/tmp/AmrwbEncoderTestRes/
+adb shell /data/local/tmp/AmrwbEncoderTest -P /data/local/tmp/AmrwbEncoderTest-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/codecs/flac/dec/test/DynamicConfig.xml b/media/module/codecs/flac/dec/test/DynamicConfig.xml
index 0258808..1920413 100644
--- a/media/module/codecs/flac/dec/test/DynamicConfig.xml
+++ b/media/module/codecs/flac/dec/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/extractors/tests/extractor-1.5.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/flac/dec/test/FlacDecoder-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/codecs/flac/dec/test/README.md b/media/module/codecs/flac/dec/test/README.md
index 4d194cd..3490d66 100644
--- a/media/module/codecs/flac/dec/test/README.md
+++ b/media/module/codecs/flac/dec/test/README.md
@@ -22,16 +22,16 @@
adb push ${OUT}/data/nativetest/FlacDecoderTest/FlacDecoderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/flac/dec/test/FlacDecoder.zip).
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/flac/dec/test/FlacDecoder-1.0.zip).
Download, unzip and push these files into device for testing.
```
-adb push FlacDecoder /data/local/tmp/
+adb push FlacDecoder-1.0 /data/local/tmp/
```
usage: FlacDecoderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/FlacDecoderTest -P /data/local/tmp/FlacDecoder/
+adb shell /data/local/tmp/FlacDecoderTest -P /data/local/tmp/FlacDecoder-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/codecs/m4v_h263/dec/test/DynamicConfig.xml b/media/module/codecs/m4v_h263/dec/test/DynamicConfig.xml
index 5219361..e86f784 100644
--- a/media/module/codecs/m4v_h263/dec/test/DynamicConfig.xml
+++ b/media/module/codecs/m4v_h263/dec/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/m4v_h263/dec/test/Mpeg4H263Decoder-1.2.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/m4v_h263/dec/test/Mpeg4H263Decoder-1.2.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/codecs/m4v_h263/dec/test/README.md b/media/module/codecs/m4v_h263/dec/test/README.md
index 38ac567..e80536b 100644
--- a/media/module/codecs/m4v_h263/dec/test/README.md
+++ b/media/module/codecs/m4v_h263/dec/test/README.md
@@ -22,16 +22,16 @@
adb push ${OUT}/data/nativetest/Mpeg4H263DecoderTest/Mpeg4H263DecoderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/m4v_h263/dec/test/Mpeg4H263Decoder-1.1.zip).
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/m4v_h263/dec/test/Mpeg4H263Decoder-1.2.zip).
Download, unzip and push these files into device for testing.
```
-adb push Mpeg4H263Decoder /data/local/tmp/
+adb push Mpeg4H263Decoder-1.2 /data/local/tmp/
```
usage: Mpeg4H263DecoderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/Mpeg4H263DecoderTest -P /data/local/tmp/Mpeg4H263Decoder/
+adb shell /data/local/tmp/Mpeg4H263DecoderTest -P /data/local/tmp/Mpeg4H263Decoder-1.2/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/codecs/m4v_h263/enc/test/DynamicConfig.xml b/media/module/codecs/m4v_h263/enc/test/DynamicConfig.xml
index ceb33ef..f31d01f 100644
--- a/media/module/codecs/m4v_h263/enc/test/DynamicConfig.xml
+++ b/media/module/codecs/m4v_h263/enc/test/DynamicConfig.xml
@@ -15,7 +15,7 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/m4v_h263/enc/test/Mpeg4H263Encoder-1.1.zip
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/m4v_h263/enc/test/Mpeg4H263Encoder-1.1.zip
</value>
</entry>
</dynamicConfig>
diff --git a/media/module/codecs/m4v_h263/enc/test/README.md b/media/module/codecs/m4v_h263/enc/test/README.md
index 25de878..e2d3603 100644
--- a/media/module/codecs/m4v_h263/enc/test/README.md
+++ b/media/module/codecs/m4v_h263/enc/test/README.md
@@ -21,15 +21,15 @@
adb push ${OUT}/data/nativetest/Mpeg4H263EncoderTest/Mpeg4H263EncoderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/codecs/m4v_h263/enc/test/Mpeg4H263Encoder.zip ) Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/m4v_h263/enc/test/Mpeg4H263Encoder-1.1.zip) Download, unzip and push these files into device for testing.
```
-adb push Mpeg4H263Encoder/. /data/local/tmp/
+adb push Mpeg4H263Encoder-1.1 /data/local/tmp/
```
usage: Mpeg4H263EncoderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/Mpeg4H263EncoderTest -P /data/local/tmp/
+adb shell /data/local/tmp/Mpeg4H263EncoderTest -P /data/local/tmp/Mpeg4H263Encoder-1.1/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/codecs/mp3dec/test/DynamicConfig.xml b/media/module/codecs/mp3dec/test/DynamicConfig.xml
index 048940b..daf5ade 100644
--- a/media/module/codecs/mp3dec/test/DynamicConfig.xml
+++ b/media/module/codecs/mp3dec/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/mp3dec/test/Mp3DecoderTest-1.3.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/mp3dec/test/Mp3DecoderTest-1.3.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/codecs/mp3dec/test/README.md b/media/module/codecs/mp3dec/test/README.md
index f59fec7..44c159e 100644
--- a/media/module/codecs/mp3dec/test/README.md
+++ b/media/module/codecs/mp3dec/test/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/Mp3DecoderTest/Mp3DecoderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/mp3dec/test/Mp3DecoderTest.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/codecs/mp3dec/test/Mp3DecoderTest-1.3.zip). Download, unzip and push these files into device for testing.
```
-adb push Mp3DecoderTestRes/. /data/local/tmp/
+adb push Mp3DecoderTest-1.3 /data/local/tmp/
```
usage: Mp3DecoderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/Mp3DecoderTest -P /data/local/tmp/Mp3DecoderTestRes/
+adb shell /data/local/tmp/Mp3DecoderTest -P /data/local/tmp/Mp3DecoderTest-1.3/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/esds/tests/DynamicConfig.xml b/media/module/esds/tests/DynamicConfig.xml
index 9718dda..757279f 100644
--- a/media/module/esds/tests/DynamicConfig.xml
+++ b/media/module/esds/tests/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/tests/ESDS/ESDSTestRes-1.1.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/esds/tests/ESDSTestRes-1.1.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/esds/tests/README.md b/media/module/esds/tests/README.md
index 100fb86..bafda98 100644
--- a/media/module/esds/tests/README.md
+++ b/media/module/esds/tests/README.md
@@ -22,16 +22,16 @@
adb push ${OUT}/data/nativetest/ESDSTest/ESDSTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/tests/ESDS/ESDSTestRes-1.0.zip)
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/esds/tests/ESDSTestRes-1.1.zip)
Download, unzip and push these files into device for testing.
```
-adb push ESDSTestRes /data/local/tmp/
+adb push ESDSTestRes-1.1 /data/local/tmp/
```
usage: ESDSTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/ESDSTest -P /data/local/tmp/ESDSTestRes/
+adb shell /data/local/tmp/ESDSTest -P /data/local/tmp/ESDSTestRes-1.1/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/extractors/tests/DynamicConfig.xml b/media/module/extractors/tests/DynamicConfig.xml
index 0258808..7416385 100644
--- a/media/module/extractors/tests/DynamicConfig.xml
+++ b/media/module/extractors/tests/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/extractors/tests/extractor-1.5.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/extractors/tests/extractor-1.5.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/extractors/tests/README.md b/media/module/extractors/tests/README.md
index cff09ca..fba2aab 100644
--- a/media/module/extractors/tests/README.md
+++ b/media/module/extractors/tests/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/ExtractorUnitTest/ExtractorUnitTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/extractors/tests/extractor-1.4.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/extractors/tests/extractor-1.5.zip). Download, unzip and push these files into device for testing.
```
-adb push extractor /data/local/tmp/
+adb push extractor-1.5 /data/local/tmp/
```
usage: ExtractorUnitTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/ExtractorUnitTest -P /data/local/tmp/extractor/
+adb shell /data/local/tmp/ExtractorUnitTest -P /data/local/tmp/extractor-1.5/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/foundation/tests/AVCUtils/DynamicConfig.xml b/media/module/foundation/tests/AVCUtils/DynamicConfig.xml
index e5b8bad..590b948 100644
--- a/media/module/foundation/tests/AVCUtils/DynamicConfig.xml
+++ b/media/module/foundation/tests/AVCUtils/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value> https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/foundation/tests/AVCUtils/AVCUtilsUnitTest-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/foundation/tests/AVCUtils/AVCUtilsUnitTest-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/foundation/tests/AVCUtils/README.md b/media/module/foundation/tests/AVCUtils/README.md
index 609d72e..8088cc7 100644
--- a/media/module/foundation/tests/AVCUtils/README.md
+++ b/media/module/foundation/tests/AVCUtils/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/AVCUtilsUnitTest/AVCUtilsUnitTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/foundation/tests/AVCUtils/AVCUtilsUnitTest.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/foundation/tests/AVCUtils/AVCUtilsUnitTest-1.0.zip). Download, unzip and push these files into device for testing.
```
-adb push AVCUtilsUnitTest /data/local/tmp/
+adb push AVCUtilsUnitTest-1.0 /data/local/tmp/
```
usage: AVCUtilsUnitTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/AVCUtilsUnitTest -P /data/local/tmp/AVCUtilsUnitTest/
+adb shell /data/local/tmp/AVCUtilsUnitTest -P /data/local/tmp/AVCUtilsUnitTest-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/foundation/tests/OpusHeader/DynamicConfig.xml b/media/module/foundation/tests/OpusHeader/DynamicConfig.xml
index ebac328..04cd363 100644
--- a/media/module/foundation/tests/OpusHeader/DynamicConfig.xml
+++ b/media/module/foundation/tests/OpusHeader/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/foundation/tests/OpusHeader/OpusHeader-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/foundation/tests/OpusHeader/OpusHeader-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/foundation/tests/OpusHeader/README.md b/media/module/foundation/tests/OpusHeader/README.md
index 860c827..e657207 100644
--- a/media/module/foundation/tests/OpusHeader/README.md
+++ b/media/module/foundation/tests/OpusHeader/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/OpusHeaderTest/OpusHeaderTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/foundation/tests/OpusHeader/OpusHeader.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/foundation/tests/OpusHeader/OpusHeader-1.0.zip). Download, unzip and push these files into device for testing.
```
-adb push OpusHeader /data/local/tmp/
+adb push OpusHeader-1.0 /data/local/tmp/
```
usage: OpusHeaderTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/OpusHeaderTest -P /data/local/tmp/OpusHeader/
+adb shell /data/local/tmp/OpusHeaderTest -P /data/local/tmp/OpusHeader-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/id3/test/DynamicConfig.xml b/media/module/id3/test/DynamicConfig.xml
index 5ae4fcd..b704a6c 100644
--- a/media/module/id3/test/DynamicConfig.xml
+++ b/media/module/id3/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/id3/test/ID3Test-1.3.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/id3/test/ID3Test-1.3.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/id3/test/README.md b/media/module/id3/test/README.md
index 7fd8901..7a12124 100644
--- a/media/module/id3/test/README.md
+++ b/media/module/id3/test/README.md
@@ -22,16 +22,16 @@
adb push ${OUT}/data/nativetest/ID3Test/ID3Test /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/id3/test/ID3Test.zip ).
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/id3/test/ID3Test-1.3.zip).
Download, unzip and push these files into device for testing.
```
-adb push ID3Test /data/local/tmp/
+adb push ID3Test-1.3 /data/local/tmp/
```
usage: ID3Test -P \<path_to_folder\>
```
-adb shell /data/local/tmp/ID3Test -P /data/local/tmp/ID3/
+adb shell /data/local/tmp/ID3Test -P /data/local/tmp/ID3Test-1.3/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/libmediatranscoding/transcoder/benchmark/AndroidTestTemplate.xml b/media/module/libmediatranscoding/transcoder/benchmark/AndroidTestTemplate.xml
index 683f07b..c3d746d 100644
--- a/media/module/libmediatranscoding/transcoder/benchmark/AndroidTestTemplate.xml
+++ b/media/module/libmediatranscoding/transcoder/benchmark/AndroidTestTemplate.xml
@@ -19,7 +19,7 @@
<option name="cleanup" value="false" />
<option name="push-file" key="{MODULE}" value="/data/local/tmp/{MODULE}" />
<option name="push-file"
- key="https://storage.googleapis.com/android_media/frameworks/av/media/libmediatranscoding/transcoder/benchmark/TranscodingBenchmark-1.2.zip?unzip=true"
+ key="https://dl.google.com/android-unittest/media/frameworks/av/media/module/libmediatranscoding/transcoder/benchmark/TranscodingBenchmark-1.2.zip?unzip=true"
value="/data/local/tmp/TranscodingBenchmark/" />
</target_preparer>
diff --git a/media/module/libmediatranscoding/transcoder/benchmark/MediaTranscoderBenchmark.cpp b/media/module/libmediatranscoding/transcoder/benchmark/MediaTranscoderBenchmark.cpp
index 8f8ad4e..86979f4 100644
--- a/media/module/libmediatranscoding/transcoder/benchmark/MediaTranscoderBenchmark.cpp
+++ b/media/module/libmediatranscoding/transcoder/benchmark/MediaTranscoderBenchmark.cpp
@@ -615,7 +615,7 @@
}
void CustomCsvReporter::PrintRunData(const Run& run) {
- if (run.error_occurred) {
+ if (run.skipped) {
return;
}
std::ostream& Out = GetOutputStream();
diff --git a/media/module/metadatautils/test/DynamicConfig.xml b/media/module/metadatautils/test/DynamicConfig.xml
index 9d80bf3..569626c 100644
--- a/media/module/metadatautils/test/DynamicConfig.xml
+++ b/media/module/metadatautils/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/tests/metadatautils/MetaDataUtilsTestRes-1.1.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/metadatautils/test/MetaDataUtilsTestRes-1.1.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/metadatautils/test/README.md b/media/module/metadatautils/test/README.md
index 0862a07..a081da8 100644
--- a/media/module/metadatautils/test/README.md
+++ b/media/module/metadatautils/test/README.md
@@ -22,15 +22,15 @@
adb push ${OUT}/data/nativetest/MetaDataUtilsTest/MetaDataUtilsTest /data/local/tmp/
```
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/tests/metadatautils/MetaDataUtilsTestRes-1.0.zip). Download, unzip and push these files into device for testing.
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/metadatautils/test/MetaDataUtilsTestRes-1.1.zip). Download, unzip and push these files into device for testing.
```
-adb push MetaDataUtilsTestRes-1.0 /data/local/tmp/
+adb push MetaDataUtilsTestRes-1.1 /data/local/tmp/
```
usage: MetaDataUtilsTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/MetaDataUtilsTest -P /data/local/tmp/MetaDataUtilsTestRes-1.0/
+adb shell /data/local/tmp/MetaDataUtilsTest -P /data/local/tmp/MetaDataUtilsTestRes-1.1/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/module/mpeg2ts/test/DynamicConfig.xml b/media/module/mpeg2ts/test/DynamicConfig.xml
index 017a3c6..0db467a 100644
--- a/media/module/mpeg2ts/test/DynamicConfig.xml
+++ b/media/module/mpeg2ts/test/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/mpeg2ts/test/Mpeg2tsUnitTest-1.0.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/module/mpeg2ts/test/Mpeg2tsUnitTest-1.0.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/module/mpeg2ts/test/README.md b/media/module/mpeg2ts/test/README.md
index 237ce72..3b0221b 100644
--- a/media/module/mpeg2ts/test/README.md
+++ b/media/module/mpeg2ts/test/README.md
@@ -20,16 +20,16 @@
adb push ${OUT}/data/nativetest/Mpeg2tsUnitTest/Mpeg2tsUnitTest /data/local/tmp/
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/mpeg2ts/test/Mpeg2tsUnitTest.zip ).
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/module/mpeg2ts/test/Mpeg2tsUnitTest-1.0.zip).
Download, unzip and push these files into device for testing.
```
-adb push Mpeg2tsUnitTestRes/. /data/local/tmp/
+adb push Mpeg2tsUnitTest-1.0 /data/local/tmp/
```
usage: Mpeg2tsUnitTest -P \<path_to_folder\>
```
-adb shell /data/local/tmp/Mpeg2tsUnitTest -P /data/local/tmp/Mpeg2tsUnitTestRes/
+adb shell /data/local/tmp/Mpeg2tsUnitTest -P /data/local/tmp/Mpeg2tsUnitTest-1.0/
```
Alternatively, the test can also be run using atest command.
diff --git a/media/mtp/tests/MtpFuzzer/MtpMockDatabase.cpp b/media/mtp/tests/MtpFuzzer/MtpMockDatabase.cpp
index 8aafe33..6377195 100644
--- a/media/mtp/tests/MtpFuzzer/MtpMockDatabase.cpp
+++ b/media/mtp/tests/MtpFuzzer/MtpMockDatabase.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
@@ -40,7 +41,7 @@
}
void MtpMockDatabase::addObject(MtpObjectInfo* info) {
- assert(hasStorage(info->storageID));
+ assert(hasStorage(info->mStorageID));
// we take ownership
mObjects.push_back(info);
diff --git a/media/mtp/tests/MtpFuzzer/mtp_data_packet_fuzzer.cpp b/media/mtp/tests/MtpFuzzer/mtp_data_packet_fuzzer.cpp
index 83c6076..635c7a4 100644
--- a/media/mtp/tests/MtpFuzzer/mtp_data_packet_fuzzer.cpp
+++ b/media/mtp/tests/MtpFuzzer/mtp_data_packet_fuzzer.cpp
@@ -17,6 +17,7 @@
#include <MtpDataPacket.h>
#include <MtpDevHandle.h>
#include <MtpPacketFuzzerUtils.h>
+#include <functional>
#include <fuzzer/FuzzedDataProvider.h>
#include <utils/String16.h>
diff --git a/media/mtp/tests/MtpFuzzer/mtp_device_fuzzer.cpp b/media/mtp/tests/MtpFuzzer/mtp_device_fuzzer.cpp
index c32d28a..d34eae0 100644
--- a/media/mtp/tests/MtpFuzzer/mtp_device_fuzzer.cpp
+++ b/media/mtp/tests/MtpFuzzer/mtp_device_fuzzer.cpp
@@ -23,6 +23,7 @@
#include <MtpStringBuffer.h>
#include <android-base/unique_fd.h>
#include <fcntl.h>
+#include <functional>
#include <fuzzer/FuzzedDataProvider.h>
#include <linux/usb/ch9.h>
#include <sys/mman.h>
diff --git a/media/mtp/tests/MtpFuzzer/mtp_event_packet_fuzzer.cpp b/media/mtp/tests/MtpFuzzer/mtp_event_packet_fuzzer.cpp
index 3bd3be2..c00b4ca 100644
--- a/media/mtp/tests/MtpFuzzer/mtp_event_packet_fuzzer.cpp
+++ b/media/mtp/tests/MtpFuzzer/mtp_event_packet_fuzzer.cpp
@@ -17,6 +17,7 @@
#include <MtpDevHandle.h>
#include <MtpEventPacket.h>
#include <MtpPacketFuzzerUtils.h>
+#include <functional>
#include <fuzzer/FuzzedDataProvider.h>
using namespace android;
diff --git a/media/mtp/tests/MtpFuzzer/mtp_packet_fuzzer.cpp b/media/mtp/tests/MtpFuzzer/mtp_packet_fuzzer.cpp
index e4df321..d1836e7 100644
--- a/media/mtp/tests/MtpFuzzer/mtp_packet_fuzzer.cpp
+++ b/media/mtp/tests/MtpFuzzer/mtp_packet_fuzzer.cpp
@@ -17,6 +17,7 @@
#include <MtpDevHandle.h>
#include <MtpPacket.h>
#include <MtpPacketFuzzerUtils.h>
+#include <functional>
#include <fuzzer/FuzzedDataProvider.h>
#include <mtp.h>
diff --git a/media/mtp/tests/MtpFuzzer/mtp_property_fuzzer.cpp b/media/mtp/tests/MtpFuzzer/mtp_property_fuzzer.cpp
index 6300256..7a657c0 100644
--- a/media/mtp/tests/MtpFuzzer/mtp_property_fuzzer.cpp
+++ b/media/mtp/tests/MtpFuzzer/mtp_property_fuzzer.cpp
@@ -18,6 +18,7 @@
#include <MtpDevHandle.h>
#include <MtpPacketFuzzerUtils.h>
#include <MtpProperty.h>
+#include <functional>
#include <fuzzer/FuzzedDataProvider.h>
#include <utils/String16.h>
diff --git a/media/mtp/tests/MtpFuzzer/mtp_request_packet_fuzzer.cpp b/media/mtp/tests/MtpFuzzer/mtp_request_packet_fuzzer.cpp
index 19fbc5b..3b2fae2 100644
--- a/media/mtp/tests/MtpFuzzer/mtp_request_packet_fuzzer.cpp
+++ b/media/mtp/tests/MtpFuzzer/mtp_request_packet_fuzzer.cpp
@@ -17,8 +17,9 @@
#include <MtpDevHandle.h>
#include <MtpPacketFuzzerUtils.h>
#include <MtpRequestPacket.h>
-#include <fuzzer/FuzzedDataProvider.h>
#include <fstream>
+#include <functional>
+#include <fuzzer/FuzzedDataProvider.h>
using namespace android;
diff --git a/media/mtp/tests/MtpFuzzer/mtp_response_packet_fuzzer.cpp b/media/mtp/tests/MtpFuzzer/mtp_response_packet_fuzzer.cpp
index 697785f..a841d2f 100644
--- a/media/mtp/tests/MtpFuzzer/mtp_response_packet_fuzzer.cpp
+++ b/media/mtp/tests/MtpFuzzer/mtp_response_packet_fuzzer.cpp
@@ -17,6 +17,7 @@
#include <MtpDevHandle.h>
#include <MtpPacketFuzzerUtils.h>
#include <MtpResponsePacket.h>
+#include <functional>
#include <fuzzer/FuzzedDataProvider.h>
using namespace android;
diff --git a/media/ndk/NdkMediaCodec.cpp b/media/ndk/NdkMediaCodec.cpp
index ed31c02..e422809 100644
--- a/media/ndk/NdkMediaCodec.cpp
+++ b/media/ndk/NdkMediaCodec.cpp
@@ -668,7 +668,7 @@
if (out_size != NULL) {
*out_size = abuf->capacity();
}
- return abuf->data();
+ return abuf->base();
}
android::Vector<android::sp<android::MediaCodecBuffer> > abufs;
@@ -685,7 +685,7 @@
if (out_size != NULL) {
*out_size = abufs[idx]->capacity();
}
- return abufs[idx]->data();
+ return abufs[idx]->base();
}
ALOGE("couldn't get input buffers");
return NULL;
@@ -703,7 +703,7 @@
if (out_size != NULL) {
*out_size = abuf->capacity();
}
- return abuf->data();
+ return abuf->base();
}
android::Vector<android::sp<android::MediaCodecBuffer> > abufs;
@@ -716,7 +716,7 @@
if (out_size != NULL) {
*out_size = abufs[idx]->capacity();
}
- return abufs[idx]->data();
+ return abufs[idx]->base();
}
ALOGE("couldn't get output buffers");
return NULL;
diff --git a/media/tests/benchmark/MediaBenchmarkTest/DynamicConfig.xml b/media/tests/benchmark/MediaBenchmarkTest/DynamicConfig.xml
index 1278f29..0329ebb 100644
--- a/media/tests/benchmark/MediaBenchmarkTest/DynamicConfig.xml
+++ b/media/tests/benchmark/MediaBenchmarkTest/DynamicConfig.xml
@@ -15,6 +15,6 @@
<dynamicConfig>
<entry key="media_files_url">
- <value>https://storage.googleapis.com/android_media/frameworks/av/media/tests/benchmark/MediaBenchmark-1.1.zip</value>
+ <value>https://dl.google.com/android-unittest/media/frameworks/av/media/tests/benchmark/MediaBenchmarkTest/MediaBenchmark-1.1.zip</value>
</entry>
</dynamicConfig>
diff --git a/media/tests/benchmark/README.md b/media/tests/benchmark/README.md
index 047c289..a6897b0 100644
--- a/media/tests/benchmark/README.md
+++ b/media/tests/benchmark/README.md
@@ -11,13 +11,13 @@
```
# Resources
-The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/tests/benchmark/MediaBenchmark.zip)
+The resource file for the tests is taken from [here](https://dl.google.com/android-unittest/media/frameworks/av/media/tests/benchmark/MediaBenchmarkTest/MediaBenchmark-1.1.zip)
Download the MediaBenchmark.zip file, unzip and push it to /data/local/tmp/ on the device.
```
-unzip MediaBenchmark.zip
-adb push MediaBenchmark /data/local/tmp/MediaBenchmark/res/
+unzip MediaBenchmark-1.1.zip
+adb push MediaBenchmark-1.1 /data/local/tmp/MediaBenchmark/res/
```
The resource files are assumed to be at /data/local/tmp/MediaBenchmark/res/. You can use a different location, but you have to modify the rest of the instructions to replace /data/local/tmp/MediaBenchmark/res/ with wherever you chose to put the files.