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

Method Read

framework/data_source/curl/curl_data_source.cpp:434–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434int CurlDataSource::Read(void *buf, size_t size)
435{
436 int ret = 0;
437
438 if (rangeEnd != INT64_MIN || mFileSize > 0) {
439 /*
440 * avoid read after seek to end
441 */
442
443 int64_t end = mFileSize;
444 if (rangeEnd > 0) {
445 end = rangeEnd;
446 }
447 end = std::min(mFileSize, end);
448
449 if (end > 0) {
450 size = std::min(size, (size_t)(end - mPConnection->tell()));
451
452 if (size <= 0) {
453 return 0;
454 }
455 }
456 }
457
458 /* only request 1 byte, for truncated reads (only if not eof) */
459 if (mFileSize <= 0 || mPConnection->tell() < mFileSize) {
460
461 if (mNeedReconnect) {
462 rangeStart = mPConnection->tell();
463 Close();
464 Open(mLocation);
465 mNeedReconnect = false;
466 }
467 ret = mPConnection->FillBuffer(1);
468
469 if (ret < 0) {
470 AF_LOGE("CurlDataSource::Read ret=%d, size=%u", ret, size);
471 return ret;
472 }
473 }
474 ret = mPConnection->readBuffer(buf, size);
475 if (ret < 0) {
476 AF_LOGE("CurlDataSource::Read ret=%d, size=%u", ret, size);
477 }
478 return ret;
479}
480
481string CurlDataSource::GetOption(const string &key)
482{

Callers 2

readSliceFunction · 0.45
onReadSourceMethod · 0.45

Calls 4

minClass · 0.85
tellMethod · 0.45
FillBufferMethod · 0.45
readBufferMethod · 0.45

Tested by 1

readSliceFunction · 0.36