[vlc-commits] demux: adaptive: move pcr/flushing to commands queue
Francois Cartegnie
git at videolan.org
Sat Jul 9 18:42:44 CEST 2016
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Jun 29 18:09:18 2016 +0200| [3ed984575f81cfdcf13b73ffb48c68e8824bd993] | committer: Francois Cartegnie
demux: adaptive: move pcr/flushing to commands queue
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3ed984575f81cfdcf13b73ffb48c68e8824bd993
---
modules/demux/adaptive/Streams.cpp | 20 +++++-------
modules/demux/adaptive/Streams.hpp | 2 --
modules/demux/adaptive/plumbing/CommandsQueue.cpp | 35 +++++++++++++++++++++
modules/demux/adaptive/plumbing/CommandsQueue.hpp | 5 +++
4 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/modules/demux/adaptive/Streams.cpp b/modules/demux/adaptive/Streams.cpp
index 09b1505..d1860e0 100644
--- a/modules/demux/adaptive/Streams.cpp
+++ b/modules/demux/adaptive/Streams.cpp
@@ -43,10 +43,8 @@ AbstractStream::AbstractStream(demux_t * demux_)
eof = false;
dead = false;
disabled = false;
- flushing = false;
discontinuity = false;
segmentTracker = NULL;
- pcr = VLC_TS_INVALID;
demuxersource = NULL;
commandsqueue = NULL;
demuxer = NULL;
@@ -139,7 +137,7 @@ bool AbstractStream::isEOF() const
mtime_t AbstractStream::getPCR() const
{
- return pcr;
+ return commandsqueue->getPCR();
}
mtime_t AbstractStream::getMinAheadTime() const
@@ -169,7 +167,7 @@ bool AbstractStream::seekAble() const
return (demuxer &&
!fakeesout->restarting() &&
!discontinuity &&
- !flushing );
+ !commandsqueue->isFlushing() );
}
bool AbstractStream::isSelected() const
@@ -232,18 +230,16 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
if(!segmentTracker || !connManager || dead)
return AbstractStream::status_eof;
- if(flushing)
+ if(commandsqueue->isFlushing())
{
if(!send)
return AbstractStream::status_buffering;
- pcr = commandsqueue->Process(p_realdemux->out, VLC_TS_0 + nz_deadline);
+ (void) commandsqueue->Process(p_realdemux->out, VLC_TS_0 + nz_deadline);
if(!commandsqueue->isEmpty())
return AbstractStream::status_demuxed;
commandsqueue->Abort(true); /* reset buffering level */
- flushing = false;
- pcr = 0;
return AbstractStream::status_dis;
}
@@ -258,7 +254,7 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
msg_Dbg( p_realdemux, "Flushing on format change" );
prepareFormatChange();
discontinuity = false;
- flushing = true;
+ commandsqueue->setFlush();
return AbstractStream::status_buffering;
}
dead = true; /* Prevent further retries */
@@ -280,7 +276,7 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
msg_Dbg( p_realdemux, "Flushing on discontinuity" );
prepareFormatChange();
discontinuity = false;
- flushing = true;
+ commandsqueue->setFlush();
return AbstractStream::status_buffering;
}
@@ -298,7 +294,7 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
description.c_str(), getPCR(), getFirstDTS(), nz_deadline, getBufferingLevel()));
if(send)
- pcr = commandsqueue->Process( p_realdemux->out, VLC_TS_0 + nz_deadline );
+ (void) commandsqueue->Process( p_realdemux->out, VLC_TS_0 + nz_deadline );
/* Disable streams that are not selected (alternate streams) */
if(esCount() && !isSelected() && !fakeesout->restarting())
@@ -368,8 +364,8 @@ bool AbstractStream::setPosition(mtime_t time, bool tryonly)
setTimeOffset();
}
+ else commandsqueue->Abort( true );
- pcr = VLC_TS_INVALID;
es_out_Control(p_realdemux->out, ES_OUT_SET_NEXT_DISPLAY_TIME,
VLC_TS_0 + time);
}
diff --git a/modules/demux/adaptive/Streams.hpp b/modules/demux/adaptive/Streams.hpp
index 910f409..73823dc 100644
--- a/modules/demux/adaptive/Streams.hpp
+++ b/modules/demux/adaptive/Streams.hpp
@@ -107,8 +107,6 @@ namespace adaptive
bool disabled;
bool eof;
bool dead;
- bool flushing;
- mtime_t pcr;
std::string language;
std::string description;
diff --git a/modules/demux/adaptive/plumbing/CommandsQueue.cpp b/modules/demux/adaptive/plumbing/CommandsQueue.cpp
index 832abb5..79cf540 100644
--- a/modules/demux/adaptive/plumbing/CommandsQueue.cpp
+++ b/modules/demux/adaptive/plumbing/CommandsQueue.cpp
@@ -196,7 +196,9 @@ EsOutControlResetPCRCommand * CommandsFactory::creatEsOutControlResetPCRCommand(
CommandsQueue::CommandsQueue( CommandsFactory *f )
{
bufferinglevel = VLC_TS_INVALID;
+ pcr = VLC_TS_INVALID;
b_drop = false;
+ b_flushing = false;
commandsFactory = f;
vlc_mutex_init(&lock);
}
@@ -265,6 +267,11 @@ mtime_t CommandsQueue::Process( es_out_t *out, mtime_t barrier )
command->Execute( out );
delete command;
}
+ pcr = lastdts;
+
+ if(commands.empty() && b_flushing)
+ b_flushing = false;
+
vlc_mutex_unlock(&lock);
return lastdts;
@@ -295,7 +302,11 @@ void CommandsQueue::Abort( bool b_reset )
}
if( b_reset )
+ {
bufferinglevel = VLC_TS_INVALID;
+ pcr = VLC_TS_INVALID;
+ b_flushing = false;
+ }
vlc_mutex_unlock(&lock);
}
@@ -314,6 +325,22 @@ void CommandsQueue::setDrop( bool b )
vlc_mutex_unlock(&lock);
}
+void CommandsQueue::setFlush()
+{
+ vlc_mutex_lock(&lock);
+ LockedCommit();
+ b_flushing = !commands.empty();
+ vlc_mutex_unlock(&lock);
+}
+
+bool CommandsQueue::isFlushing() const
+{
+ vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
+ bool b = b_flushing;
+ vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
+ return b;
+}
+
mtime_t CommandsQueue::getDemuxedAmount() const
{
return bufferinglevel - getFirstDTS();
@@ -344,3 +371,11 @@ mtime_t CommandsQueue::getFirstDTS() const
vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
return i_dts;
}
+
+mtime_t CommandsQueue::getPCR() const
+{
+ vlc_mutex_lock(const_cast<vlc_mutex_t *>(&lock));
+ mtime_t i_pcr = pcr;
+ vlc_mutex_unlock(const_cast<vlc_mutex_t *>(&lock));
+ return i_pcr;
+}
diff --git a/modules/demux/adaptive/plumbing/CommandsQueue.hpp b/modules/demux/adaptive/plumbing/CommandsQueue.hpp
index b22cc2e..42d55ef 100644
--- a/modules/demux/adaptive/plumbing/CommandsQueue.hpp
+++ b/modules/demux/adaptive/plumbing/CommandsQueue.hpp
@@ -145,9 +145,12 @@ namespace adaptive
void Commit();
bool isEmpty() const;
void setDrop( bool );
+ void setFlush();
+ bool isFlushing() const;
mtime_t getDemuxedAmount() const;
mtime_t getBufferingLevel() const;
mtime_t getFirstDTS() const;
+ mtime_t getPCR() const;
private:
CommandsFactory *commandsFactory;
@@ -156,6 +159,8 @@ namespace adaptive
std::list<AbstractCommand *> incoming;
std::list<AbstractCommand *> commands;
mtime_t bufferinglevel;
+ mtime_t pcr;
+ bool b_flushing;
bool b_drop;
};
}
More information about the vlc-commits
mailing list