#include <algorithm>
+#include <limits>
namespace VLCTagLib
{
: m_stream( p_stream )
, m_previousPos( 0 )
, m_borked( false )
+ , m_seqReadLength( 0 )
+ , m_seqReadLimit( std::numeric_limits<long>::max() )
{
}
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);
else if ((size_t)i_read != length)
res.resize(i_read);
m_previousPos += i_read;
+ m_seqReadLength += i_read;
return res;
}
return true;
}
+ void setMaxSequentialRead(long s)
+ {
+ m_seqReadLimit = s;
+ }
+
void seek(long offset, Position p)
{
uint64_t pos = 0;
m_borked = (vlc_stream_Seek( m_stream, pos + offset ) != 0);
if(!m_borked)
m_previousPos = pos + offset;
+ m_seqReadLength = 0;
}
void clear()
stream_t* m_stream;
int64_t m_previousPos;
bool m_borked;
+ long m_seqReadLength;
+ long m_seqReadLimit;
};
#endif /* TAGLIB_VERSION_1_11 */