1 回答

TA貢獻(xiàn)1851條經(jīng)驗 獲得超3個贊
您正在使用針對 32 位優(yōu)化的源代碼:
// Note: The layout and size of the USBFS structures matches that of Linux Kernel 3.2 and 3.14
// for ARM 32 bit. For other environments (X86, 64 bit, future Linux kernels), it might be
// necessary to adjust some values.
雖然 JNA 通常會針對 32 位和 64 位調(diào)整結(jié)構(gòu)映射,但此代碼認(rèn)為 JNA 太慢并手動映射這些偏移量:
// This class is modeled after struct usbdevfs_urb in <linuxKernel>/include/linux/usbdevice_fs.h
// At first I implemented the URB structure directly using com.sun.jna.Structure, but that was extremely slow.
// Therefore byte offsets are now used to access the fields of the structure.
如果您查看結(jié)構(gòu)映射,usbdevfs_urb有 3 個指針字段需要從 4 字節(jié)偏移量調(diào)整為 8 字節(jié)偏移量。例如,第 5 個字段buffer從 4 個字節(jié)變?yōu)?8 個字節(jié),因此此代碼中斷:
public void setBuffer (Pointer buffer) {
urbBuf.putInt(12, (int)Pointer.nativeValue(buffer)); }
public void setBufferLength (int bufferLength) {
urbBuf.putInt(16, bufferLength); }
特別是,putInt(12, (int) ...)可能應(yīng)該是putLong(12, ...),下一次調(diào)用中的 16 應(yīng)該是 20(依此類推,將 4 添加到剩余的偏移量中。)
最后兩個字段也是 8 字節(jié) vs. 4 字節(jié),所以 andsetUserContext()需要getUserContext()處理long而不是intandurbBaseSize需要從 44 遞增到 52(+4 為buffer,+4 為userContext.
我看到一些其他int變量代表需要變成longs 的內(nèi)存地址。我可能錯過了其他需要的更改。

TA貢獻(xiàn)1827條經(jīng)驗 獲得超9個贊
正如 Peter Stoiber 在這個問題的最后一個答案中所述,存在一個解決這個問題的類:https ://github.com/Peter-St/Android-UVC-Camera/tree/master/app/src/main /java/humer/uvc_camera/UsbIso64
添加回答
舉報