diff options
-rw-r--r-- | hlsPlayer.cpp | 23 | ||||
-rw-r--r-- | hlsPlayer.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/hlsPlayer.cpp b/hlsPlayer.cpp index a6c0e6b..8feb8f0 100644 --- a/hlsPlayer.cpp +++ b/hlsPlayer.cpp @@ -278,6 +278,10 @@ bool cHlsSegmentLoader::DoLoad(void) std::string segmentUri = GetSegmentUri(m_lastLoadedSegment++); result = LoadSegment(segmentUri); } + } else { + if(nextSegmentSize >= m_ringBufferSize) { + ResizeRingbuffer(nextSegmentSize + MEGABYTE(1)); + } } m_bufferFilled = result; } else { @@ -339,6 +343,25 @@ void cHlsSegmentLoader::Ping(void) } } +void cHlsSegmentLoader::ResizeRingbuffer(int newsize) +{ + hlsMutex.Lock(); + isyslog("[plex] %s, Oldsize: %d, Newsize: %d", __FUNCTION__, m_ringBufferSize, newsize); + //Create new Ringbuffer + cRingBufferLinear* newBuffer = new cRingBufferLinear(newsize, 2*TS_SIZE); + // Copy old data + int count = 0; + uchar* pData = m_pRingbuffer->Get(count); + newBuffer->Put(pData, count); + // delete old buffer + delete m_pRingbuffer; + m_pRingbuffer = NULL; + // assing new buffer + m_pRingbuffer = newBuffer; + m_ringBufferSize = newsize; + hlsMutex.Unlock(); +} + //--- cHlsPlayer cHlsPlayer::cHlsPlayer(std::string startm3u8, plexclient::Video* Video, int offset) diff --git a/hlsPlayer.h b/hlsPlayer.h index 12bea70..111a367 100644 --- a/hlsPlayer.h +++ b/hlsPlayer.h @@ -48,6 +48,7 @@ private: bool LoadSegment(std::string uri); int EstimateSegmentSize(); bool LoadLists(void); + void ResizeRingbuffer(int newsize); protected: |