mediaresourcemanager: handle the case when there's no client holding resource with the same type
Bug: 21171205
Change-Id: Id4aa6ccc7ee7daba25fd295399235c5b463ccd83
diff --git a/services/mediaresourcemanager/ResourceManagerService.h b/services/mediaresourcemanager/ResourceManagerService.h
index 0d9d878..ca218fc 100644
--- a/services/mediaresourcemanager/ResourceManagerService.h
+++ b/services/mediaresourcemanager/ResourceManagerService.h
@@ -65,6 +65,9 @@
virtual void removeResource(int64_t clientId);
+ // Tries to reclaim resource from processes with lower priority than the calling process
+ // according to the requested resources.
+ // Returns true if any resource has been reclaimed, otherwise returns false.
virtual bool reclaimResource(int callingPid, const Vector<MediaResource> &resources);
protected:
@@ -95,6 +98,11 @@
bool isCallingPriorityHigher_l(int callingPid, int pid);
+ // A helper function basically calls getLowestPriorityBiggestClient_l and add the result client
+ // to the given Vector.
+ void getClientForResource_l(
+ int callingPid, const MediaResource *res, Vector<sp<IResourceManagerClient>> *clients);
+
mutable Mutex mLock;
sp<ProcessInfoInterface> mProcessInfo;
sp<ServiceLog> mServiceLog;