I'm trying to use an Allocation created with the USING_IO_INPUT flag to get images from the camera. I'm setting it up as follows
Type.Builder yuvType = new Type.Builder(mRS, Element.YUV(mRS));
yuvType.setYuvFormat(imageReaderFormat);
yuvType.setX(mCameraWidth).setY(mCameraHeight);
mAllocation = Allocation.createTyped(mRS, yuvType.create(), Allocation
.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_IO_INPUT | Allocation.USAGE_SCRIPT);
mAllocation.setOnBufferAvailableListener(mOnBufferAllocationAvailable);
I'm adding the Allocation surface to a Preview Session, and getting the callbacks to my very simple function
public void onBufferAvailable(Allocation allocation) {
allocation.ioReceive();
//mPixels is properly initialised
allocation.copyTo(mPixels);
}
This setup works on a Nexus 5X, but fails on a Nexus 4 running 5.1.1. When I call allocation.ioReceive()
in the callback, I get a few warnings printed from the driver, and copying from the Allocation to a byte array results in garbage being copied.
W/Adreno-RS: <rsdVendorAllocationUnMapQCOM:394>: NOT Found allocation map for alloc 0xa1761000
W/Adreno-GSL: <gsl_ldd_control:427>: ioctl fd 25 code 0xc01c0915 (IOCTL_KGSL_MAP_USER_MEM) failed: errno 22 Invalid argument
W/Adreno-RS: <rsdVendorAllocationMapQCOM:288>: gsl_memory_map_fd failed -5 hostptr: 0xa0112000 sz: 0 offset: 0 flags: 0x10c0b00 alloc: 0xa1761000
I am running the camera in a background thread, although onBufferAvailable
gets called in the "RSMessageThread".
Is this problem related to the way I am setting the Allocations and the Camera Preview, or is it a bug in the driver?