MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / Read

Method Read

framework/data_source/ContentDataSource.cpp:79–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79int ContentDataSource::Read(void *buf, size_t nbyte) {
80 JniEnv env{};
81 JNIEnv *pEnv = env.getEnv();
82 if (pEnv == nullptr) {
83 return -EINVAL;
84 }
85
86 jbyteArray buffer = pEnv->NewByteArray((jsize) nbyte);
87 int readSize = (int) pEnv->CallIntMethod(mJContentDataSource, jContentDataSource_read, buffer);
88 if (readSize <= 0) {
89 return readSize;
90 }
91 jboolean isCopy = false;
92 jbyte *jBytes = pEnv->GetByteArrayElements(buffer, &isCopy);
93 memcpy(buf, jBytes, readSize);
94
95 pEnv->ReleaseByteArrayElements(buffer, jBytes, 0);
96 pEnv->DeleteLocalRef(buffer);
97 return readSize;
98}
99void ContentDataSource::Interrupt(bool interrupt) {
100 IDataSource::Interrupt(interrupt);
101}

Callers

nothing calls this directly

Calls 3

getEnvMethod · 0.80
NewByteArrayMethod · 0.45
CallIntMethodMethod · 0.45

Tested by

no test coverage detected