From: François Cartegnie Date: Mon, 10 Aug 2020 12:52:11 +0000 (+0200) Subject: meta_engine: taglib: add sequential read limit on VlcIostream X-Git-Tag: archive/raspbian/3.0.21-9+rpi1^2~86 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2c985d86c4f1aaf1b2a8a54404ebf996037cd693;p=vlc.git meta_engine: taglib: add sequential read limit on VlcIostream (cherry picked from commit d375284a144e6b18896deda3a86b9560bc04f3d8) (rebased) rebased: - 3.0 already has 1.11 ifdef Gbp-Pq: Name 0040-meta_engine-taglib-add-sequential-read-limit-on-VlcI.patch --- diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp index 58d7683c..a52c67c9 100644 --- a/modules/meta_engine/taglib.cpp +++ b/modules/meta_engine/taglib.cpp @@ -99,6 +99,7 @@ using namespace TagLib; #include +#include namespace VLCTagLib { @@ -167,6 +168,8 @@ public: : m_stream( p_stream ) , m_previousPos( 0 ) , m_borked( false ) + , m_seqReadLength( 0 ) + , m_seqReadLimit( std::numeric_limits::max() ) { } @@ -184,7 +187,7 @@ public: ByteVector readBlock(ulong length) { - if(m_borked) + if(m_borked || m_seqReadLength >= m_seqReadLimit) return ByteVector::null; ByteVector res(length, 0); ssize_t i_read = vlc_stream_Read( m_stream, res.data(), length); @@ -193,6 +196,7 @@ public: else if ((size_t)i_read != length) res.resize(i_read); m_previousPos += i_read; + m_seqReadLength += i_read; return res; } @@ -219,6 +223,11 @@ public: return true; } + void setMaxSequentialRead(long s) + { + m_seqReadLimit = s; + } + void seek(long offset, Position p) { uint64_t pos = 0; @@ -246,6 +255,7 @@ public: m_borked = (vlc_stream_Seek( m_stream, pos + offset ) != 0); if(!m_borked) m_previousPos = pos + offset; + m_seqReadLength = 0; } void clear() @@ -274,6 +284,8 @@ private: stream_t* m_stream; int64_t m_previousPos; bool m_borked; + long m_seqReadLength; + long m_seqReadLimit; }; #endif /* TAGLIB_VERSION_1_11 */