Loading services/audioflinger/ISchedulingPolicyService.cpp +12 −4 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ #define LOG_TAG "SchedulingPolicyService" #define LOG_TAG "ISchedulingPolicyService" //#define LOG_NDEBUG 0 #include <binder/Parcel.h> Loading Loading @@ -45,9 +45,17 @@ public: data.writeInt32(tid); data.writeInt32(prio); uint32_t flags = asynchronous ? IBinder::FLAG_ONEWAY : 0; remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags); // fail on exception if (reply.readExceptionCode() != 0) return -1; status_t status = remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags); if (status != NO_ERROR) { return status; } if (asynchronous) { return NO_ERROR; } // fail on exception: force binder reconnection if (reply.readExceptionCode() != 0) { return DEAD_OBJECT; } return reply.readInt32(); } }; Loading services/audioflinger/SchedulingPolicyService.cpp +19 −9 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ * limitations under the License. */ #define LOG_TAG "SchedulingPolicyService" //#define LOG_NDEBUG 0 #include <binder/IServiceManager.h> #include <utils/Mutex.h> #include "ISchedulingPolicyService.h" Loading @@ -28,25 +31,32 @@ static Mutex sMutex; int requestPriority(pid_t pid, pid_t tid, int32_t prio, bool asynchronous) { // FIXME merge duplicated code related to service lookup, caching, and error recovery sp<ISchedulingPolicyService> sps; int ret; for (;;) { sMutex.lock(); sps = sSchedulingPolicyService; sp<ISchedulingPolicyService> sps = sSchedulingPolicyService; sMutex.unlock(); if (sps != 0) { break; } if (sps == 0) { sp<IBinder> binder = defaultServiceManager()->checkService(_scheduling_policy); if (binder != 0) { if (binder == 0) { sleep(1); continue; } sps = interface_cast<ISchedulingPolicyService>(binder); sMutex.lock(); sSchedulingPolicyService = sps; sMutex.unlock(); } ret = sps->requestPriority(pid, tid, prio, asynchronous); if (ret != DEAD_OBJECT) { break; } sleep(1); ALOGW("SchedulingPolicyService died"); sMutex.lock(); sSchedulingPolicyService.clear(); sMutex.unlock(); } return sps->requestPriority(pid, tid, prio, asynchronous); return ret; } } // namespace android Loading
services/audioflinger/ISchedulingPolicyService.cpp +12 −4 Original line number Diff line number Diff line Loading @@ -14,7 +14,7 @@ * limitations under the License. */ #define LOG_TAG "SchedulingPolicyService" #define LOG_TAG "ISchedulingPolicyService" //#define LOG_NDEBUG 0 #include <binder/Parcel.h> Loading Loading @@ -45,9 +45,17 @@ public: data.writeInt32(tid); data.writeInt32(prio); uint32_t flags = asynchronous ? IBinder::FLAG_ONEWAY : 0; remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags); // fail on exception if (reply.readExceptionCode() != 0) return -1; status_t status = remote()->transact(REQUEST_PRIORITY_TRANSACTION, data, &reply, flags); if (status != NO_ERROR) { return status; } if (asynchronous) { return NO_ERROR; } // fail on exception: force binder reconnection if (reply.readExceptionCode() != 0) { return DEAD_OBJECT; } return reply.readInt32(); } }; Loading
services/audioflinger/SchedulingPolicyService.cpp +19 −9 Original line number Diff line number Diff line Loading @@ -14,6 +14,9 @@ * limitations under the License. */ #define LOG_TAG "SchedulingPolicyService" //#define LOG_NDEBUG 0 #include <binder/IServiceManager.h> #include <utils/Mutex.h> #include "ISchedulingPolicyService.h" Loading @@ -28,25 +31,32 @@ static Mutex sMutex; int requestPriority(pid_t pid, pid_t tid, int32_t prio, bool asynchronous) { // FIXME merge duplicated code related to service lookup, caching, and error recovery sp<ISchedulingPolicyService> sps; int ret; for (;;) { sMutex.lock(); sps = sSchedulingPolicyService; sp<ISchedulingPolicyService> sps = sSchedulingPolicyService; sMutex.unlock(); if (sps != 0) { break; } if (sps == 0) { sp<IBinder> binder = defaultServiceManager()->checkService(_scheduling_policy); if (binder != 0) { if (binder == 0) { sleep(1); continue; } sps = interface_cast<ISchedulingPolicyService>(binder); sMutex.lock(); sSchedulingPolicyService = sps; sMutex.unlock(); } ret = sps->requestPriority(pid, tid, prio, asynchronous); if (ret != DEAD_OBJECT) { break; } sleep(1); ALOGW("SchedulingPolicyService died"); sMutex.lock(); sSchedulingPolicyService.clear(); sMutex.unlock(); } return sps->requestPriority(pid, tid, prio, asynchronous); return ret; } } // namespace android