Merge "gralloc1: Do not do early validation on Release"
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
commit
1c0e1bffdd
@@ -192,7 +192,13 @@ void BufferManager::CreateSharedHandle(buffer_handle_t inbuffer, const BufferDes
|
|||||||
|
|
||||||
gralloc1_error_t BufferManager::FreeBuffer(std::shared_ptr<Buffer> buf) {
|
gralloc1_error_t BufferManager::FreeBuffer(std::shared_ptr<Buffer> buf) {
|
||||||
auto hnd = buf->handle;
|
auto hnd = buf->handle;
|
||||||
ALOGD_IF(DEBUG, "FreeBuffer handle:%p id: %" PRIu64, hnd, hnd->id);
|
ALOGD_IF(DEBUG, "FreeBuffer handle:%p", hnd);
|
||||||
|
|
||||||
|
if (private_handle_t::validate(hnd) != 0) {
|
||||||
|
ALOGE("FreeBuffer: Invalid handle: %p", hnd);
|
||||||
|
return GRALLOC1_ERROR_BAD_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
if (allocator_->FreeBuffer(reinterpret_cast<void *>(hnd->base), hnd->size, hnd->offset,
|
if (allocator_->FreeBuffer(reinterpret_cast<void *>(hnd->base), hnd->size, hnd->offset,
|
||||||
hnd->fd, buf->ion_handle_main) != 0) {
|
hnd->fd, buf->ion_handle_main) != 0) {
|
||||||
return GRALLOC1_ERROR_BAD_HANDLE;
|
return GRALLOC1_ERROR_BAD_HANDLE;
|
||||||
@@ -277,7 +283,7 @@ gralloc1_error_t BufferManager::RetainBuffer(private_handle_t const *hnd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gralloc1_error_t BufferManager::ReleaseBuffer(private_handle_t const *hnd) {
|
gralloc1_error_t BufferManager::ReleaseBuffer(private_handle_t const *hnd) {
|
||||||
ALOGD_IF(DEBUG, "Release buffer handle:%p id: %" PRIu64, hnd, hnd->id);
|
ALOGD_IF(DEBUG, "Release buffer handle:%p", hnd);
|
||||||
std::lock_guard<std::mutex> lock(buffer_lock_);
|
std::lock_guard<std::mutex> lock(buffer_lock_);
|
||||||
auto buf = GetBufferFromHandleLocked(hnd);
|
auto buf = GetBufferFromHandleLocked(hnd);
|
||||||
if (buf == nullptr) {
|
if (buf == nullptr) {
|
||||||
|
|||||||
@@ -392,14 +392,13 @@ gralloc1_error_t GrallocImpl::RetainBuffer(gralloc1_device_t *device, buffer_han
|
|||||||
}
|
}
|
||||||
|
|
||||||
gralloc1_error_t GrallocImpl::ReleaseBuffer(gralloc1_device_t *device, buffer_handle_t buffer) {
|
gralloc1_error_t GrallocImpl::ReleaseBuffer(gralloc1_device_t *device, buffer_handle_t buffer) {
|
||||||
gralloc1_error_t status = CheckDeviceAndHandle(device, buffer);
|
if (!device || !buffer) {
|
||||||
if (status == GRALLOC1_ERROR_NONE) {
|
return GRALLOC1_ERROR_BAD_DESCRIPTOR;
|
||||||
const private_handle_t *hnd = PRIV_HANDLE_CONST(buffer);
|
|
||||||
GrallocImpl const *dev = GRALLOC_IMPL(device);
|
|
||||||
status = dev->buf_mgr_->ReleaseBuffer(hnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
const private_handle_t *hnd = PRIV_HANDLE_CONST(buffer);
|
||||||
|
GrallocImpl const *dev = GRALLOC_IMPL(device);
|
||||||
|
return dev->buf_mgr_->ReleaseBuffer(hnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
gralloc1_error_t GrallocImpl::GetNumFlexPlanes(gralloc1_device_t *device, buffer_handle_t buffer,
|
gralloc1_error_t GrallocImpl::GetNumFlexPlanes(gralloc1_device_t *device, buffer_handle_t buffer,
|
||||||
|
|||||||
Reference in New Issue
Block a user