[vlc-commits] demux: adaptive: move lock to non buffered chunk
Francois Cartegnie
git at videolan.org
Wed Aug 8 16:01:11 CEST 2018
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Aug 8 13:42:05 2018 +0200| [2b0833eb984096ab29360b68a15c7b23ccbe3c53] | committer: Francois Cartegnie
demux: adaptive: move lock to non buffered chunk
(cherry picked from commit cedb5bb7fbda46f1bc7cc6ac834905ed4c140dfc)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=2b0833eb984096ab29360b68a15c7b23ccbe3c53
---
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 9083e7881c..a3d392c817 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 df8ce2aeac..a3773862da 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;
mtime_t downloadstart;
- mutable vlc_mutex_t lock;
vlc_cond_t avail;
bool held;
};
More information about the vlc-commits
mailing list