[vlc-commits] demux: adaptive: test single states with isDisabled and isValid
Francois Cartegnie
git at videolan.org
Fri May 17 20:34:54 CEST 2019
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed May 15 17:08:59 2019 +0200| [b21dbcdecf8d030e3d77bf829f0881e2b1ec0b2d] | committer: Francois Cartegnie
demux: adaptive: test single states with isDisabled and isValid
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b21dbcdecf8d030e3d77bf829f0881e2b1ec0b2d
---
modules/demux/adaptive/PlaylistManager.cpp | 11 ++++---
modules/demux/adaptive/Streams.cpp | 49 ++++++++++++++----------------
modules/demux/adaptive/Streams.hpp | 4 +--
modules/demux/smooth/SmoothManager.cpp | 4 +--
4 files changed, 33 insertions(+), 35 deletions(-)
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 7b0d54026a..b80df667dc 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -235,8 +235,11 @@ AbstractStream::buffering_status PlaylistManager::bufferize(vlc_tick_t i_nzdeadl
{
AbstractStream *st = (*it).st;
+ if(!st->isValid())
+ continue;
+
if (st->isDisabled() &&
- (!st->isSelected() || !st->canActivate() || !reactivateStream(st)))
+ (!st->isSelected() || !reactivateStream(st)))
continue;
AbstractStream::buffering_status i_ret = st->bufferize(i_nzdeadline, i_min_buffering, i_extra_buffering);
@@ -295,7 +298,7 @@ void PlaylistManager::drain()
{
AbstractStream *st = *it;
- if (st->isDisabled())
+ if (!st->isValid() || st->isDisabled())
continue;
b_drained &= st->decodersDrained();
@@ -349,7 +352,7 @@ bool PlaylistManager::setPosition(vlc_tick_t time)
for(it=streams.begin(); it!=streams.end(); ++it)
{
AbstractStream *st = *it;
- if(!st->isDisabled())
+ if(st->isValid() && !st->isDisabled())
{
hasValidStream = true;
ret &= st->setPosition(time, !real);
@@ -427,7 +430,7 @@ int PlaylistManager::doDemux(vlc_tick_t increment)
bool b_dead = true;
std::vector<AbstractStream *>::const_iterator it;
for(it=streams.begin(); it!=streams.end(); ++it)
- b_dead &= !(*it)->canActivate();
+ b_dead &= !(*it)->isValid();
if(!b_dead)
vlc_cond_timedwait(&demux.cond, &demux.lock, vlc_tick_now() + VLC_TICK_FROM_MS(50));
vlc_mutex_unlock(&demux.lock);
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index 8bf6edfac4..e477ef4c35 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -45,7 +45,7 @@ AbstractStream::AbstractStream(demux_t * demux_)
format = StreamFormat::UNSUPPORTED;
currentChunk = NULL;
eof = false;
- dead = false;
+ valid = true;
disabled = false;
discontinuity = false;
needrestart = false;
@@ -147,10 +147,10 @@ void AbstractStream::setDescription(const std::string &desc)
vlc_tick_t AbstractStream::getPCR() const
{
- vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
- vlc_tick_t pcr = isDisabled() ? VLC_TICK_INVALID : fakeEsOut()->commandsQueue()->getPCR();
- vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
- return pcr;
+ vlc_mutex_locker locker(const_cast<vlc_mutex_t *>(&lock));
+ if(!valid || disabled)
+ return VLC_TICK_INVALID;
+ return fakeEsOut()->commandsQueue()->getPCR();
}
vlc_tick_t AbstractStream::getMinAheadTime() const
@@ -162,19 +162,14 @@ vlc_tick_t AbstractStream::getMinAheadTime() const
vlc_tick_t AbstractStream::getFirstDTS() const
{
- vlc_tick_t dts;
- vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
- if(isDisabled())
- {
- dts = VLC_TICK_INVALID;
- }
- else
- {
- dts = fakeEsOut()->commandsQueue()->getFirstDTS();
- if(dts == VLC_TICK_INVALID)
- dts = fakeEsOut()->commandsQueue()->getPCR();
- }
- vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
+ vlc_mutex_locker locker(const_cast<vlc_mutex_t *>(&lock));
+
+ if(!valid || disabled)
+ return VLC_TICK_INVALID;
+
+ vlc_tick_t dts = fakeEsOut()->commandsQueue()->getFirstDTS();
+ if(dts == VLC_TICK_INVALID)
+ dts = fakeEsOut()->commandsQueue()->getPCR();
return dts;
}
@@ -270,14 +265,14 @@ void AbstractStream::setDisabled(bool b)
disabled = b;
}
-bool AbstractStream::isDisabled() const
+bool AbstractStream::isValid() const
{
- return dead || disabled;
+ return valid;
}
-bool AbstractStream::canActivate() const
+bool AbstractStream::isDisabled() const
{
- return !dead;
+ return disabled;
}
bool AbstractStream::decodersDrained()
@@ -308,7 +303,7 @@ AbstractStream::buffering_status AbstractStream::doBufferize(vlc_tick_t nz_deadl
vlc_mutex_lock(&lock);
/* Ensure it is configured */
- if(!segmentTracker || !connManager || dead)
+ if(!segmentTracker || !connManager || !valid)
{
vlc_mutex_unlock(&lock);
return AbstractStream::buffering_end;
@@ -347,7 +342,7 @@ AbstractStream::buffering_status AbstractStream::doBufferize(vlc_tick_t nz_deadl
vlc_mutex_unlock(&lock);
return AbstractStream::buffering_ongoing;
}
- dead = true; /* Prevent further retries */
+ valid = false; /* Prevent further retries */
fakeEsOut()->commandsQueue()->setEOF(true);
vlc_mutex_unlock(&lock);
return AbstractStream::buffering_end;
@@ -432,7 +427,7 @@ AbstractStream::status AbstractStream::dequeue(vlc_tick_t nz_deadline, vlc_tick_
}
}
- if(isDisabled() || fakeEsOut()->commandsQueue()->isEOF())
+ if(!valid || disabled || fakeEsOut()->commandsQueue()->isEOF())
{
*pi_pcr = nz_deadline;
return AbstractStream::status_eof;
@@ -534,7 +529,7 @@ bool AbstractStream::setPosition(vlc_tick_t time, bool tryonly)
{
msg_Info(p_realdemux, "Restart demux failed");
eof = true;
- dead = true;
+ valid = false;
ret = false;
}
else
@@ -557,7 +552,7 @@ vlc_tick_t AbstractStream::getPlaybackTime() const
void AbstractStream::runUpdates()
{
- if(!isDisabled())
+ if(valid && !disabled)
segmentTracker->updateSelected();
}
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index c0c83255b5..7c78d700e2 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -66,10 +66,10 @@ namespace adaptive
vlc_tick_t getFirstDTS() const;
int esCount() const;
bool isSelected() const;
- bool canActivate() const;
virtual bool reactivate(vlc_tick_t);
void setDisabled(bool);
bool isDisabled() const;
+ bool isValid() const;
typedef enum {
status_eof = 0, /* prioritized */
status_discontinuity,
@@ -137,7 +137,7 @@ namespace adaptive
private:
buffering_status doBufferize(vlc_tick_t, vlc_tick_t, vlc_tick_t);
buffering_status last_buffer_status;
- bool dead;
+ bool valid;
bool disabled;
unsigned notfound_sequence;
};
diff --git a/modules/demux/smooth/SmoothManager.cpp b/modules/demux/smooth/SmoothManager.cpp
index ebd71ee448..7a3f243300 100644
--- a/modules/demux/smooth/SmoothManager.cpp
+++ b/modules/demux/smooth/SmoothManager.cpp
@@ -103,7 +103,7 @@ bool SmoothManager::updatePlaylist()
{
const AbstractStream *st = *it;
const vlc_tick_t m = st->getMinAheadTime();
- if(st->isDisabled() || !st->isSelected())
+ if(!st->isValid() || st->isDisabled() || !st->isSelected())
{
continue;
}
@@ -125,7 +125,7 @@ void SmoothManager::scheduleNextUpdate()
for(it=streams.begin(); it!=streams.end(); ++it)
{
const AbstractStream *st = *it;
- if(st->isDisabled() || !st->isSelected())
+ if(!st->isValid() || st->isDisabled() || !st->isSelected())
continue;
const vlc_tick_t m = st->getMinAheadTime();
if(m > 0 && (m < minbuffer || minbuffer == 0))
More information about the vlc-commits
mailing list