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

Commit fbf3c35f authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Recover from DEAD_OBJECT in AudioSystem::initStreamVolume" into tm-dev

parents 499caa57 ec3d5799
Loading
Loading
Loading
Loading
+15 −9
Original line number Original line Diff line number Diff line
@@ -832,6 +832,11 @@ const sp<IAudioPolicyService> AudioSystem::get_audio_policy_service() {
    return ap;
    return ap;
}
}


void AudioSystem::clearAudioPolicyService() {
    Mutex::Autolock _l(gLockAPS);
    gAudioPolicyService.clear();
}

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


void AudioSystem::onNewAudioModulesAvailable() {
void AudioSystem::onNewAudioModulesAvailable() {
@@ -1150,8 +1155,15 @@ status_t AudioSystem::initStreamVolume(audio_stream_type_t stream,
            legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
            legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
    int32_t indexMinAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(indexMin));
    int32_t indexMinAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(indexMin));
    int32_t indexMaxAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(indexMax));
    int32_t indexMaxAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(indexMax));
    return statusTFromBinderStatus(
    status_t status = statusTFromBinderStatus(
            aps->initStreamVolume(streamAidl, indexMinAidl, indexMaxAidl));
            aps->initStreamVolume(streamAidl, indexMinAidl, indexMaxAidl));
    if (status == DEAD_OBJECT) {
        // This is a critical operation since w/o proper stream volumes no audio
        // will be heard. Make sure we recover from a failure in any case.
        ALOGE("Received DEAD_OBJECT from APS, clearing the client");
        clearAudioPolicyService();
    }
    return status;
}
}


status_t AudioSystem::setStreamVolumeIndex(audio_stream_type_t stream,
status_t AudioSystem::setStreamVolumeIndex(audio_stream_type_t stream,
@@ -1412,10 +1424,7 @@ void AudioSystem::clearAudioConfigCache() {
        }
        }
        gAudioFlinger.clear();
        gAudioFlinger.clear();
    }
    }
    {
    clearAudioPolicyService();
        Mutex::Autolock _l(gLockAPS);
        gAudioPolicyService.clear();
    }
}
}


status_t AudioSystem::setSupportedSystemUsages(const std::vector<audio_usage_t>& systemUsages) {
status_t AudioSystem::setSupportedSystemUsages(const std::vector<audio_usage_t>& systemUsages) {
@@ -2603,10 +2612,7 @@ void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who __
            mAudioVolumeGroupCallback[i]->onServiceDied();
            mAudioVolumeGroupCallback[i]->onServiceDied();
        }
        }
    }
    }
    {
    AudioSystem::clearAudioPolicyService();
        Mutex::Autolock _l(gLockAPS);
        AudioSystem::gAudioPolicyService.clear();
    }


    ALOGW("AudioPolicyService server died!");
    ALOGW("AudioPolicyService server died!");
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -350,6 +350,7 @@ public:
    static void clearAudioConfigCache();
    static void clearAudioConfigCache();


    static const sp<media::IAudioPolicyService> get_audio_policy_service();
    static const sp<media::IAudioPolicyService> get_audio_policy_service();
    static void clearAudioPolicyService();


    // helpers for android.media.AudioManager.getProperty(), see description there for meaning
    // helpers for android.media.AudioManager.getProperty(), see description there for meaning
    static uint32_t getPrimaryOutputSamplingRate();
    static uint32_t getPrimaryOutputSamplingRate();