[vlc-commits] [Git][videolan/vlc][master] 4 commits: adaptive: make internal cache sizes size_t
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Sat May 21 16:34:21 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
03784ac4 by Steve Lhomme at 2022-05-21T16:09:34+00:00
adaptive: make internal cache sizes size_t
The source size is a size_t and it represents a size in memory.
- - - - -
76d64fcd by Steve Lhomme at 2022-05-21T16:09:34+00:00
adaptive: empty the chunk source cache on exit
There's no way to release it during playback but we shouldn't leak it in the
end.
- - - - -
b7ee30a7 by Steve Lhomme at 2022-05-21T16:09:34+00:00
adaptive: ensure the chunk source cache size is always coherent
- - - - -
ff7e38fe by Steve Lhomme at 2022-05-21T16:09:34+00:00
adaptive: recycle the chunk source when prepareChunk fails
Just as when createChunk() fails.
- - - - -
3 changed files:
- modules/demux/adaptive/http/HTTPConnectionManager.cpp
- modules/demux/adaptive/http/HTTPConnectionManager.h
- modules/demux/adaptive/playlist/Segment.cpp
Changes:
=====================================
modules/demux/adaptive/http/HTTPConnectionManager.cpp
=====================================
@@ -33,6 +33,8 @@
#include <vlc_url.h>
#include <vlc_http.h>
+#include <cassert>
+
using namespace adaptive::http;
AbstractConnectionManager::AbstractConnectionManager(vlc_object_t *p_object_)
@@ -85,6 +87,16 @@ HTTPConnectionManager::HTTPConnectionManager (vlc_object_t *p_object_)
HTTPConnectionManager::~HTTPConnectionManager ()
{
+ while(!cache.empty())
+ {
+ HTTPChunkBufferedSource *purged = cache.back();
+ cache.pop_back();
+ assert(cache_total >= purged->contentLength);
+ cache_total -= purged->contentLength;
+ CacheDebug(msg_Dbg(p_object, "Cache DEL '%s' usage %u bytes",
+ purged->getStorageID().c_str(), cache_total));
+ deleteSource(purged);
+ }
delete downloader;
delete downloaderhp;
this->closeAllConnections();
@@ -174,6 +186,7 @@ AbstractChunkSource *HTTPConnectionManager::makeSource(const std::string &url,
if(s->getStorageID() == storageid)
{
cache.remove(s);
+ assert(cache_total >= s->contentLength);
cache_total -= s->contentLength;
CacheDebug(msg_Dbg(p_object, "Cache GET '%s' usage %u bytes",
storageid.c_str(), cache_total));
@@ -214,6 +227,7 @@ void HTTPConnectionManager::recycleSource(AbstractChunkSource *source)
{
HTTPChunkBufferedSource *purged = cache.back();
cache.pop_back();
+ assert(cache_total >= purged->contentLength);
cache_total -= purged->contentLength;
CacheDebug(msg_Dbg(p_object, "Cache DEL '%s' usage %u bytes",
purged->getStorageID().c_str(), cache_total));
=====================================
modules/demux/adaptive/http/HTTPConnectionManager.h
=====================================
@@ -102,8 +102,8 @@ namespace adaptive
AbstractConnection * reuseConnection(ConnectionParams &);
Downloader * getDownloadQueue(const AbstractChunkSource *) const;
std::list<HTTPChunkBufferedSource *> cache;
- unsigned cache_total;
- unsigned cache_max;
+ size_t cache_total;
+ size_t cache_max;
};
}
}
=====================================
modules/demux/adaptive/playlist/Segment.cpp
=====================================
@@ -104,6 +104,7 @@ SegmentChunk* ISegment::toChunk(SharedResources *res, size_t index, BaseRepresen
chunk->discontinuitySequenceNumber = getDiscontinuitySequenceNumber();
if(!prepareChunk(res, chunk, rep))
{
+ res->getConnManager()->recycleSource(source);
delete chunk;
return nullptr;
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb6704f3d60725babb22cdb0caf8530cd36044b2...ff7e38fe13353889c0f603f883134e75885b20f6
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/fb6704f3d60725babb22cdb0caf8530cd36044b2...ff7e38fe13353889c0f603f883134e75885b20f6
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list