|
|
|
@ -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, |
|
|
|
|