liboverlay: free rotator memory in a new function
- move freeing roator memory to a new function - In queueBuffer, updateDataChannel, if memory allocation fails for the rotator, free the previous allocated memory CRs-fixed: 353156 (cherry picked from commit 97de5b6dc39a8706ba90f4e8b191b18418cb0191) Change-Id: Icc774b67678426ea7ba43520b1186ea148ce1281
This commit is contained in:
parent
d9420e6d78
commit
d8abd6c8dc
@ -1841,7 +1841,8 @@ bool OverlayDataChannel::mapRotatorMemory(int num_buffers, bool uiChannel, int r
|
||||
//XXX: getInstance(false) implies that it should only
|
||||
// use the kernel allocator. Change it to something
|
||||
// more descriptive later.
|
||||
android::sp<gralloc::IAllocController> allocController = gralloc::IAllocController::getInstance(false);
|
||||
android::sp<gralloc::IAllocController> allocController =
|
||||
gralloc::IAllocController::getInstance(false);
|
||||
int err = allocController->allocate(data, allocFlags, 0);
|
||||
if(err) {
|
||||
reportError("Cant allocate rotatory memory");
|
||||
@ -1899,12 +1900,7 @@ bool OverlayDataChannel::closeDataChannel() {
|
||||
return true;
|
||||
|
||||
if (!mNoRot && mRotFD > 0) {
|
||||
//XXX: getInstance(false) implies that it should only
|
||||
// use the kernel allocator. Change it to something
|
||||
// more descriptive later.
|
||||
android::sp<gralloc::IAllocController> allocController = gralloc::IAllocController::getInstance(false);
|
||||
sp<IMemAlloc> memalloc = allocController->getAllocator(mBufferType);
|
||||
memalloc->free_buffer(mPmemAddr, mPmemOffset * mNumBuffers, 0, mPmemFD);
|
||||
freeRotatorMemory(mPmemAddr, mPmemOffset, mPmemFD);
|
||||
close(mPmemFD);
|
||||
mPmemFD = -1;
|
||||
close(mRotFD);
|
||||
@ -1922,6 +1918,23 @@ bool OverlayDataChannel::closeDataChannel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OverlayDataChannel::freeRotatorMemory(void* pmemAddr, uint32_t
|
||||
pmemOffset, int pmemFD) {
|
||||
bool ret = true;
|
||||
if(pmemFD != -1 && pmemAddr != MAP_FAILED) {
|
||||
//XXX: getInstance(false) implies that it should only
|
||||
// use the kernel allocator. Change it to something
|
||||
// more descriptive later.
|
||||
android::sp<gralloc::IAllocController> allocController =
|
||||
gralloc::IAllocController::getInstance(false);
|
||||
sp<IMemAlloc> memalloc = allocController->getAllocator(mBufferType);
|
||||
memalloc->free_buffer(pmemAddr, pmemOffset * mNumBuffers, 0, pmemFD);
|
||||
}
|
||||
else
|
||||
ret = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool OverlayDataChannel::setFd(int fd) {
|
||||
mOvData.data.memory_id = fd;
|
||||
return true;
|
||||
@ -1948,6 +1961,8 @@ bool OverlayDataChannel::queueBuffer(uint32_t offset) {
|
||||
result = mapRotatorMemory(mNumBuffers, 0, UPDATE_REQUEST);
|
||||
if (!result) {
|
||||
LOGE("queueBuffer: mapRotatorMemory failed");
|
||||
// free the oldPmemAddr if any
|
||||
freeRotatorMemory(oldPmemAddr, oldPmemOffset, oldPmemFD);
|
||||
return false;
|
||||
}
|
||||
mUpdateDataChannel = false;
|
||||
@ -1957,15 +1972,7 @@ bool OverlayDataChannel::queueBuffer(uint32_t offset) {
|
||||
result = queue(offset);
|
||||
|
||||
// Unmap the old PMEM memory after the queueBuffer has returned
|
||||
if (oldPmemFD != -1 && oldPmemAddr != MAP_FAILED) {
|
||||
//XXX: getInstance(false) implies that it should only
|
||||
// use the kernel allocator. Change it to something
|
||||
// more descriptive later.
|
||||
android::sp<gralloc::IAllocController> allocController = gralloc::IAllocController::getInstance(false);
|
||||
sp<IMemAlloc> memalloc = allocController->getAllocator(mBufferType);
|
||||
memalloc->free_buffer(oldPmemAddr, oldPmemOffset * mNumBuffers, 0, oldPmemFD);
|
||||
oldPmemFD = -1;
|
||||
}
|
||||
freeRotatorMemory(oldPmemAddr, oldPmemOffset, oldPmemFD);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -367,6 +367,7 @@ class OverlayDataChannel {
|
||||
bool openDevices(int fbnum = -1, bool uichannel = false, int num_buffers = 2);
|
||||
bool mapRotatorMemory(int num_buffers, bool uiChannel, int requestType);
|
||||
bool queue(uint32_t offset);
|
||||
bool freeRotatorMemory(void *pmemAddr, uint32_t pmemOffset, int pmemFD);
|
||||
|
||||
public:
|
||||
OverlayDataChannel();
|
||||
|
Loading…
Reference in New Issue
Block a user