[vlc-commits] demux: adaptive: move lock to non buffered chunk
Francois Cartegnie
git at videolan.org
Wed Aug 8 13:49:20 CEST 2018
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Aug 8 13:42:05 2018 +0200| [cedb5bb7fbda46f1bc7cc6ac834905ed4c140dfc] | committer: Francois Cartegnie
demux: adaptive: move lock to non buffered chunk
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=cedb5bb7fbda46f1bc7cc6ac834905ed4c140dfc
---
modules/demux/adaptive/http/Chunk.cpp | 8 ++++++--
modules/demux/adaptive/http/Chunk.h | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/modules/demux/adaptive/http/Chunk.cpp b/modules/demux/adaptive/http/Chunk.cpp
index 6ed0aa1ca8..eb0532b6a0 100644
--- a/modules/demux/adaptive/http/Chunk.cpp
+++ b/modules/demux/adaptive/http/Chunk.cpp
@@ -133,6 +133,7 @@ HTTPChunkSource::HTTPChunkSource(const std::string& url, AbstractConnectionManag
connManager (manager),
consumed (0)
{
+ vlc_mutex_init(&lock);
prepared = false;
eof = false;
sourceid = id;
@@ -145,10 +146,12 @@ HTTPChunkSource::~HTTPChunkSource()
{
if(connection)
connection->setUsed(false);
+ vlc_mutex_destroy(&lock);
}
bool HTTPChunkSource::init(const std::string &url)
{
+ vlc_mutex_locker locker(&lock);
params = ConnectionParams(url);
params.setUseAccess(usesAccess());
@@ -163,6 +166,7 @@ bool HTTPChunkSource::init(const std::string &url)
bool HTTPChunkSource::hasMoreData() const
{
+ vlc_mutex_locker locker(&lock);
if(eof)
return false;
else if(contentLength)
@@ -172,6 +176,7 @@ bool HTTPChunkSource::hasMoreData() const
block_t * HTTPChunkSource::read(size_t readsize)
{
+ vlc_mutex_locker locker(&lock);
if(!prepare())
{
eof = true;
@@ -218,6 +223,7 @@ block_t * HTTPChunkSource::read(size_t readsize)
std::string HTTPChunkSource::getContentType() const
{
+ vlc_mutex_locker locker(&lock);
if(connection)
return connection->getContentType();
else
@@ -282,7 +288,6 @@ HTTPChunkBufferedSource::HTTPChunkBufferedSource(const std::string& url, Abstrac
pp_tail (&p_head),
buffered (0)
{
- vlc_mutex_init(&lock);
vlc_cond_init(&avail);
done = false;
eof = false;
@@ -310,7 +315,6 @@ HTTPChunkBufferedSource::~HTTPChunkBufferedSource()
vlc_mutex_unlock(&lock);
vlc_cond_destroy(&avail);
- vlc_mutex_destroy(&lock);
}
bool HTTPChunkBufferedSource::isDone() const
diff --git a/modules/demux/adaptive/http/Chunk.h b/modules/demux/adaptive/http/Chunk.h
index 3bf3b44263..0b5efd5fe9 100644
--- a/modules/demux/adaptive/http/Chunk.h
+++ b/modules/demux/adaptive/http/Chunk.h
@@ -101,6 +101,7 @@ namespace adaptive
virtual bool prepare();
AbstractConnection *connection;
AbstractConnectionManager *connManager;
+ mutable vlc_mutex_t lock;
size_t consumed; /* read pointer */
bool prepared;
bool eof;
@@ -137,7 +138,6 @@ namespace adaptive
bool done;
bool eof;
vlc_tick_t downloadstart;
- mutable vlc_mutex_t lock;
vlc_cond_t avail;
bool held;
};
More information about the vlc-commits
mailing list