Merge "Revert "Crash audioserver if EPIPE (DEAD_OBJECT) is received from the HAL""
diff --git a/media/libaudiohal/ConversionHelperHidl.cpp b/media/libaudiohal/ConversionHelperHidl.cpp
index 1fabfbe..3451eb0 100644
--- a/media/libaudiohal/ConversionHelperHidl.cpp
+++ b/media/libaudiohal/ConversionHelperHidl.cpp
@@ -82,16 +82,9 @@
}
}
-// static
-void ConversionHelperHidl::crashIfHalIsDead(const Status& status) {
- LOG_ALWAYS_FATAL_IF(
- status.transactionError() == DEAD_OBJECT, "HAL server crashed, need to restart");
-}
-
status_t ConversionHelperHidl::processReturn(const char* funcName, const Status& status) {
const status_t st = status.transactionError();
ALOGE_IF(st, "%s %p %s: %s (from rpc)", mClassName, this, funcName, strerror(-st));
- crashIfHalIsDead(status);
return st;
}
@@ -100,7 +93,6 @@
const status_t st = status.isOk() ? analyzeResult(retval) : status.transactionError();
ALOGE_IF(!status.isOk() && st, "%s %p %s: %s (from rpc)",
mClassName, this, funcName, strerror(-st));
- crashIfHalIsDead(status);
return st;
}
diff --git a/media/libaudiohal/ConversionHelperHidl.h b/media/libaudiohal/ConversionHelperHidl.h
index 428daf2..628913a 100644
--- a/media/libaudiohal/ConversionHelperHidl.h
+++ b/media/libaudiohal/ConversionHelperHidl.h
@@ -30,9 +30,6 @@
namespace android {
class ConversionHelperHidl {
- public:
- static void crashIfHalIsDead(const Status& status);
-
protected:
static status_t keysFromHal(const String8& keys, hidl_vec<hidl_string> *hidlKeys);
static status_t parametersFromHal(const String8& kvPairs, hidl_vec<ParameterValue> *hidlParams);
diff --git a/media/libaudiohal/DevicesFactoryHalHidl.cpp b/media/libaudiohal/DevicesFactoryHalHidl.cpp
index efcc089..155b1a8 100644
--- a/media/libaudiohal/DevicesFactoryHalHidl.cpp
+++ b/media/libaudiohal/DevicesFactoryHalHidl.cpp
@@ -22,7 +22,6 @@
#include <android/hardware/audio/2.0/IDevice.h>
#include <utils/Log.h>
-#include "ConversionHelperHidl.h"
#include "DeviceHalHidl.h"
#include "DevicesFactoryHalHidl.h"
@@ -83,7 +82,6 @@
else if (retval == Result::INVALID_ARGUMENTS) return BAD_VALUE;
else return NO_INIT;
}
- ConversionHelperHidl::crashIfHalIsDead(ret.getStatus());
return ret.getStatus().transactionError();
}
diff --git a/media/libaudiohal/EffectHalHidl.cpp b/media/libaudiohal/EffectHalHidl.cpp
index 1cd1997..b508cb5 100644
--- a/media/libaudiohal/EffectHalHidl.cpp
+++ b/media/libaudiohal/EffectHalHidl.cpp
@@ -20,7 +20,6 @@
#include <media/EffectsFactoryApi.h>
#include <utils/Log.h>
-#include "ConversionHelperHidl.h"
#include "EffectHalHidl.h"
#include "HidlUtils.h"
@@ -103,7 +102,6 @@
effectDescriptorToHal(result, pDescriptor);
}
});
- ConversionHelperHidl::crashIfHalIsDead(ret.getStatus());
return ret.getStatus().isOk() ? analyzeResult(retval) : ret.getStatus().transactionError();
}
diff --git a/media/libaudiohal/EffectsFactoryHalHidl.cpp b/media/libaudiohal/EffectsFactoryHalHidl.cpp
index bacbe4e..4f2eef0 100644
--- a/media/libaudiohal/EffectsFactoryHalHidl.cpp
+++ b/media/libaudiohal/EffectsFactoryHalHidl.cpp
@@ -20,7 +20,6 @@
#include <cutils/native_handle.h>
#include <media/EffectsFactoryApi.h>
-#include "ConversionHelperHidl.h"
#include "EffectHalHidl.h"
#include "EffectsFactoryHalHidl.h"
#include "HidlUtils.h"
@@ -64,7 +63,6 @@
return retval == Result::OK ? OK : NO_INIT;
}
mLastDescriptors.resize(0);
- ConversionHelperHidl::crashIfHalIsDead(ret.getStatus());
return ret.getStatus().transactionError();
}
@@ -109,7 +107,6 @@
else if (retval == Result::INVALID_ARGUMENTS) return NAME_NOT_FOUND;
else return NO_INIT;
}
- ConversionHelperHidl::crashIfHalIsDead(ret.getStatus());
return ret.getStatus().transactionError();
}
@@ -133,7 +130,6 @@
else if (retval == Result::INVALID_ARGUMENTS) return NAME_NOT_FOUND;
else return NO_INIT;
}
- ConversionHelperHidl::crashIfHalIsDead(ret.getStatus());
return ret.getStatus().transactionError();
}
@@ -143,7 +139,6 @@
hidlHandle->data[0] = fd;
Return<void> ret = mEffectsFactory->debugDump(hidlHandle);
native_handle_delete(hidlHandle);
- ConversionHelperHidl::crashIfHalIsDead(ret.getStatus());
return ret.getStatus().transactionError();
}
diff --git a/services/radio/RadioHalHidl.cpp b/services/radio/RadioHalHidl.cpp
index 5eb37bd..07cb4d5 100644
--- a/services/radio/RadioHalHidl.cpp
+++ b/services/radio/RadioHalHidl.cpp
@@ -39,11 +39,6 @@
return new RadioHalHidl(classId);
}
-void RadioHalHidl::crashIfHalIsDead(const Status& status) {
- LOG_ALWAYS_FATAL_IF(
- status.transactionError() == DEAD_OBJECT, "HAL server crashed, need to restart");
-}
-
int RadioHalHidl::getProperties(radio_hal_properties_t *properties)
{
ALOGV("%s IN", __FUNCTION__);
@@ -61,7 +56,10 @@
}
});
- crashIfHalIsDead(hidlReturn.getStatus());
+ if (hidlReturn.getStatus().transactionError() == DEAD_OBJECT) {
+ clearService();
+ return -EPIPE;
+ }
if (halResult == Result::OK) {
HidlUtils::convertPropertiesFromHal(properties, &halProperties);
}
@@ -93,7 +91,10 @@
}
});
- crashIfHalIsDead(hidlReturn.getStatus());
+ if (hidlReturn.getStatus().transactionError() == DEAD_OBJECT) {
+ clearService();
+ return -EPIPE;
+ }
if (halResult == Result::OK) {
tunerImpl->setHalTuner(halTuner);
tuner = tunerImpl;
@@ -374,7 +375,6 @@
if (status == DEAD_OBJECT) {
handleHwFailure();
}
- RadioHalHidl::crashIfHalIsDead(status);
return status;
}
diff --git a/services/radio/RadioHalHidl.h b/services/radio/RadioHalHidl.h
index 1657a40..5211ee2 100644
--- a/services/radio/RadioHalHidl.h
+++ b/services/radio/RadioHalHidl.h
@@ -45,8 +45,6 @@
public:
RadioHalHidl(radio_class_t classId);
- static void crashIfHalIsDead(const Status& status);
-
// RadioInterface
virtual int getProperties(radio_hal_properties_t *properties);
virtual int openTuner(const radio_hal_band_config_t *config,
diff --git a/services/soundtrigger/SoundTriggerHalHidl.cpp b/services/soundtrigger/SoundTriggerHalHidl.cpp
index c027799..ecbdec4 100644
--- a/services/soundtrigger/SoundTriggerHalHidl.cpp
+++ b/services/soundtrigger/SoundTriggerHalHidl.cpp
@@ -59,7 +59,9 @@
}
} else {
ret = (int)hidlReturn.getStatus().transactionError();
- crashIfHalIsDead(ret);
+ if (ret == -EPIPE) {
+ clearService();
+ }
}
ALOGI("getProperties ret %d", ret);
return ret;
@@ -133,7 +135,9 @@
} else {
ret = (int)hidlReturn.getStatus().transactionError();
ALOGE("loadSoundModel error %d", ret);
- crashIfHalIsDead(ret);
+ if (ret == -EPIPE) {
+ clearService();
+ }
}
@@ -160,7 +164,9 @@
}
int ret = (int)hidlReturn.getStatus().transactionError();
ALOGE_IF(ret != 0, "unloadSoundModel error %d", ret);
- crashIfHalIsDead(ret);
+ if (ret == -EPIPE) {
+ clearService();
+ }
if (ret == 0) {
ret = hidlReturn;
}
@@ -199,7 +205,9 @@
int ret = (int)hidlReturn.getStatus().transactionError();
ALOGE_IF(ret != 0, "startRecognition error %d", ret);
- crashIfHalIsDead(ret);
+ if (ret == -EPIPE) {
+ clearService();
+ }
if (ret == 0) {
ret = hidlReturn;
}
@@ -227,7 +235,9 @@
int ret = (int)hidlReturn.getStatus().transactionError();
ALOGE_IF(ret != 0, "stopRecognition error %d", ret);
- crashIfHalIsDead(ret);
+ if (ret == -EPIPE) {
+ clearService();
+ }
if (ret == 0) {
ret = hidlReturn;
}
@@ -249,7 +259,9 @@
int ret = (int)hidlReturn.getStatus().transactionError();
ALOGE_IF(ret != 0, "stopAllRecognitions error %d", ret);
- crashIfHalIsDead(ret);
+ if (ret == -EPIPE) {
+ clearService();
+ }
if (ret == 0) {
ret = hidlReturn;
}
@@ -279,9 +291,10 @@
return mISoundTrigger;
}
-void SoundTriggerHalHidl::crashIfHalIsDead(int ret)
+void SoundTriggerHalHidl::clearService()
{
- LOG_ALWAYS_FATAL_IF(ret == -EPIPE, "HAL server crashed, need to restart");
+ AutoMutex lock(mLock);
+ mISoundTrigger = 0;
}
sp<SoundTriggerHalHidl::SoundModel> SoundTriggerHalHidl::getModel(sound_model_handle_t handle)
diff --git a/services/soundtrigger/SoundTriggerHalHidl.h b/services/soundtrigger/SoundTriggerHalHidl.h
index b235e1c..e578dda 100644
--- a/services/soundtrigger/SoundTriggerHalHidl.h
+++ b/services/soundtrigger/SoundTriggerHalHidl.h
@@ -143,7 +143,7 @@
uint32_t nextUniqueId();
sp<ISoundTriggerHw> getService();
- void crashIfHalIsDead(int ret);
+ void clearService();
sp<SoundModel> getModel(sound_model_handle_t handle);
sp<SoundModel> removeModel(sound_model_handle_t handle);