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

Commit 1afd1dd9 authored by Yifei Zhang's avatar Yifei Zhang Committed by Android (Google) Code Review
Browse files

Merge "av: replace getService with waitForService"

parents 5e6d0cbf ff21209b
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -103,7 +103,6 @@ status_t CameraStatus::readFromParcel(const android::Parcel* parcel) {

namespace {
    sp<::android::hardware::ICameraService> gCameraService;
    const int                 kCameraServicePollDelay = 500000; // 0.5s
    const char*               kCameraServiceName      = "media.camera";

    Mutex                     gLock;
@@ -141,14 +140,10 @@ const sp<::android::hardware::ICameraService> CameraBase<TCam, TCamTraits>::getC

        sp<IServiceManager> sm = defaultServiceManager();
        sp<IBinder> binder;
        do {
            binder = sm->getService(String16(kCameraServiceName));
            if (binder != 0) {
                break;
        binder = sm->waitForService(String16(kCameraServiceName));
        if (binder == nullptr) {
            return nullptr;
        }
            ALOGW("CameraService not published, waiting...");
            usleep(kCameraServicePollDelay);
        } while(true);
        if (gDeathNotifier == NULL) {
            gDeathNotifier = new DeathNotifier();
        }
+4 −10
Original line number Diff line number Diff line
@@ -38,16 +38,10 @@ IMediaDeathNotifier::getMediaPlayerService()
    Mutex::Autolock _l(sServiceLock);
    if (sMediaPlayerService == 0) {
        sp<IServiceManager> sm = defaultServiceManager();
        sp<IBinder> binder;
        do {
            binder = sm->getService(String16("media.player"));
            if (binder != 0) {
                break;
        sp<IBinder> binder = sm->waitForService(String16("media.player"));
        if (binder == nullptr) {
            return nullptr;
        }
            ALOGW("Media player service not published, waiting...");
            usleep(500000); // 0.5 s
        } while (true);

        if (sDeathNotifier == NULL) {
            sDeathNotifier = new DeathNotifier();
        }
+4 −8
Original line number Diff line number Diff line
@@ -41,14 +41,10 @@ const sp<IMediaPlayerService> MediaMetadataRetriever::getService()
    if (sService == 0) {
        sp<IServiceManager> sm = defaultServiceManager();
        sp<IBinder> binder;
        do {
            binder = sm->getService(String16("media.player"));
            if (binder != 0) {
                break;
            }
            ALOGW("MediaPlayerService not published, waiting...");
            usleep(500000); // 0.5 s
        } while (true);
        binder = sm->waitForService(String16("media.player"));
        if (binder == nullptr) {
            return nullptr;
        }
        if (sDeathNotifier == NULL) {
            sDeathNotifier = new DeathNotifier();
        }