Commit 40608ad1 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: simplify first pcr handling

parent 2dcf76ce
......@@ -208,8 +208,6 @@ AbstractStream::buffering_status PlaylistManager::bufferize(mtime_t i_nzdeadline
i_return != AbstractStream::buffering_lessthanmin /* prevents starting before buffering is reached */ )
{
demux.i_nzpcr = getFirstDTS();
if(demux.i_nzpcr == VLC_TS_INVALID)
demux.i_nzpcr = getPCR();
}
vlc_mutex_unlock(&demux.lock);
......@@ -265,30 +263,32 @@ void PlaylistManager::drain()
mtime_t PlaylistManager::getPCR() const
{
mtime_t pcr = VLC_TS_INVALID;
mtime_t minpcr = VLC_TS_INVALID;
std::vector<AbstractStream *>::const_iterator it;
for(it=streams.begin(); it!=streams.end(); ++it)
{
if ((*it)->isDisabled() || (*it)->isDead())
continue;
if(pcr == VLC_TS_INVALID || pcr > (*it)->getPCR())
pcr = (*it)->getPCR();
const mtime_t pcr = (*it)->getPCR();
if(minpcr == VLC_TS_INVALID)
minpcr = pcr;
else if(pcr > VLC_TS_INVALID)
minpcr = std::min(minpcr, pcr);
}
return pcr;
return minpcr;
}
mtime_t PlaylistManager::getFirstDTS() const
{
mtime_t dts = VLC_TS_INVALID;
mtime_t mindts = VLC_TS_INVALID;
std::vector<AbstractStream *>::const_iterator it;
for(it=streams.begin(); it!=streams.end(); ++it)
{
if ((*it)->isDisabled() || (*it)->isDead())
continue;
if(dts == VLC_TS_INVALID || dts > (*it)->getFirstDTS())
dts = (*it)->getFirstDTS();
const mtime_t dts = (*it)->getFirstDTS();
if(mindts == VLC_TS_INVALID)
mindts = dts;
else if(dts > VLC_TS_INVALID)
mindts = std::min(mindts, dts);
}
return dts;
return mindts;
}
mtime_t PlaylistManager::getDuration() const
......
......@@ -140,7 +140,10 @@ bool AbstractStream::isDead() const
mtime_t AbstractStream::getPCR() const
{
return commandsqueue->getPCR();
vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
mtime_t pcr = (dead || disabled) ? VLC_TS_INVALID : commandsqueue->getPCR();
vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
return pcr;
}
mtime_t AbstractStream::getMinAheadTime() const
......@@ -152,7 +155,20 @@ mtime_t AbstractStream::getMinAheadTime() const
mtime_t AbstractStream::getFirstDTS() const
{
return commandsqueue->getFirstDTS();
mtime_t dts;
vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
if(dead || disabled)
{
dts = VLC_TS_INVALID;
}
else
{
dts = commandsqueue->getFirstDTS();
if(dts == VLC_TS_INVALID)
dts = commandsqueue->getPCR();
}
vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
return dts;
}
int AbstractStream::esCount() const
......
......@@ -376,19 +376,21 @@ mtime_t CommandsQueue::getBufferingLevel() const
mtime_t CommandsQueue::getFirstDTS() const
{
mtime_t i_dts = VLC_TS_INVALID;
std::list<AbstractCommand *>::const_iterator it;
vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
mtime_t i_firstdts = pcr;
for( it = commands.begin(); it != commands.end(); ++it )
{
if( (*it)->getTime() > VLC_TS_INVALID )
const mtime_t i_dts = (*it)->getTime();
if( i_dts > VLC_TS_INVALID )
{
i_dts = (*it)->getTime();
if( i_dts < i_firstdts || i_firstdts == VLC_TS_INVALID )
i_firstdts = i_dts;
break;
}
}
vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
return i_dts;
return i_firstdts;
}
mtime_t CommandsQueue::getPCR() const
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment