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

Method Read

plugin/BiDataSource.cpp:216–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216int BiDataSource::Read(void *buf, size_t nbyte)
217{
218 if (mCurrent == nullptr)
219 return -EINVAL;
220 int ret = mCurrent->mDataSource->Read(buf, nbyte);
221 if (ret > 0) {
222 filePos += ret;
223 return ret;
224 }
225
226 if (mCurrent->mDataSource->getSpeedLevel() != speedLevel_local || ret < 0) {
227 return ret;
228 }
229
230 // ret == 0
231
232 // local file
233 if (fileSize == 0) {
234 fileSize = getFileSize();
235 if (fileSize <= 0)
236 return 0;
237 }
238
239 if (filePos >= mCurrent->mRange.end) {
240 // change to remote
241 mCurrent = mSources[0].get() == mCurrent ? mSources[1].get() : mSources[0].get();
242 if (!mCurrent->mIsOpened) {
243 ret = mCurrent->mDataSource->Open(0);
244 mCurrent->mIsOpened = true;
245 if (ret < 0)
246 return ret;
247 }
248 ret = static_cast<int>(mCurrent->mDataSource->Seek(filePos, SEEK_SET));
249 if (ret < 0)
250 return ret;
251 ret = mCurrent->mDataSource->Read(buf, nbyte);
252 }
253 if (ret > 0)
254 filePos += ret;
255 return ret;
256}
257
258std::string BiDataSource::GetOption(const std::string &key)
259{

Callers 1

pollMethod · 0.45

Calls 4

getSpeedLevelMethod · 0.80
getMethod · 0.45
OpenMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected