[vlc-commits] demux: adaptive: simplify disabled/dead streams cases
Francois Cartegnie
git at videolan.org
Wed Sep 21 18:52:31 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep 16 14:51:36 2016 +0200| [4a7c8d021ac4550f60511d09c803f7a8fb6159ec] | committer: Francois Cartegnie
demux: adaptive: simplify disabled/dead streams cases
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4a7c8d021ac4550f60511d09c803f7a8fb6159ec
---
modules/demux/adaptive/PlaylistManager.cpp | 14 +++++---------
modules/demux/adaptive/Streams.cpp | 18 +++++++++---------
modules/demux/adaptive/Streams.hpp | 2 +-
3 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/modules/demux/adaptive/PlaylistManager.cpp b/modules/demux/adaptive/PlaylistManager.cpp
index 5f1629e..39c7dc5 100644
--- a/modules/demux/adaptive/PlaylistManager.cpp
+++ b/modules/demux/adaptive/PlaylistManager.cpp
@@ -190,13 +190,9 @@ AbstractStream::buffering_status PlaylistManager::bufferize(mtime_t i_nzdeadline
{
AbstractStream *st = *it;
- if (st->isDisabled())
- {
- if(st->isSelected() && !st->isDead())
- reactivateStream(st);
- else
+ if (st->isDisabled() &&
+ (!st->isSelected() || !st->canActivate() || !reactivateStream(st)))
continue;
- }
AbstractStream::buffering_status i_ret = st->bufferize(i_nzdeadline, i_min_buffering, i_extra_buffering);
if(i_return != AbstractStream::buffering_ongoing) /* Buffering streams need to keep going */
@@ -312,7 +308,7 @@ bool PlaylistManager::setPosition(mtime_t time)
for(it=streams.begin(); it!=streams.end(); ++it)
{
AbstractStream *st = *it;
- if(!st->isDisabled() && !st->isDead())
+ if(!st->isDisabled())
ret &= st->setPosition(time, !real);
}
if(!ret)
@@ -359,7 +355,7 @@ void PlaylistManager::pruneLiveStream()
for(it=streams.begin(); it!=streams.end(); it++)
{
const AbstractStream *st = *it;
- if(st->isDisabled() || !st->isSelected() || st->isDead())
+ if(st->isDisabled() || !st->isSelected())
continue;
const mtime_t t = st->getPlaybackTime();
if(minValidPos == 0 || t < minValidPos)
@@ -390,7 +386,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)->isDead();
+ b_dead &= !(*it)->canActivate();
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 27098dd..68ff4b4 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -136,15 +136,10 @@ void AbstractStream::setDescription(const std::string &desc)
description = desc;
}
-bool AbstractStream::isDead() const
-{
- return dead;
-}
-
mtime_t AbstractStream::getPCR() const
{
vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
- mtime_t pcr = (isDead() || isDisabled()) ? VLC_TS_INVALID : commandsqueue->getPCR();
+ mtime_t pcr = isDisabled() ? VLC_TS_INVALID : commandsqueue->getPCR();
vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
return pcr;
}
@@ -160,7 +155,7 @@ mtime_t AbstractStream::getFirstDTS() const
{
mtime_t dts;
vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
- if(isDead() || isDisabled())
+ if(isDisabled())
{
dts = VLC_TS_INVALID;
}
@@ -243,7 +238,12 @@ void AbstractStream::setDisabled(bool b)
bool AbstractStream::isDisabled() const
{
- return disabled;
+ return dead || disabled;
+}
+
+bool AbstractStream::canActivate() const
+{
+ return !dead;
}
bool AbstractStream::drain()
@@ -359,7 +359,7 @@ AbstractStream::status AbstractStream::dequeue(mtime_t nz_deadline, mtime_t *pi_
*pi_pcr = nz_deadline;
- if (isDisabled() || isDead())
+ if (isDisabled())
return AbstractStream::status_eof;
if(commandsqueue->isFlushing())
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index c2671c4..afd3ba2 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -60,12 +60,12 @@ namespace adaptive
void setLanguage(const std::string &);
void setDescription(const std::string &);
- bool isDead() const;
mtime_t getPCR() const;
mtime_t getMinAheadTime() const;
mtime_t getFirstDTS() const;
int esCount() const;
bool isSelected() const;
+ bool canActivate() const;
virtual bool reactivate(mtime_t);
void setDisabled(bool);
bool isDisabled() const;
More information about the vlc-commits
mailing list