[vlc-commits] demux: adaptive: test single states with isDisabled and isValid
Francois Cartegnie
git at videolan.org
Mon Mar 30 16:15:34 CEST 2020
vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed May 15 17:08:59 2019 +0200| [2bde86c9c48d9daa3ee03e6a837da635c7a531ce] | committer: Francois Cartegnie
demux: adaptive: test single states with isDisabled and isValid
(cherry picked from commit b21dbcdecf8d030e3d77bf829f0881e2b1ec0b2d)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=2bde86c9c48d9daa3ee03e6a837da635c7a531ce
---
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 df1acf8db5..f95eb49e89 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -240,8 +240,11 @@ AbstractStream::buffering_status PlaylistManager::bufferize(mtime_t i_nzdeadline
{
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);
@@ -300,7 +303,7 @@ void PlaylistManager::drain()
{
AbstractStream *st = *it;
- if (st->isDisabled())
+ if (!st->isValid() || st->isDisabled())
continue;
b_drained &= st->decodersDrained();
@@ -363,7 +366,7 @@ bool PlaylistManager::setPosition(mtime_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);
@@ -451,7 +454,7 @@ int PlaylistManager::doDemux(int64_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, mdate() + CLOCK_FREQ / 20);
vlc_mutex_unlock(&demux.lock);
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index d5478ddd2f..bc4358d7cf 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -45,7 +45,7 @@ AbstractStream::AbstractStream(demux_t * demux_)
format = StreamFormat::UNKNOWN;
currentChunk = NULL;
eof = false;
- dead = false;
+ valid = true;
disabled = false;
discontinuity = false;
needrestart = false;
@@ -145,10 +145,10 @@ void AbstractStream::setDescription(const std::string &desc)
mtime_t AbstractStream::getPCR() const
{
- vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
- mtime_t pcr = isDisabled() ? VLC_TS_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_TS_INVALID;
+ return fakeEsOut()->commandsQueue()->getPCR();
}
mtime_t AbstractStream::getMinAheadTime() const
@@ -160,19 +160,14 @@ mtime_t AbstractStream::getMinAheadTime() const
mtime_t AbstractStream::getFirstDTS() const
{
- mtime_t dts;
- vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
- if(isDisabled())
- {
- dts = VLC_TS_INVALID;
- }
- else
- {
- dts = fakeEsOut()->commandsQueue()->getFirstDTS();
- if(dts == VLC_TS_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_TS_INVALID;
+
+ mtime_t dts = fakeEsOut()->commandsQueue()->getFirstDTS();
+ if(dts == VLC_TS_INVALID)
+ dts = fakeEsOut()->commandsQueue()->getPCR();
return dts;
}
@@ -268,14 +263,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()
@@ -306,7 +301,7 @@ AbstractStream::buffering_status AbstractStream::doBufferize(mtime_t nz_deadline
vlc_mutex_lock(&lock);
/* Ensure it is configured */
- if(!segmentTracker || !connManager || dead)
+ if(!segmentTracker || !connManager || !valid)
{
vlc_mutex_unlock(&lock);
return AbstractStream::buffering_end;
@@ -345,7 +340,7 @@ AbstractStream::buffering_status AbstractStream::doBufferize(mtime_t nz_deadline
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;
@@ -430,7 +425,7 @@ AbstractStream::status AbstractStream::dequeue(mtime_t nz_deadline, mtime_t *pi_
}
}
- if(isDisabled() || fakeEsOut()->commandsQueue()->isEOF())
+ if(!valid || disabled || fakeEsOut()->commandsQueue()->isEOF())
{
*pi_pcr = nz_deadline;
return AbstractStream::status_eof;
@@ -525,7 +520,7 @@ bool AbstractStream::setPosition(mtime_t time, bool tryonly)
{
msg_Info(p_realdemux, "Restart demux failed");
eof = true;
- dead = true;
+ valid = false;
ret = false;
}
else
@@ -548,7 +543,7 @@ mtime_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 12c421aced..a9e37dc0dc 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -66,10 +66,10 @@ namespace adaptive
mtime_t getFirstDTS() const;
int esCount() const;
bool isSelected() const;
- bool canActivate() const;
virtual bool reactivate(mtime_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(mtime_t, unsigned, unsigned);
buffering_status last_buffer_status;
- bool dead;
+ bool valid;
bool disabled;
};
diff --git a/modules/demux/smooth/SmoothManager.cpp b/modules/demux/smooth/SmoothManager.cpp
index e5df1e9938..7740c94c5a 100644
--- a/modules/demux/smooth/SmoothManager.cpp
+++ b/modules/demux/smooth/SmoothManager.cpp
@@ -105,7 +105,7 @@ bool SmoothManager::updatePlaylist()
{
const AbstractStream *st = *it;
const mtime_t m = st->getMinAheadTime();
- if(st->isDisabled() || !st->isSelected())
+ if(!st->isValid() || st->isDisabled() || !st->isSelected())
{
continue;
}
@@ -127,7 +127,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 mtime_t m = st->getMinAheadTime();
if(m > 0 && (m < minbuffer || minbuffer == 0))
More information about the vlc-commits
mailing list