gralloc1: Do not delete on close
gralloc device is a singleton, initialize it in the constructor and never close it. CRs-Fixed: 2022072 Change-Id: I216c235e05c5e60a85a9bd91825a47200d0ab8b0
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
065cff7db9
commit
7df1e404ad
@@ -65,10 +65,10 @@ int gralloc_device_open(const struct hw_module_t *module, const char *name, hw_d
|
|||||||
if (!strcmp(name, GRALLOC_HARDWARE_MODULE_ID)) {
|
if (!strcmp(name, GRALLOC_HARDWARE_MODULE_ID)) {
|
||||||
gralloc1::GrallocImpl * /*gralloc1_device_t*/ dev = gralloc1::GrallocImpl::GetInstance(module);
|
gralloc1::GrallocImpl * /*gralloc1_device_t*/ dev = gralloc1::GrallocImpl::GetInstance(module);
|
||||||
*device = reinterpret_cast<hw_device_t *>(dev);
|
*device = reinterpret_cast<hw_device_t *>(dev);
|
||||||
if (dev->Init()) {
|
if (dev) {
|
||||||
status = 0;
|
status = 0;
|
||||||
} else {
|
} else {
|
||||||
ALOGE(" Error in opening gralloc1 device");
|
ALOGE("Fatal error opening gralloc1 device");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
@@ -83,20 +83,20 @@ GrallocImpl::GrallocImpl(const hw_module_t *module) {
|
|||||||
common.close = CloseDevice;
|
common.close = CloseDevice;
|
||||||
getFunction = GetFunction;
|
getFunction = GetFunction;
|
||||||
getCapabilities = GetCapabilities;
|
getCapabilities = GetCapabilities;
|
||||||
|
|
||||||
|
initalized_ = Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GrallocImpl::Init() {
|
bool GrallocImpl::Init() {
|
||||||
buf_mgr_ = BufferManager::GetInstance();
|
buf_mgr_ = BufferManager::GetInstance();
|
||||||
return true;
|
return buf_mgr_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrallocImpl::~GrallocImpl() {
|
GrallocImpl::~GrallocImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int GrallocImpl::CloseDevice(hw_device_t *device) {
|
int GrallocImpl::CloseDevice(hw_device_t *device __unused) {
|
||||||
GrallocImpl *impl = reinterpret_cast<GrallocImpl *>(device);
|
// No-op since the gralloc device is a singleton
|
||||||
delete impl;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ namespace gralloc1 {
|
|||||||
|
|
||||||
class GrallocImpl : public gralloc1_device_t {
|
class GrallocImpl : public gralloc1_device_t {
|
||||||
public:
|
public:
|
||||||
~GrallocImpl();
|
|
||||||
bool Init();
|
|
||||||
static int CloseDevice(hw_device_t *device);
|
static int CloseDevice(hw_device_t *device);
|
||||||
static void GetCapabilities(struct gralloc1_device *device, uint32_t *out_count,
|
static void GetCapabilities(struct gralloc1_device *device, uint32_t *out_count,
|
||||||
int32_t * /*gralloc1_capability_t*/ out_capabilities);
|
int32_t * /*gralloc1_capability_t*/ out_capabilities);
|
||||||
@@ -54,7 +52,11 @@ class GrallocImpl : public gralloc1_device_t {
|
|||||||
|
|
||||||
static GrallocImpl* GetInstance(const struct hw_module_t *module) {
|
static GrallocImpl* GetInstance(const struct hw_module_t *module) {
|
||||||
static GrallocImpl *instance = new GrallocImpl(module);
|
static GrallocImpl *instance = new GrallocImpl(module);
|
||||||
return instance;
|
if (instance->IsInitialized()) {
|
||||||
|
return instance;
|
||||||
|
} else {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -113,7 +115,12 @@ class GrallocImpl : public gralloc1_device_t {
|
|||||||
static gralloc1_error_t Gralloc1Perform(gralloc1_device_t *device, int operation, ...);
|
static gralloc1_error_t Gralloc1Perform(gralloc1_device_t *device, int operation, ...);
|
||||||
|
|
||||||
explicit GrallocImpl(const hw_module_t *module);
|
explicit GrallocImpl(const hw_module_t *module);
|
||||||
|
~GrallocImpl();
|
||||||
|
bool Init();
|
||||||
|
bool IsInitialized() const { return initalized_; }
|
||||||
|
|
||||||
BufferManager *buf_mgr_ = NULL;
|
BufferManager *buf_mgr_ = NULL;
|
||||||
|
bool initalized_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gralloc1
|
} // namespace gralloc1
|
||||||
|
|||||||
Reference in New Issue
Block a user