Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d35f9921 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "MediaMetadataRetriever: add static lock for image extraction" into main...

Merge "MediaMetadataRetriever: add static lock for image extraction" into main am: a90d4e8b am: 455ddffc

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/3281494



Change-Id: I4ca1c6f4d3252f3cf11f4a7ceb8b3bf5adf48a88
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 81ff45af 455ddffc
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -122,6 +122,10 @@ private:
    static sp<IMediaPlayerService>            sService;
    static sp<IMediaPlayerService>            sService;


    Mutex                                     mLock;
    Mutex                                     mLock;
    // Static lock was added to the client in order to consume at most
    // one service thread from image extraction requests of the same
    // client process(See also b/21277449).
    static Mutex                              sLock;
    sp<IMediaMetadataRetriever>               mRetriever;
    sp<IMediaMetadataRetriever>               mRetriever;


};
};
+6 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,8 @@ Mutex MediaMetadataRetriever::sServiceLock;
sp<IMediaPlayerService> MediaMetadataRetriever::sService;
sp<IMediaPlayerService> MediaMetadataRetriever::sService;
sp<MediaMetadataRetriever::DeathNotifier> MediaMetadataRetriever::sDeathNotifier;
sp<MediaMetadataRetriever::DeathNotifier> MediaMetadataRetriever::sDeathNotifier;


Mutex MediaMetadataRetriever::sLock;

const sp<IMediaPlayerService> MediaMetadataRetriever::getService()
const sp<IMediaPlayerService> MediaMetadataRetriever::getService()
{
{
    Mutex::Autolock lock(sServiceLock);
    Mutex::Autolock lock(sServiceLock);
@@ -143,6 +145,7 @@ sp<IMemory> MediaMetadataRetriever::getFrameAtTime(
    ALOGV("getFrameAtTime: time(%" PRId64 " us) option(%d) colorFormat(%d) metaOnly(%d)",
    ALOGV("getFrameAtTime: time(%" PRId64 " us) option(%d) colorFormat(%d) metaOnly(%d)",
            timeUs, option, colorFormat, metaOnly);
            timeUs, option, colorFormat, metaOnly);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _gLock(sLock);
    if (mRetriever == 0) {
    if (mRetriever == 0) {
        ALOGE("retriever is not initialized");
        ALOGE("retriever is not initialized");
        return NULL;
        return NULL;
@@ -155,6 +158,7 @@ sp<IMemory> MediaMetadataRetriever::getImageAtIndex(
    ALOGV("getImageAtIndex: index(%d) colorFormat(%d) metaOnly(%d) thumbnail(%d)",
    ALOGV("getImageAtIndex: index(%d) colorFormat(%d) metaOnly(%d) thumbnail(%d)",
            index, colorFormat, metaOnly, thumbnail);
            index, colorFormat, metaOnly, thumbnail);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _gLock(sLock);
    if (mRetriever == 0) {
    if (mRetriever == 0) {
        ALOGE("retriever is not initialized");
        ALOGE("retriever is not initialized");
        return NULL;
        return NULL;
@@ -167,6 +171,7 @@ sp<IMemory> MediaMetadataRetriever::getImageRectAtIndex(
    ALOGV("getImageRectAtIndex: index(%d) colorFormat(%d) rect {%d, %d, %d, %d}",
    ALOGV("getImageRectAtIndex: index(%d) colorFormat(%d) rect {%d, %d, %d, %d}",
            index, colorFormat, left, top, right, bottom);
            index, colorFormat, left, top, right, bottom);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _gLock(sLock);
    if (mRetriever == 0) {
    if (mRetriever == 0) {
        ALOGE("retriever is not initialized");
        ALOGE("retriever is not initialized");
        return NULL;
        return NULL;
@@ -180,6 +185,7 @@ sp<IMemory> MediaMetadataRetriever::getFrameAtIndex(
    ALOGV("getFrameAtIndex: index(%d), colorFormat(%d) metaOnly(%d)",
    ALOGV("getFrameAtIndex: index(%d), colorFormat(%d) metaOnly(%d)",
            index, colorFormat, metaOnly);
            index, colorFormat, metaOnly);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _l(mLock);
    Mutex::Autolock _gLock(sLock);
    if (mRetriever == 0) {
    if (mRetriever == 0) {
        ALOGE("retriever is not initialized");
        ALOGE("retriever is not initialized");
        return NULL;
        return NULL;