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

Commit e76e069b authored by Paul Wang's avatar Paul Wang Committed by Android (Google) Code Review
Browse files

Merge "Replace getService with waitForService"

parents 777ee0ab bcf95f67
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -132,12 +132,10 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger() {
                binder = gAudioFlingerBinder;
            } else {
                sp<IServiceManager> sm = defaultServiceManager();
                do {
                    binder = sm->getService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME));
                    if (binder != nullptr) break;
                    ALOGW("AudioFlinger not published, waiting...");
                    usleep(500000); // 0.5 s
                } while (true);
                binder = sm->waitForService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME));
                if (binder == nullptr) {
                    return nullptr;
                }
            }
            binder->linkToDeath(gAudioFlingerClient);
            const auto afs = interface_cast<media::IAudioFlingerService>(binder);
@@ -864,14 +862,10 @@ const sp<IAudioPolicyService> AudioSystem::get_audio_policy_service() {
        Mutex::Autolock _l(gLockAPS);
        if (gAudioPolicyService == 0) {
            sp<IServiceManager> sm = defaultServiceManager();
            sp<IBinder> binder;
            do {
                binder = sm->getService(String16("media.audio_policy"));
                if (binder != 0)
                    break;
                ALOGW("AudioPolicyService not published, waiting...");
                usleep(500000); // 0.5 s
            } while (true);
            sp<IBinder> binder = sm->waitForService(String16("media.audio_policy"));
            if (binder == nullptr) {
                return nullptr;
            }
            if (gAudioPolicyServiceClient == NULL) {
                gAudioPolicyServiceClient = new AudioPolicyServiceClient();
            }
@@ -2078,8 +2072,7 @@ status_t AudioSystem::getHwOffloadFormatsSupportedForBluetoothMedia(
        return BAD_VALUE;
    }

    const sp<IAudioPolicyService>
            & aps = AudioSystem::get_audio_policy_service();
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return PERMISSION_DENIED;

    std::vector<AudioFormatDescription> formatsAidl;