[vlc-commits] meta_engine: taglib: add sequential read limit on VlcIostream
Francois Cartegnie
git at videolan.org
Tue Aug 11 16:22:57 CEST 2020
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Aug 10 14:52:11 2020 +0200| [d375284a144e6b18896deda3a86b9560bc04f3d8] | committer: Francois Cartegnie
meta_engine: taglib: add sequential read limit on VlcIostream
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d375284a144e6b18896deda3a86b9560bc04f3d8
---
modules/meta_engine/taglib.cpp | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/modules/meta_engine/taglib.cpp b/modules/meta_engine/taglib.cpp
index 0ab1fd3ba6..975a971ee1 100644
--- a/modules/meta_engine/taglib.cpp
+++ b/modules/meta_engine/taglib.cpp
@@ -92,6 +92,7 @@ using namespace TagLib;
#include <algorithm>
+#include <limits>
namespace VLCTagLib
{
@@ -157,6 +158,8 @@ public:
: m_stream( p_stream )
, m_previousPos( 0 )
, m_borked( false )
+ , m_seqReadLength( 0 )
+ , m_seqReadLimit( std::numeric_limits<long>::max() )
{
}
@@ -174,7 +177,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);
@@ -183,6 +186,7 @@ public:
else if ((size_t)i_read != length)
res.resize(i_read);
m_previousPos += i_read;
+ m_seqReadLength += i_read;
return res;
}
@@ -209,6 +213,11 @@ public:
return true;
}
+ void setMaxSequentialRead(long s)
+ {
+ m_seqReadLimit = s;
+ }
+
void seek(long offset, Position p)
{
uint64_t pos = 0;
@@ -236,6 +245,7 @@ public:
m_borked = (vlc_stream_Seek( m_stream, pos + offset ) != 0);
if(!m_borked)
m_previousPos = pos + offset;
+ m_seqReadLength = 0;
}
void clear()
@@ -264,6 +274,8 @@ private:
stream_t* m_stream;
int64_t m_previousPos;
bool m_borked;
+ long m_seqReadLength;
+ long m_seqReadLimit;
};
static int ExtractCoupleNumberValues( vlc_meta_t* p_meta, const char *psz_value,
More information about the vlc-commits
mailing list