|
|
@ -318,39 +318,42 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_hand |
|
|
|
ALOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, |
|
|
|
ALOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, |
|
|
|
"[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState); |
|
|
|
"[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState); |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_lock(&s_map_lock); |
|
|
|
/* never unmap buffers that were created in this process */ |
|
|
|
if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) { |
|
|
|
if (hnd->pid != getpid()) { |
|
|
|
ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); |
|
|
|
pthread_mutex_lock(&s_map_lock); |
|
|
|
hnd->base = 0; |
|
|
|
if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP) { |
|
|
|
ump_reference_release((ump_handle)hnd->ump_mem_handle); |
|
|
|
ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); |
|
|
|
hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE; |
|
|
|
hnd->base = 0; |
|
|
|
hnd->lockState = 0; |
|
|
|
ump_reference_release((ump_handle)hnd->ump_mem_handle); |
|
|
|
hnd->writeOwner = 0; |
|
|
|
hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE; |
|
|
|
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_IOCTL) { |
|
|
|
hnd->lockState = 0; |
|
|
|
if(hnd->base != 0) |
|
|
|
hnd->writeOwner = 0; |
|
|
|
gralloc_unmap(module, handle); |
|
|
|
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_IOCTL) { |
|
|
|
|
|
|
|
if(hnd->base != 0) |
|
|
|
|
|
|
|
gralloc_unmap(module, handle); |
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&s_map_lock); |
|
|
|
pthread_mutex_unlock(&s_map_lock); |
|
|
|
if (0 < gMemfd) { |
|
|
|
if (0 < gMemfd) { |
|
|
|
close(gMemfd); |
|
|
|
close(gMemfd); |
|
|
|
gMemfd = 0; |
|
|
|
gMemfd = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) { |
|
|
|
|
|
|
|
ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); |
|
|
|
|
|
|
|
ump_reference_release((ump_handle)hnd->ump_mem_handle); |
|
|
|
|
|
|
|
if (hnd->base) |
|
|
|
|
|
|
|
gralloc_unmap(module, handle); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hnd->base = 0; |
|
|
|
|
|
|
|
hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE; |
|
|
|
|
|
|
|
hnd->lockState = 0; |
|
|
|
|
|
|
|
hnd->writeOwner = 0; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ALOGE("unregistering non-UMP buffer not supported"); |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
|
|
|
|
} else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) { |
|
|
|
|
|
|
|
ump_mapped_pointer_release((ump_handle)hnd->ump_mem_handle); |
|
|
|
|
|
|
|
ump_reference_release((ump_handle)hnd->ump_mem_handle); |
|
|
|
|
|
|
|
if (hnd->base) |
|
|
|
|
|
|
|
gralloc_unmap(module, handle); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hnd->base = 0; |
|
|
|
|
|
|
|
hnd->ump_mem_handle = (int)UMP_INVALID_MEMORY_HANDLE; |
|
|
|
|
|
|
|
hnd->lockState = 0; |
|
|
|
|
|
|
|
hnd->writeOwner = 0; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ALOGE("unregistering non-UMP buffer not supported"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&s_map_lock); |
|
|
|
pthread_mutex_unlock(&s_map_lock); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|