Commit 64f08bdf authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: add drain (GET_EMPTY)

Required to correctly switch to another period,
as we disable es on period end.
parent 5b5ac44e
......@@ -195,6 +195,30 @@ AbstractStream::status PlaylistManager::demux(mtime_t *pi_nzbarrier, bool send)
return i_return;
}
void PlaylistManager::drain()
{
for(;;)
{
bool b_drained = true;
std::vector<AbstractStream *>::iterator it;
for(it=streams.begin(); it!=streams.end(); ++it)
{
AbstractStream *st = *it;
if (st->isDisabled())
continue;
b_drained &= st->drain();
}
if(b_drained)
break;
msleep(20*1000); /* ugly, but we have no way to get feedback */
}
es_out_Control(p_demux->out, ES_OUT_RESET_PCR);
}
mtime_t PlaylistManager::getPCR() const
{
mtime_t pcr = VLC_TS_INVALID;
......
......@@ -54,6 +54,8 @@ namespace adaptive
bool start();
AbstractStream::status demux(mtime_t *, bool);
void drain();
virtual bool needsUpdate() const;
virtual bool updatePlaylist();
virtual void scheduleNextUpdate();
......
......@@ -224,6 +224,11 @@ bool AbstractStream::isDisabled() const
return disabled;
}
bool AbstractStream::drain()
{
return fakeesout->drain();
}
AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
{
/* Ensure it is configured */
......@@ -279,10 +284,6 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
commandsqueue->setFlush();
return AbstractStream::status_buffering;
}
commandsqueue->Commit();
if(commandsqueue->isEmpty())
return AbstractStream::status_eof;
}
else if(nz_deadline + VLC_TS_0 > getBufferingLevel()) /* need to read more */
{
......
......@@ -76,6 +76,7 @@ namespace adaptive
status_buffering_ahead, /* Special case for live waiting new segments */
status_demuxed} status;
status demux(mtime_t, bool);
bool drain();
virtual bool setPosition(mtime_t, bool);
mtime_t getPlaybackTime() const;
void runUpdates();
......
......@@ -237,6 +237,25 @@ bool FakeESOut::hasSelectedEs() const
return b_selected;
}
bool FakeESOut::drain()
{
bool b_drained = true;
std::list<FakeESOutID *>::const_iterator it;
vlc_mutex_lock(&lock);
for( it=fakeesidlist.begin(); it!=fakeesidlist.end(); ++it )
{
FakeESOutID *esID = *it;
if( esID->realESID() )
{
bool b_empty;
es_out_Control( real_es_out, ES_OUT_GET_EMPTY, &b_empty );
b_drained &= b_empty;
}
}
vlc_mutex_unlock(&lock);
return b_drained;
}
bool FakeESOut::restarting() const
{
vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
......
......@@ -43,6 +43,7 @@ namespace adaptive
void setTimestampOffset( mtime_t );
size_t esCount() const;
bool hasSelectedEs() const;
bool drain();
bool restarting() const;
void setExtraInfoProvider( ExtraFMTInfoInterface * );
......
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