Sharing memory with Android native app -
i'm trying create shared memory region follows:
jniexport jlong jnicall java_com_test_native_getshortbuffer(jnienv* env, jobject thiz, jint channels, jint size) { int bytes = (int)channels * (int)size * 2; int fd = open("/dev/ashmem", o_creat | o_rdwr | o_direct | o_sync, s_irusr | s_iwusr); if (fd < 0) return errno; // 0 = let os choose start address // last param = starting offset char *data = static_cast<char*>(mmap(null, bytes, prot_read | prot_write, map_shared, fd, 0)); if (data == map_failed) { close(fd); return errno; } return (jlong)data; }
but err 22, einval, says o_flags
incorrect. tried variety of flags, such o_creat | o_rdwr, s_irusr | s_iwusr
, no luck. flags see above came managed pull off (see here).
anyone know i'm doing wrong?
Comments
Post a Comment