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

Method Seek

framework/data_source/curl/curl_data_source2.cpp:307–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307int64_t CurlDataSource2::Seek(int64_t offset, int whence)
308{
309 // CURL_LOGD("CurlDataSource2::Seek position is %lld,when is %d", offset, whence);
310 if (!mPConnection) {
311 return -(ESPIPE);
312 }
313 if (whence == SEEK_SIZE) {
314 return mFileSize;
315 } else if (((whence == SEEK_CUR && offset == 0) || (whence == SEEK_SET && offset == mPConnection->tell())) &&
316 !mPConnection->needReconnect()) {
317 return mPConnection->tell();
318 } else if ((mFileSize <= 0 && whence == SEEK_END) /*|| h->is_streamed*/) {
319 return FRAMEWORK_ERR(ENOSYS);
320 }
321
322 if (whence == SEEK_CUR) {
323 offset += mPConnection->tell();
324 } else if (whence == SEEK_END) {
325 offset += mFileSize;
326 } else if (whence != SEEK_SET) {
327 return FRAMEWORK_ERR(EINVAL);
328 }
329
330 if (offset < 0) {
331 return -(ESPIPE);
332 }
333
334 if (offset == mPConnection->tell() && !mPConnection->needReconnect()) {
335 return offset;
336 }
337
338 /* do not try to make a new connection if seeking past the end of the file */
339 if (rangeEnd != INT64_MIN || mFileSize > 0) {
340 uint64_t end_pos = rangeEnd != INT64_MIN ? rangeEnd : mFileSize;
341 if (offset >= end_pos) {
342 mPConnection->SetResume(offset);
343 return offset;
344 }
345 }
346
347 if (offset == mFileSize) {
348 }
349
350 //first seek in cache
351 if (!mNeedReconnect) {
352 if (mPConnection->short_seek(offset) >= 0) {
353 AF_LOGI("short seek ok\n");
354 return offset;
355 } else {
356 AF_LOGI("short seek failed\n");
357 }
358 } else {
359 closeConnections(true, true);
360 }
361#if USE_MULTI
362 CURLConnection2 *con = nullptr;
363 for (auto item = mConnections->begin(); item != mConnections->end();) {
364 if ((*(item))->short_seek(offset) >= 0) {

Callers

nothing calls this directly

Calls 13

needReconnectMethod · 0.80
removeFormMultiMethod · 0.80
frontMethod · 0.80
deleteHandleMethod · 0.80
deleteFormMultiMethod · 0.80
addToMultiMethod · 0.80
pauseMethod · 0.65
tellMethod · 0.45
SetResumeMethod · 0.45
short_seekMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected