Loading media/libstagefright/MediaCodec.cpp +16 −4 Original line number Diff line number Diff line Loading @@ -186,9 +186,12 @@ static const char *kCodecShapingEnhanced = "android.media.mediacodec.shaped"; // XXX suppress until we get our representation right static bool kEmitHistogram = false; static int64_t getId(IResourceManagerClient const * client) { return (int64_t) client; } static int64_t getId(const std::shared_ptr<IResourceManagerClient> &client) { return (int64_t) client.get(); return getId(client.get()); } static bool isResourceError(status_t err) { Loading @@ -205,12 +208,20 @@ static const C2MemoryUsage kDefaultReadWriteUsage{ //////////////////////////////////////////////////////////////////////////////// struct ResourceManagerClient : public BnResourceManagerClient { explicit ResourceManagerClient(MediaCodec* codec) : mMediaCodec(codec) {} explicit ResourceManagerClient(MediaCodec* codec, int32_t pid) : mMediaCodec(codec), mPid(pid) {} Status reclaimResource(bool* _aidl_return) override { sp<MediaCodec> codec = mMediaCodec.promote(); if (codec == NULL) { // codec is already gone. // Codec is already gone, so remove the resources as well ::ndk::SpAIBinder binder(AServiceManager_getService("media.resource_manager")); std::shared_ptr<IResourceManagerService> service = IResourceManagerService::fromBinder(binder); if (service == nullptr) { ALOGW("MediaCodec::ResourceManagerClient unable to find ResourceManagerService"); } service->removeClient(mPid, getId(this)); *_aidl_return = true; return Status::ok(); } Loading Loading @@ -247,6 +258,7 @@ struct ResourceManagerClient : public BnResourceManagerClient { private: wp<MediaCodec> mMediaCodec; int32_t mPid; DISALLOW_EVIL_CONSTRUCTORS(ResourceManagerClient); }; Loading Loading @@ -820,7 +832,7 @@ MediaCodec::MediaCodec( mGetCodecBase(getCodecBase), mGetCodecInfo(getCodecInfo) { mResourceManagerProxy = new ResourceManagerServiceProxy(pid, uid, ::ndk::SharedRefBase::make<ResourceManagerClient>(this)); ::ndk::SharedRefBase::make<ResourceManagerClient>(this, pid)); if (!mGetCodecBase) { mGetCodecBase = [](const AString &name, const char *owner) { return GetCodecBase(name, owner); Loading services/mediaresourcemanager/ResourceManagerService.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -732,6 +732,7 @@ bool ResourceManagerService::reclaimUnconditionallyFrom( return true; } int failedClientPid = -1; { Mutex::Autolock lock(mLock); bool found = false; Loading @@ -746,11 +747,14 @@ bool ResourceManagerService::reclaimUnconditionallyFrom( } } if (found) { failedClientPid = mMap.keyAt(i); break; } } if (!found) { ALOGV("didn't find failed client"); if (found) { ALOGW("Failed to reclaim resources from client with pid %d", failedClientPid); } else { ALOGW("Failed to reclaim resources from unlocateable client"); } } Loading Loading
media/libstagefright/MediaCodec.cpp +16 −4 Original line number Diff line number Diff line Loading @@ -186,9 +186,12 @@ static const char *kCodecShapingEnhanced = "android.media.mediacodec.shaped"; // XXX suppress until we get our representation right static bool kEmitHistogram = false; static int64_t getId(IResourceManagerClient const * client) { return (int64_t) client; } static int64_t getId(const std::shared_ptr<IResourceManagerClient> &client) { return (int64_t) client.get(); return getId(client.get()); } static bool isResourceError(status_t err) { Loading @@ -205,12 +208,20 @@ static const C2MemoryUsage kDefaultReadWriteUsage{ //////////////////////////////////////////////////////////////////////////////// struct ResourceManagerClient : public BnResourceManagerClient { explicit ResourceManagerClient(MediaCodec* codec) : mMediaCodec(codec) {} explicit ResourceManagerClient(MediaCodec* codec, int32_t pid) : mMediaCodec(codec), mPid(pid) {} Status reclaimResource(bool* _aidl_return) override { sp<MediaCodec> codec = mMediaCodec.promote(); if (codec == NULL) { // codec is already gone. // Codec is already gone, so remove the resources as well ::ndk::SpAIBinder binder(AServiceManager_getService("media.resource_manager")); std::shared_ptr<IResourceManagerService> service = IResourceManagerService::fromBinder(binder); if (service == nullptr) { ALOGW("MediaCodec::ResourceManagerClient unable to find ResourceManagerService"); } service->removeClient(mPid, getId(this)); *_aidl_return = true; return Status::ok(); } Loading Loading @@ -247,6 +258,7 @@ struct ResourceManagerClient : public BnResourceManagerClient { private: wp<MediaCodec> mMediaCodec; int32_t mPid; DISALLOW_EVIL_CONSTRUCTORS(ResourceManagerClient); }; Loading Loading @@ -820,7 +832,7 @@ MediaCodec::MediaCodec( mGetCodecBase(getCodecBase), mGetCodecInfo(getCodecInfo) { mResourceManagerProxy = new ResourceManagerServiceProxy(pid, uid, ::ndk::SharedRefBase::make<ResourceManagerClient>(this)); ::ndk::SharedRefBase::make<ResourceManagerClient>(this, pid)); if (!mGetCodecBase) { mGetCodecBase = [](const AString &name, const char *owner) { return GetCodecBase(name, owner); Loading
services/mediaresourcemanager/ResourceManagerService.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -732,6 +732,7 @@ bool ResourceManagerService::reclaimUnconditionallyFrom( return true; } int failedClientPid = -1; { Mutex::Autolock lock(mLock); bool found = false; Loading @@ -746,11 +747,14 @@ bool ResourceManagerService::reclaimUnconditionallyFrom( } } if (found) { failedClientPid = mMap.keyAt(i); break; } } if (!found) { ALOGV("didn't find failed client"); if (found) { ALOGW("Failed to reclaim resources from client with pid %d", failedClientPid); } else { ALOGW("Failed to reclaim resources from unlocateable client"); } } Loading