[vlc-commits] demux: adaptative: simplify chunk usage
Francois Cartegnie
git at videolan.org
Wed Nov 18 11:51:22 CET 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Nov 13 12:42:43 2015 +0100| [dd9a9051ea05075a14224c9a00cbe6b8c79eb178] | committer: Francois Cartegnie
demux: adaptative: simplify chunk usage
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dd9a9051ea05075a14224c9a00cbe6b8c79eb178
---
modules/demux/adaptative/Streams.cpp | 45 ++++++++++++++++------------------
modules/demux/adaptative/Streams.hpp | 1 -
2 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/modules/demux/adaptative/Streams.cpp b/modules/demux/adaptative/Streams.cpp
index 1c21ae5..001f8eb 100644
--- a/modules/demux/adaptative/Streams.cpp
+++ b/modules/demux/adaptative/Streams.cpp
@@ -135,17 +135,6 @@ int AbstractStream::esCount() const
return fakeesout->esCount();
}
-SegmentChunk * AbstractStream::getChunk()
-{
- if (currentChunk == NULL && !eof)
- {
- currentChunk = segmentTracker->getNextChunk(!fakeesout->restarting(), connManager);
- if (currentChunk == NULL)
- eof = true;
- }
- return currentChunk;
-}
-
bool AbstractStream::seekAble() const
{
return (demuxer &&
@@ -292,44 +281,52 @@ AbstractStream::status AbstractStream::demux(mtime_t nz_deadline, bool send)
block_t * AbstractStream::readNextBlock(size_t toread)
{
- SegmentChunk *chunk = getChunk();
- if(!chunk)
- return NULL;
+ if (currentChunk == NULL)
+ {
+ if(!eof)
+ currentChunk = segmentTracker->getNextChunk(!fakeesout->restarting(), connManager);
+
+ if (currentChunk == NULL)
+ {
+ eof = true;
+ return NULL;
+ }
+ }
- if(format != chunk->getStreamFormat())
+ if(format != currentChunk->getStreamFormat())
{
/* Force stream to end for this call */
msg_Info(p_realdemux, "Changing stream format %u->%u",
- (unsigned)format, (unsigned)chunk->getStreamFormat());
+ (unsigned)format, (unsigned)currentChunk->getStreamFormat());
restarting_output = true;
- format = chunk->getStreamFormat();
+ format = currentChunk->getStreamFormat();
/* Next stream will use current unused chunk */
return NULL;
}
- if(chunk->discontinuity)
+ if(currentChunk->discontinuity)
{
discontinuity = true;
- chunk->discontinuity = false;
+ currentChunk->discontinuity = false;
msg_Info(p_realdemux, "Encountered discontinuity");
return NULL;
}
- const bool b_segment_head_chunk = (chunk->getBytesRead() == 0);
+ const bool b_segment_head_chunk = (currentChunk->getBytesRead() == 0);
- block_t *block = chunk->read(toread);
+ block_t *block = currentChunk->read(toread);
if(block == NULL)
{
+ delete currentChunk;
currentChunk = NULL;
- delete chunk;
return NULL;
}
- if (chunk->getBytesToRead() == 0)
+ if (currentChunk->getBytesToRead() == 0)
{
+ delete currentChunk;
currentChunk = NULL;
- delete chunk;
}
block = checkBlock(block, b_segment_head_chunk);
diff --git a/modules/demux/adaptative/Streams.hpp b/modules/demux/adaptative/Streams.hpp
index ffc76b8..d0f1e57 100644
--- a/modules/demux/adaptative/Streams.hpp
+++ b/modules/demux/adaptative/Streams.hpp
@@ -91,7 +91,6 @@ namespace adaptative
bool restarting_output;
bool discontinuity;
- SegmentChunk *getChunk();
Demuxer *syncdemux;
More information about the vlc-commits
mailing list