INNER CODE UNIT · C++
wrappedByteBuffer
OxygenCobalt/Auxio · musikr/src/main/cpp/JInputStream.cpp:62
jobject wrappedByteBuffer = env->NewDirectByteBuffer(buf.data(),
buf.size());
if (wrappedByteBuffer == nullptr) {
throw std::runtime_error("Failed to wrap ByteBuffer");
}
JObjectRef byteBuffer { env, wrappedByteBuffer };
jint read = env->CallIntMethod(jInputStream, jInputStreamReadBlockMethod,
*byteBuffer);
return read;
}
TagLib::ByteVector JInputStream::readBlock(size_t length) {
// We have to invert the buffer allocation here
TagLib::ByteVector buf { static_cast<unsigned int>(length), 0 };
jint read = readBlockImpl(buf);
if (read >= 0) {
buf.resize(read);
return buf;