Skip to content

Commit

Permalink
fix(curl): fix hls play crash
Browse files Browse the repository at this point in the history
Signed-off-by: pingkai <pingkai010@gmail.com>
  • Loading branch information
pingkai committed Feb 24, 2020
1 parent 0b2496a commit 5271362
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
7 changes: 3 additions & 4 deletions framework/data_source/curl/CURLConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,19 +687,18 @@ int CURLConnection::readBuffer(void *buf, size_t size)
/*if (re == CURLE_OK)
av_log(mCurlhttpContext.hd,AV_LOG_DEBUG,"download speed is %f\n",downloadSpeed);*/
uint32_t want = std::min(RingBuffergetMaxReadSize(pRbuf), (uint32_t) size);
assert(want > 0);

if (RingBufferReadData(pRbuf, (char *) buf, want) == want) {
if (want > 0 && RingBufferReadData(pRbuf, (char *) buf, want) == want) {
mFilePos += want;
return want;
}

/* check if we finished prematurely */
if (!still_running &&
(mFileSize <= 0 || mFilePos != mFileSize)) {
(mFileSize > 0 && mFilePos != mFileSize)) {
AF_LOGE("%s - Transfer ended before entire file was retrieved pos %lld, size %lld",
__FUNCTION__, mFilePos, mFileSize);
return -1;
// return -1;
}

return 0;
Expand Down
1 change: 0 additions & 1 deletion framework/data_source/curl/curl_data_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ void CurlDataSource::closeConnections(bool current)
lock_guard<mutex> lock(mMutex);
CURLConnection *deleteConnection = nullptr;
vector<CURLConnection *> *pConnections = mConnections;
mPConnection = nullptr;
mConnections = nullptr;

if (current) {
Expand Down

0 comments on commit 5271362

Please sign in to comment.